Difference between revisions of "Bitbake Cheat Sheet"
(Created page with "Here are some quick notes on bitbake syntax and rules. For an exhaustive list of functionality, and longer descriptions, see the bitbake manual at: http://docs.openembedded.org/...") |
|||
| (24 intermediate revisions by one user not shown) | |||
| Line 2: | Line 2: | ||
longer descriptions, see the bitbake manual at: http://docs.openembedded.org/bitbake/html/ (note that this | longer descriptions, see the bitbake manual at: http://docs.openembedded.org/bitbake/html/ (note that this | ||
link goes to the OpenEmbedded version of the bitbake manual, which is a version from 2006 as of this writing. A separate (yocto-specific?) bitbake manual is included in source form in the yocto project source directory, under bitbake/doc.) | link goes to the OpenEmbedded version of the bitbake manual, which is a version from 2006 as of this writing. A separate (yocto-specific?) bitbake manual is included in source form in the yocto project source directory, under bitbake/doc.) | ||
| − | == | + | == Command Line options == |
| + | Here are a few commonly-used command line options. | ||
{| border="1" cellspacing="0" cellpadding="5" | {| border="1" cellspacing="0" cellpadding="5" | ||
|-bgcolor="#80c0d0" | |-bgcolor="#80c0d0" | ||
| Line 8: | Line 9: | ||
!Meaning | !Meaning | ||
|- | |- | ||
| − | |-c <task>||execute <task> for the image or recipe being built. ex: bitbake -c fetch busybox. | + | | -c <task>||execute <task> for the image or recipe being built. ex: bitbake -c fetch busybox. |
Some of the possible tasks are: fetch, configure, compile, package, clean | Some of the possible tasks are: fetch, configure, compile, package, clean | ||
|- | |- | ||
| − | |-f||force execution of the operation, even if not required | + | | -f||force execution of the operation, even if not required |
|- | |- | ||
| − | |-v||show verbose output | + | | -v||show verbose output |
|- | |- | ||
| − | |-DDD||show lots of debug information | + | | -DDD||show lots of debug information |
|- | |- | ||
| − | |-s||show recipe version information | + | | -s||show recipe version information |
|- | |- | ||
| − | |--help||get usage help | + | | --help||get usage help |
|- | |- | ||
| − | |-c listtasks <image-or-recipe-name>|| show the tasks associated with an image or individual recipe | + | | -c listtasks <image-or-recipe-name>|| show the tasks associated with an image or individual recipe |
|- | |- | ||
|-c clean <recipe>||clean up build artifacts for a recipe | |-c clean <recipe>||clean up build artifacts for a recipe | ||
|- | |- | ||
| − | |-g <recipe>||output dependency tree in graphviz format | + | | -g <recipe>||output dependency tree in graphviz format |
|} | |} | ||
| − | == | + | == User interfaces == |
| + | Bitbake can be used with several different user interfaces. Here are some options: | ||
| + | {| border="1" cellspacing="0" cellpadding="5" | ||
| + | |-bgcolor="#80c0d0" | ||
| + | ! style="width: 200px;" | User interface | ||
| + | ! Type | ||
| + | ! NOTES | ||
| + | |- | ||
| + | |bitbake <recipe-or-image> ''or''<br> "bitbake -u knotty <recipe-or-image>" | ||
| + | |scrolling text interface | ||
| + | |This is the default user interface | ||
| + | |- | ||
| + | |bitbake -u ncurses <recipe-or-image> | ||
| + | |text-window based interface | ||
| + | |I couldn't figure out how to control or exit this interface | ||
| + | |- | ||
| + | |bitbake -u hob | ||
| + | |graphical interface | ||
| + | |This is a full graphical interface which includes selecting machine, distro, etc. and performing a build | ||
| + | |- | ||
| + | |bitbake -u goggle <recipe-or-image> | ||
| + | |simple graphical interface | ||
| + | |This is a simple graphical wrapper over the streaming text output of bitbake. It's nice in that it shows collapsible trees for the logs for sub-tasks for each recipe. | ||
| + | |} | ||
| + | == .bb file syntax == | ||
| + | This table lists some of the syntax found in recipe (.bb) files. | ||
{| border="1" cellspacing="0" cellpadding="5" | {| border="1" cellspacing="0" cellpadding="5" | ||
|-bgcolor="#80c0d0" | |-bgcolor="#80c0d0" | ||
| − | !Syntax | + | ! style="width: 270px;" | Syntax |
| − | !Meaning | + | ! Meaning |
| − | !NOTES | + | ! NOTES |
|- | |- | ||
|VAR = "foo"||simple assignment | |VAR = "foo"||simple assignment | ||
| Line 44: | Line 70: | ||
|VAR ??=foo||weak default assignment|| takes lower precedence than ?= | |VAR ??=foo||weak default assignment|| takes lower precedence than ?= | ||
|- | |- | ||
| − | |VAR = "stuff ${OTHER_VAR} more | + | |VAR = "stuff ${OTHER_VAR} more"|| variable expansion||OTHER_VAR expanded at time of reference to VAR |
|- | |- | ||
| − | |VAR := "stuff ${OTHER_VAR} more | + | |VAR := "stuff ${OTHER_VAR} more"||immediate variable expansion||OTHER_VAR expanded at time of parsing this line |
|- | |- | ||
|VAR += "foo"||append with space|| | |VAR += "foo"||append with space|| | ||
| Line 55: | Line 81: | ||
|- | |- | ||
|VAR =. "foo"||prepend without space|| | |VAR =. "foo"||prepend without space|| | ||
| + | |- | ||
| + | |VAR_append = "foo" ||append without space|| | ||
|- | |- | ||
|OVERRIDES="string1:string2"<BR> | |OVERRIDES="string1:string2"<BR> | ||
| Line 62: | Line 90: | ||
|if string1 is listed in OVERRIDES, use "bar" for value of VAR, otherwise use "foo" | |if string1 is listed in OVERRIDES, use "bar" for value of VAR, otherwise use "foo" | ||
|- | |- | ||
| + | |OVERRIDES="string1:string2"<BR> | ||
| + | VAR = "foo"<BR> | ||
| + | VAR_append_string1 = " bar" | ||
| + | |conditional append | ||
| + | |if string1 is in OVERRIDES, then append " bar" to the value of VAR | ||
| + | |- | ||
| + | |BBVERSIONS="1.0 1.8 string"<BR> | ||
| + | VAR="foo"<BR> | ||
| + | VAR_string="bar" | ||
| + | |range-specific conditional | ||
| + | |If the version of the package is in the specified range (1.0-1.8 in this example), then perform an override on the indicated variable | ||
| + | |- | ||
| + | |VAR = "foo ${@<line-of-python-code>}" | ||
| + | |python code expansion | ||
| + | |ex: VAR = "the date is: ${@time.strftime(’%Y%m%d’,time.gmtime())}" | ||
| + | |- | ||
| + | |include foo||include file||include file named "foo", search BBPATH | ||
| + | |- | ||
| + | |require [<path>]foo||require file||include file named "foo", failing if not found exactly where specified | ||
| + | |- | ||
| + | |inherit foo||inherit classes||include definitions from foo.bbclass | ||
| + | |- | ||
| + | |do_sometask() {<BR> | ||
| + | <shell code><BR> | ||
| + | } | ||
| + | |define a task using shell code | ||
| + | | | ||
| + | |- | ||
| + | |python do_sometask {<BR> | ||
| + | <python code><BR> | ||
| + | } | ||
| + | |define a task using python code | ||
| + | | | ||
| + | |- | ||
| + | |addtask sometask (before<nowiki>|</nowiki>after) other_task | ||
| + | |add a task | ||
| + | |adds a defined task to the list of tasks, with the ordering specified. Zero or more 'before' or 'after' clauses can be used. | ||
| + | |- | ||
| + | |VAR[some_flag]="foo" | ||
| + | |associate a subsidiary flag value to a variable | ||
| + | |a few subsidiary flag value names are well-defined: "dirs", "cleandirs", "noexec", "nostamp", "fakeroot", "umask", "deptask", "rdeptask", "recdeptask", "recrdeptask" | ||
| + | Flag values appear to be used exclusively with task definitions (i.e. do_sometask) | ||
| + | |} | ||
| + | |||
| + | == Additional bitbake-related commands == | ||
| + | {| border="1" cellspacing="0" cellpadding="5" | ||
| + | |-bgcolor="#80c0d0" | ||
| + | ! Command | ||
| + | ! Description | ||
| + | ! NOTES | ||
| + | |- | ||
| + | |bitbake-layers | ||
| + | |Show information about layers and recipes | ||
| + | |Included in the bitbake/bin directory in yocto. | ||
| + | |- | ||
| + | |bitbake-env | ||
| + | |Show invidividual bitbake variable values | ||
| + | |see: http://www.crashcourse.ca/wiki/index.php/OE_bitbake-env_utility | ||
| + | |- | ||
| + | |bitbake -g -u depexp <recipe-or-image-name> | ||
| + | |Show dependency information in a graphical interface | ||
| | | | ||
|} | |} | ||
Revision as of 00:58, 4 December 2012
Here are some quick notes on bitbake syntax and rules. For an exhaustive list of functionality, and longer descriptions, see the bitbake manual at: http://docs.openembedded.org/bitbake/html/ (note that this link goes to the OpenEmbedded version of the bitbake manual, which is a version from 2006 as of this writing. A separate (yocto-specific?) bitbake manual is included in source form in the yocto project source directory, under bitbake/doc.)
Contents |
Command Line options
Here are a few commonly-used command line options.
| Option | Meaning |
|---|---|
| -c <task> | execute <task> for the image or recipe being built. ex: bitbake -c fetch busybox.
Some of the possible tasks are: fetch, configure, compile, package, clean |
| -f | force execution of the operation, even if not required |
| -v | show verbose output |
| -DDD | show lots of debug information |
| -s | show recipe version information |
| --help | get usage help |
| -c listtasks <image-or-recipe-name> | show the tasks associated with an image or individual recipe |
| -g <recipe> | output dependency tree in graphviz format |
User interfaces
Bitbake can be used with several different user interfaces. Here are some options:
| User interface | Type | NOTES |
|---|---|---|
| bitbake <recipe-or-image> or "bitbake -u knotty <recipe-or-image>" |
scrolling text interface | This is the default user interface |
| bitbake -u ncurses <recipe-or-image> | text-window based interface | I couldn't figure out how to control or exit this interface |
| bitbake -u hob | graphical interface | This is a full graphical interface which includes selecting machine, distro, etc. and performing a build |
| bitbake -u goggle <recipe-or-image> | simple graphical interface | This is a simple graphical wrapper over the streaming text output of bitbake. It's nice in that it shows collapsible trees for the logs for sub-tasks for each recipe. |
.bb file syntax
This table lists some of the syntax found in recipe (.bb) files.
| Syntax | Meaning | NOTES |
|---|---|---|
| VAR = "foo" | simple assignment | |
| VAR ?= "foo" | assign if no other value is already assigned (default assignment) | |
| VAR ??=foo | weak default assignment | takes lower precedence than ?= |
| VAR = "stuff ${OTHER_VAR} more" | variable expansion | OTHER_VAR expanded at time of reference to VAR |
| VAR := "stuff ${OTHER_VAR} more" | immediate variable expansion | OTHER_VAR expanded at time of parsing this line |
| VAR += "foo" | append with space | |
| VAR =+ "foo" | prepend with space | |
| VAR .= "foo" | append without space | |
| VAR =. "foo" | prepend without space | |
| VAR_append = "foo" | append without space | |
| OVERRIDES="string1:string2" VAR = "foo" |
alternate/override value | if string1 is listed in OVERRIDES, use "bar" for value of VAR, otherwise use "foo" |
| OVERRIDES="string1:string2" VAR = "foo" |
conditional append | if string1 is in OVERRIDES, then append " bar" to the value of VAR |
| BBVERSIONS="1.0 1.8 string" VAR="foo" |
range-specific conditional | If the version of the package is in the specified range (1.0-1.8 in this example), then perform an override on the indicated variable |
| VAR = "foo ${@<line-of-python-code>}" | python code expansion | ex: VAR = "the date is: ${@time.strftime(’%Y%m%d’,time.gmtime())}" |
| include foo | include file | include file named "foo", search BBPATH |
| require [<path>]foo | require file | include file named "foo", failing if not found exactly where specified |
| inherit foo | inherit classes | include definitions from foo.bbclass |
do_sometask() {<shell code> } |
define a task using shell code | |
python do_sometask {<python code> } |
define a task using python code | |
| addtask sometask (before|after) other_task | add a task | adds a defined task to the list of tasks, with the ordering specified. Zero or more 'before' or 'after' clauses can be used. |
| VAR[some_flag]="foo" | associate a subsidiary flag value to a variable | a few subsidiary flag value names are well-defined: "dirs", "cleandirs", "noexec", "nostamp", "fakeroot", "umask", "deptask", "rdeptask", "recdeptask", "recrdeptask"
Flag values appear to be used exclusively with task definitions (i.e. do_sometask) |
| Command | Description | NOTES |
|---|---|---|
| bitbake-layers | Show information about layers and recipes | Included in the bitbake/bin directory in yocto. |
| bitbake-env | Show invidividual bitbake variable values | see: http://www.crashcourse.ca/wiki/index.php/OE_bitbake-env_utility |
| bitbake -g -u depexp <recipe-or-image-name> | Show dependency information in a graphical interface |