[openharmony]标准系统编译过程分析
2022-02-26 本文已影响0人
itsenlin
编译命令
这里以hi3516dv300开发板为例来分析,编译命令如下
./build.sh --product-name rk3568 --ccache -v
编译过程分析
当前标准系统编译入口是bash脚本,里面调用python脚本,最终调用gn/ninja + makefile/make
整体执行流程如下
build.sh
|==> build/scripts/entry.py
|==> build/lite/build.py # set_root_path的时候调用config.root_path创建编译配置文件ohos_config.json
|==> build/lite/hb/__main__.py #由上级传入build参数,即调用hb的build命令
|==> build/lite/hb_internal/build/build.py (build.exec_command)
|==> build/lite/hb_internal/set/set.py (set_product)
|==> build/lite/hb_internal/common/product.py (get_product_info) # 先在vendor/<company_name>/<product_name>/下查找config.json
# 如果上面文件找不到,则查找productdefine/common/products/<product_name>.json
|==> # 找到对应配置文件之后,通过Config类修改ohos_config.json
|==> build/lite/hb_internal/build/build_process.py (Build.build)
|==> build/lite/hb_internal/common/misc.py (PreBuild.prepare) # 设置ccache,以及重命名日志文件
|==> build/lite/hb_internal/preloader/preloader.py (Preloader.run) # 生成out/preloader/<product_name>/目录
# 读取build/subsystem_config.json,生成out/preloader/<product_name>/subsystem_config.json
# 读取productdefine/common/products/<product_name>.json,
# 生成parts.json、features.json、build.prop、build_config.json、build_gnargs.prop、platforms.build
|==> Build.gn_build
|==> Build.ninja_build
|==> build/lite/hb_internal/common/misc.py (PostBuild.clean)
gn 命令
上面的编译命令最终组成的gn命令如下
gn_cmd = ['gn', 'gen',
'--args=product_path="/home/openharmony/productdefine/common/products"
product_name="rk3568"
device_name="rk3568"
target_cpu="arm"
target_os="ohos"
is_standard_system=true
device_path="device/hihope/build"
ohos_kernel_type="linux"
ohos_build_type="debug"
ohos_build_time="1644821637531"
ohos_build_datetime="2022-02-14 06:53:57"
ohos_build_enable_ccache=true',
'/home/openharmony/out/rk3568']
ninja命令
上面的编译命令最终组成的ninja命令如下:
ninja_cmd = ['ninja', '-w', 'dupbuild=warn', '-C', '/home/openharmony/out/rk3568', '-v', 'images']