Bitbake命令的使用和语法:
$ bitbake -h
Usage: bitbake [options] [recipename/target recipe:do_task ...]
Executes the specified task (default is 'build') for a given set of target recipes (.bb files).
It is assumed there is a conf/bblayers.conf available in cwd or in BBPATH which
will provide the layer, BBFILES and other configuration information.
Options:
--version show program's version number and exit
-h, --help show this help message and exit
-b BUILDFILE, --buildfile=BUILDFILE
Execute tasks from a specific .bb recipe directly.
WARNING: Does not handle any dependencies from other
recipes.
-k, --continue Continue as much as possible after an error. While the
target that failed and anything depending on it cannot
be built, as much as possible will be built before
stopping.
-f, --force Force the specified targets/task to run (invalidating
any existing stamp file).
-c CMD, --cmd=CMD Specify the task to execute. The exact options
available depend on the metadata. Some examples might
be 'compile' or 'populate_sysroot' or 'listtasks' may
give a list of the tasks available.
-C INVALIDATE_STAMP, --clear-stamp=INVALIDATE_STAMP
Invalidate the stamp for the specified task such as
'compile' and then run the default task for the
specified target(s).
-r PREFILE, --read=PREFILE
Read the specified file before bitbake.conf.
-R POSTFILE, --postread=POSTFILE
Read the specified file after bitbake.conf.
-v, --verbose Enable tracing of shell tasks (with 'set -x'). Also
print bb.note(...) messages to stdout (in addition to
writing them to ${T}/log.do_<task>).
-D, --debug Increase the debug level. You can specify this more
than once. -D sets the debug level to 1, where only
bb.debug(1, ...) messages are printed to stdout; -DD
sets the debug level to 2, where both bb.debug(1, ...)
and bb.debug(2, ...) messages are printed; etc.
Without -D, no debug messages are printed. Note that
-D only affects output to stdout. All debug messages
are written to ${T}/log.do_taskname, regardless of the
debug level.
-q, --quiet Output less log message data to the terminal. You can
specify this more than once.
-n, --dry-run Don't execute, just go through the motions.
-S SIGNATURE_HANDLER, --dump-signatures=SIGNATURE_HANDLER
Dump out the signature construction information, with
no task execution. The SIGNATURE_HANDLER parameter is
passed to the handler. Two common values are none and
printdiff but the handler may define more/less. none
means only dump the signature, printdiff means compare
the dumped signature with the cached one.
-p, --parse-only Quit after parsing the BB recipes.
-s, --show-versions Show current and preferred versions of all recipes.
-e, --environment Show the global or per-recipe environment complete
with information about where variables were
set/changed.
-g, --graphviz Save dependency tree information for the specified
targets in the dot syntax.
-I EXTRA_ASSUME_PROVIDED, --ignore-deps=EXTRA_ASSUME_PROVIDED
Assume these dependencies don't exist and are already
provided (equivalent to ASSUME_PROVIDED). Useful to
make dependency graphs more appealing
-l DEBUG_DOMAINS, --log-domains=DEBUG_DOMAINS
Show debug logging for the specified logging domains
-P, --profile Profile the command and save reports.
-u UI, --ui=UI The user interface to use (knotty, ncurses, taskexp or
teamcity - default knotty).
--token=XMLRPCTOKEN Specify the connection token to be used when
connecting to a remote server.
--revisions-changed Set the exit code depending on whether upstream
floating revisions have changed or not.
--server-only Run bitbake without a UI, only starting a server
(cooker) process.
-B BIND, --bind=BIND The name/address for the bitbake xmlrpc server to bind
to.
-T SERVER_TIMEOUT, --idle-timeout=SERVER_TIMEOUT
Set timeout to unload bitbake server due to
inactivity, set to -1 means no unload, default:
Environment variable BB_SERVER_TIMEOUT.
--no-setscene Do not run any setscene tasks. sstate will be ignored
and everything needed, built.
--skip-setscene Skip setscene tasks if they would be executed. Tasks
previously restored from sstate will be kept, unlike
--no-setscene
--setscene-only Only run setscene tasks, don't run any real tasks.
--remote-server=REMOTE_SERVER
Connect to the specified server.
-m, --kill-server Terminate any running bitbake server.
--observe-only Connect to a server as an observing-only client.
--status-only Check the status of the remote bitbake server.
-w WRITEEVENTLOG, --write-log=WRITEEVENTLOG
Writes the event log of the build to a bitbake event
json file. Use '' (empty string) to assign the name
automatically.
--runall=RUNALL Run the specified task for any recipe in the taskgraph
of the specified target (even if it wouldn't otherwise
have run).
--runonly=RUNONLY Run only the specified task within the taskgraph of
the specified targets (and any task dependencies those
tasks may have).
在自己的可执行环境中,运行bitbake -h,可以得出当前环境的bitbake命令的帮助信息。
使用举例:
查看某个recipe的环境设置
$ bitbake -e foo
查询某个变量:
$ bitbake -e foo | grep ^PN
显示此recipe所支持的task
$ bitbake -c listtasks curl
do_build Default task for a recipe - depends on all other normal tasks required to 'build' a recipe
do_checkuri Validates the SRC_URI value
do_clean Removes all output files for a target
do_cleanall Removes all output files, shared state cache, and downloaded source files for a target
do_cleansstate Removes all output files and shared state cache for a target
do_compile Compiles the source in the compilation directory
do_configure Configures the source by enabling and disabling any build-time and configuration options for the software being built
do_deploy_source_date_epoch
do_deploy_source_date_epoch_setscene (setscene version)
do_devpyshell Starts an interactive Python shell for development/debugging
do_devshell Starts a shell with the environment set up for development/debugging
do_fetch Fetches the source code
do_install Copies files from the compilation directory to a holding area
do_listtasks Lists all defined tasks for a target
do_package Analyzes the content of the holding area and splits it into subsets based on available packages and files
do_package_qa Runs QA checks on packaged files
do_package_qa_setscene Runs QA checks on packaged files (setscene version)
do_package_setscene Analyzes the content of the holding area and splits it into subsets based on available packages and files (setscene version)
do_package_write_ipk Creates the actual IPK packages and places them in the Package Feed area
do_package_write_ipk_setscene Creates the actual IPK packages and places them in the Package Feed area (setscene version)
do_packagedata Creates package metadata used by the build system to generate the final packages
do_packagedata_setscene Creates package metadata used by the build system to generate the final packages (setscene version)
do_patch Locates patch files and applies them to the source code
do_populate_lic Writes license information for the recipe that is collected later when the image is constructed
do_populate_lic_setscene Writes license information for the recipe that is collected later when the image is constructed (setscene version)
do_populate_sysroot Copies a subset of files installed by do_install into the sysroot in order to make them available to other recipes
do_populate_sysroot_setscene Copies a subset of files installed by do_install into the sysroot in order to make them available to other recipes (setscene version)
do_prepare_recipe_sysroot
do_unpack Unpacks the source code into a working directory
常用的任务举例:
* fetchall // Fetch all source
* build
* devshell
* package_write_ipk
* cleansstate // Clean the build/sstate-cache directory
* configure
* clean // clean $WORKDIR
* cleanall // clean $WORKDIR and sstate-cache
* populate_lic
* package_write
* populate_sysroot
* buildall
* populate_lic_setscene
* patch
* listtasks // list all tasks that can be run for a target
* compile
* package_setscene
* fetch
* checkuri
* package_write_ipk_setscene
* package
* unpack
* install
* populate_sysroot_setscene
* checkuriall
执行执行某个task:
$ bitbake -c cmd foo
cmd就是上面所列出的任务之一。
而是用bitbake执行此recipe时,进行构建,会按照一定顺序来执行各个任务,查看任务顺序,可以在recipe.taskorder文件中查询,一般路径是:
poky/<build_directory>/tmp/work/<machine_toolchain>/<package_name>/<package_version>/temp/log.task_order
比如,build python v2.7.12工具,使用bitbake python命令,具体的任务执行顺序将位于:
poky/build/tmp/work/<machine_toolchain>/python/2.7.12-r1/temp/log.task_order
Executing a Task Against a Single Recipe / 执行指定的recipe文件里的任务
执行单个recipe文件的任务是相对简单的。你给出有关的文件,BitBake会解析它并执行指定的任务。如果你没有指定任务,BitBake会执行默认任务,即 "build"。BitBake执行时遵循任务间的依赖关系。
下面的命令在foo_1.0.bb的recipe文件上运行build任务,它是默认任务。
$ bitbake -b foo_1.0.bb
下面命令在foo.bb的recipe文件上运行clean任务:
$ bitbake -b foo.bb -c clean
"-b "选项明确地不处理配方的依赖关系。一般仅用于调试时使用。
Executing Tasks Against a Set of Recipe Files / 针对一批recipe文件,执行相应的任务
当一个人想管理多个.bb文件时,会有一些额外的复杂情况。显然,需要有一种方法来告诉BitBake哪些文件是可用的,以及在这些文件中你想执行哪些。还需要有一种方法让每个recipe文件表达它的依赖关系,包括在build-time和runtime中。当多个配方提供相同的功能时,或者当一个配方有多个版本时,必须有一种方法让你能选择合适的配方。
当不使用"-buildfile "或"-b "时,bitbake命令接受的是一个 "PROVIDES",它不是一个文件名或其他东西。默认情况下,一个配方bb文件通常就有一个 "PROVIDES ",是它的"packagename"。
如下例所示:
$ bitbake foo
下一个例子 的"PROVIDES "是软件包的名称,并使用"-c "选项告诉BitBake只执行do_clean任务。
$ bitbake -c clean foo
与-b指定具体文件不同,但不使用-b参数时,后面接的参数需要是一个可用的PROVIDES名字,bitbake会检索当前的环境,寻找符合此名字的PROVIDES,如果找不到,则会提示错误:
$ bitbake helloworld
Loading cache: 100% |#######################################################################################################################################################################| Time: 0:00:00
Loaded 3468 entries from dependency cache.
ERROR: Nothing PROVIDES 'helloworld'. Close matches:
hello
PROVIDES的内容,会由各个bb文件提供,比如有helloworld.bb文件的话,就会提供一个hellworld的PROVIDES名字。如果是多个版本的bb文件,提供的PROVIDES名字只是一个,而选择哪个bb文件执行则另行判断。
bb文件格式为<packagename>_<version>.bb,比如:
blah.bb
blah_1.0.bb
blah_2.0.bb
这三个文件存在的话,bitbake使用的名字都是blah,后缀是其他信息。
如果存在多个版本的bb文件,如果不特殊指定,bitbake会选择更高版本的bb文件,比如:
curl_7.85.0.bb
curl_7.72.0.bb
则会选择第一个bb文件来执行。
Executing a List of Task and Recipe Combinations / 执行多个Recipe的不同任务
当你指定多个目标时,BitBake命令行支持为单个目标指定不同的任务。例如,假设你有两个目标(或配方)myfirstrecipe和mysecondrecipe,你需要BitBake为第一个配方运行任务A,为第二个配方运行任务B。
$ bitbake myfirstrecipe:do_taskA mysecondrecipe:do_taskB
参考: