【简介】
zephyr 的开发过程中工程的管理使用的west 命令,我们基于现有的开发梳理下本地经常用到的命令。
1.工程下的borad 信息查看
zephyr 的编译管理是基于board进行管理的,我们有时需要查看当前工程下支持的板卡信息,可以使用 “west boards” 查命令可以查看当前所支持的board 信息

2.工程编译命令
编译命令使用的west build 以下是命令的使用说明。
west build -h
usage: west build [-h] [-b BOARD[@REV]] [-d BUILD_DIR]
[-S SNIPPET] [--shield SHIELD]
[-t TARGET] [-p {auto, always, never}] [-c] [--cmake-only]
[--cmake-opt CMAKE_OPT] [-n] [-o BUILD_OPT] [-f]
[--sysbuild | --no-sysbuild] [--domain DOMAIN]
[--extra-conf FILE.conf]
[--extra-dtc-overlay FILE.overlay]
[source_dir] -- [cmake_opt [cmake_opt ...]]
Convenience wrapper for building Zephyr applications.
If the build directory is not given, the default is build/ unless the
build.dir-fmt configuration variable is set. The current directory is
checked after that. If either is a Zephyr build directory, it is used.
positional arguments:
source_dir application source directory
cmake_opt extra options to pass to cmake; implies -c
(these must come after "--" as shown above)
options:
-h, --help show this help message and exit
-b BOARD, --board BOARD
board to build for with optional board revision
-d BUILD_DIR, --build-dir BUILD_DIR
build directory to create or use
-f, --force ignore any errors and try to proceed
cmake and build tool:
-c, --cmake force a cmake run
--cmake-opt CMAKE_OPTS
alternative to the end-of-options marker '--'. Can be given multiple times and 'argparse' should preserve the order for CMake. Not mutually exclusive with '--': options after '--' are given last to CMake.
--cmake-only just run cmake; don't build (implies -c)
--domain DOMAIN execute build tool (make or ninja) only for given domain
-t TARGET, --target TARGET
run build system target TARGET (try "-t usage")
-T TEST_ITEM, --test-item TEST_ITEM
Build based on test data in test definition file. If source directory is not used an argument has to be defined as SOURCE_PATH/TEST_NAME. E.g. samples/hello_world/sample.basic.helloworld. If source directory is
passed then "TEST_NAME" is enough.
-o BUILD_OPT, --build-opt BUILD_OPT
options to pass to the build tool (make or ninja); may be given more than once
-n, --just-print, --dry-run, --recon
just print build commands; don't run them
-S SNIPPET, --snippet SNIPPET
add the argument to SNIPPET; may be given multiple times. Forces CMake to run again if given. Do not use this option with manually specified -DSNIPPET... cmake arguments: the results are undefined
--shield SHIELD add the argument to SHIELD; may be given multiple times. Forces CMake to run again if given. Do not use this option with manually specified -DSHIELD... cmake arguments: the results are undefined
--extra-conf EXTRA_CONF_FILE
add the argument to EXTRA_CONF_FILE; may be given multiple times. Forces CMake to run again if given. Do not use this option with manually specified -DEXTRA_CONF_FILE... cmake arguments: the results are undefined
--extra-dtc-overlay EXTRA_DTC_OVERLAY_FILE
add the argument to EXTRA_DTC_OVERLAY_FILE; may be given multiple times. Forces CMake to run again if given. Do not use this option with manually specified -DEXTRA_DTC_OVERLAY_FILE... cmake arguments: the results
are undefined
--sysbuild, --no-sysbuild
create multi domain build system or disable it (default)
pristine builds:
A "pristine" build directory is empty. The -p option controls
whether the build directory is made pristine before the build
is done. A bare '--pristine' with no value is the same as
--pristine=always. Setting --pristine=auto uses heuristics to
guess if a pristine build may be necessary.
-p [{auto,always,never}], --pristine [{auto,always,never}]
pristine build folder setting上述的编译参数比较常用的是-p -b -d 选项:
-b: 指定需要编译的board 名称
-d:指定编译的成果物的输出路径,不配置使用默认的build 目录
-p:指定编译的方式,我们常用的为 always 每次都进行重新构建会比较耗时,auto 根据当前修改进行编译。
west build -p always -b s32k324_evb -d build_s32k324_evb samples\subsys\shell\shell_module\
本地使用如上的命令来编译示例程序

3.详细编译过程信息查看
编译过程中如果需要查看详细的编译参数及选项可以使用-v 选项
我们在之前的编译命令基础上添加 -v 选项后
west -v build -p always -b s32k324_evb samples\subsys\shell\shell_module\
终端就会输出详细的编译参数及过程

我要赚赏金
