OpenHarmony开发者论坛

标题: OH编译构建分析 - 依赖关系检查 [打印本页]

作者: 深开鸿_王石    时间: 2024-1-9 17:55
标题: OH编译构建分析 - 依赖关系检查

背景
OHOS的编译构建系统是由sh脚本(或bat脚本),python脚本,Gn和Ninja工具组成的编译构建框架。总体编译构建流程是根据产品配置,生成具体依赖关系,然后使用Gn配置构建目标,通过Gn生成ninja文件,然后执行ninja生成二进制,最后打包生成镜像的过程。本篇主要涉及编译初期的生成产品配置和依赖关系检查。

编译初期[OHOS INFO] Start building...

[OHOS INFO] Set cache size limit to 100.0 GB
[OHOS INFO] generated build prop info to /home/anybody/ohos/master/newsrc/out/preloader/rk3568/build.prop
[OHOS INFO] generated build config info to /home/anybody/ohos/master/newsrc/out/preloader/rk3568/build_config.json
[OHOS INFO] generated product parts info to /home/anybody/ohos/master/newsrc/out/preloader/rk3568/parts.json
[OHOS INFO] generated parts config info to /home/anybody/ohos/master/newsrc/out/preloader/rk3568/parts_config.json
[OHOS INFO] generated build gnargs prop info to /home/anybody/ohos/master/newsrc/out/preloader/rk3568/build_gnargs.prop
[OHOS INFO] generated features info to /home/anybody/ohos/master/newsrc/out/preloader/rk3568/features.json
[OHOS INFO] generated syscap info to /home/anybody/ohos/master/newsrc/out/preloader/rk3568/syscap.json
[OHOS INFO] generated exclusion modules info to /home/anybody/ohos/master/newsrc/out/preloader/rk3568/exclusion_modules.json
[OHOS INFO] generated platforms build info to /home/anybody/ohos/master/newsrc/out/preloader/rk3568/platforms.build
[OHOS INFO] generated subsystem config info to /home/anybody/ohos/master/newsrc/out/preloader/rk3568/subsystem_config.json
[OHOS INFO] generated system capability info to /home/anybody/ohos/master/newsrc/out/preloader/rk3568/systemcapability.json
[OHOS INFO] generated compile_standard_whitelist info to /home/anybody/ohos/master/newsrc/out/preloader/rk3568/compile_standard_whitelist.json
[OHOS INFO] generated compile_env_allowlist info to /home/anybody/ohos/master/newsrc/out/preloader/rk3568/compile_env_allowlist.json
[OHOS INFO] Checking all build args...
[OHOS INFO] subsytem config scan completed
warning: subsystem name config incorrect in '/home/anybody/ohos/master/newsrc/vendor/hihope/rk3568/ohos.build', build file subsystem name is product_hihope,configured subsystem name is product_rk3568.
warning: subsystem name config incorrect in '/home/anybody/ohos/master/newsrc/device/board/hihope/rk3568/ohos.build', build file subsystem name is rockchip_products,configured subsystem name is device_rk3568.
[OHOS INFO] all parts scan completed
[OHOS INFO] Loading configuration file...

[OHOS INFO] loader args:['platforms_config_file="/home/anybody/ohos/master/newsrc/out/preloader/rk3568/platforms.build"', 'subsystem_config_file="/home/anybody/ohos/master/newsrc/out/preloader/rk3568/subsystem_config.json"', 'example_subsystem_file=""', 'exclusion_modules_config_file="/home/anybody/ohos/master/newsrc/out/preloader/rk3568/exclusion_modules.json"', 'source_root_dir="/home/anybody/ohos/master/newsrc/"', 'gn_root_out_dir="out/rk3568"', 'build_platform_name=phone', 'build_xts=False', 'load_test_config=True', 'target_os=ohos', 'target_cpu=arm', 'os_level=standard', "ignore_api_check=['xts', 'common', 'testfwk']", 'scalable_build=False', 'skip_partlist_check=False']
[OHOS INFO] Checking parts config...
[OHOS INFO] generated subsystem build config to '/home/anybody/ohos/master/newsrc/out/rk3568/build_configs/subsystem_info/subsystem_build_config.json'
[OHOS INFO] generated src subsystem info to '/home/anybody/ohos/master/newsrc/out/rk3568/build_configs/subsystem_info/src_subsystem_info.json'
[OHOS INFO] generated no src subsystem info to '/home/anybody/ohos/master/newsrc/out/rk3568/build_configs/subsystem_info/no_src_subsystem_info.json'
[OHOS INFO] generate target platform parts to '/home/anybody/ohos/master/newsrc/out/rk3568/build_configs/target_platforms_parts.json'
[OHOS INFO] generated system capabilities to '/home/anybody/ohos/master/newsrc/out/rk3568/build_configs/phone_system_capabilities.json'
[OHOS INFO] generated platforms parts by src to '/home/anybody/ohos/master/newsrc/out/rk3568/build_configs/platforms_parts_by_src.json'
[OHOS INFO] generate required parts targets to '/home/anybody/ohos/master/newsrc/out/rk3568/build_configs/required_parts_targets.json'
[OHOS INFO] generate build targets list file to '/home/anybody/ohos/master/newsrc/out/rk3568/build_configs/required_parts_targets_list.json'
[OHOS INFO] generated parts src flag to '/home/anybody/ohos/master/newsrc/out/rk3568/build_configs/subsystem_info/parts_src_flag.json'
[OHOS INFO] generate auto install part to '/home/anybody/ohos/master/newsrc/out/rk3568/build_configs/auto_install_parts.json'
[OHOS INFO] generate platforms list to '/home/anybody/ohos/master/newsrc/out/rk3568/build_configs/platforms_list.gni'
[OHOS INFO] generate part different info to '/home/anybody/ohos/master/newsrc/out/rk3568/build_configs/parts_different_info.json'
[OHOS INFO] generate infos for testfwk to '/home/anybody/ohos/master/newsrc/out/rk3568/build_configs/infos_for_testfwk.json'
[OHOS INFO] Checking all product features...
[OHOS INFO] generate syscap info file to '/home/anybody/ohos/master/newsrc/out/preloader/rk3568/system/etc/SystemCapability.json'
[OHOS INFO] generate syscap info with part name list to '/home/anybody/ohos/master/newsrc/out/preloader/rk3568/system/etc/syscap.json'
[OHOS INFO] generate target syscap for init list to '/home/anybody/ohos/master/newsrc/out/preloader/rk3568/system/etc/param/syscap.para'

[OHOS INFO] Excuting gn command: /home/anybody/ohos/master/newsrc/prebuilts/build-tools/linux-x86/bin/gn gen --args="product_name=\"rk3568\" product_path=\"/home/anybody/ohos/master/newsrc/vendor/hihope/rk3568\" product_config_path=\"/home/anybody/ohos/master/newsrc/vendor/hihope/rk3568\" device_name=\"rk3568\" device_path=\"/home/anybody/ohos/master/newsrc/device/board/rockchip/rk3568\" device_company=\"rockchip\" device_config_path=\"/home/anybody/ohos/master/newsrc/device/board/rockchip/rk3568\" target_cpu=\"arm\" is_standard_system=true ohos_build_compiler_specified=\"\" ohos_build_time=1704150237815 ohos_build_datetime=\"2024-01-02 15:03:57\" ace_engine_feature_enable_accessibility=true ace_engine_feature_enable_web=true datamgr_service_udmf=true code_signature_support_oh_code_sign=false enable_ohos_startup_init_feature_ab_partition=true enable_ohos_startup_init_feature_loader=true dsoftbus_feature_conn_p2p=true dsoftbus_feature_disc_ble=true dsoftbus_feature_conn_br=true dsoftbus_feature_conn_ble=true dsoftbus_feature_trans_udp_stream=true wifi_feature_non_seperate_p2p=true wifi_feature_non_hdf_driver=true graphic_2d_feature_rs_enable_eglimage=true graphic_2d_feature_use_texgine=true audio_framework_feature_dtmf_tone=true audio_framework_feature_opensl_es=true input_feature_combination_key=true input_feature_pointer_drawing=true input_feature_interceptor=true input_feature_monitor=true input_feature_keyboard=true input_feature_mouse=true input_feature_touchscreen=true input_feature_input_device=true memmgr_purgeable_memory=true fusion_interaction_coordination=false wpa_supplicant_driver_nl80211=true hdf_core_platform_test_support=true drivers_peripheral_input_feature_model=true drivers_peripheral_display_community=true drivers_peripheral_display_vdi_default=true drivers_peripheral_wlan_feature_enable_HDF_NL80211=true drivers_peripheral_wlan_feature_enable_HDF_UT=false drivers_peripheral_sensor_feature_model=true drivers_peripheral_audio_feature_full_test_suite=true drivers_peripheral_audio_feature_alsa_lib=false drivers_peripheral_audio_feature_effect=true drivers_peripheral_light_feature_model=true drivers_peripheral_vibrator_feature_model=true drivers_peripheral_codec_feature_support_omx_extend_test=true drivers_peripheral_codec_feature_support_hdi_v1=true use_ffrt=true ohos_build_enable_ccache=true ohos_build_type=\"debug\" device_type=\"default\" build_variant=\"root\" root_perf_main=\"main\" runtime_mode=\"release\"" --args=product_name="rk3568" product_path="/home/anybody/ohos/master/newsrc/vendor/hihope/rk3568" product_config_path="/home/anybody/ohos/master/newsrc/vendor/hihope/rk3568" device_name="rk3568" device_path="/home/anybody/ohos/master/newsrc/device/board/rockchip/rk3568" device_company="rockchip" device_config_path="/home/anybody/ohos/master/newsrc/device/board/rockchip/rk3568" target_cpu="arm" is_standard_system=true ohos_build_compiler_specified="" ohos_build_time=1704150237815 ohos_build_datetime="2024-01-02 15:03:57" ace_engine_feature_enable_accessibility=true ace_engine_feature_enable_web=true datamgr_service_udmf=true code_signature_support_oh_code_sign=false enable_ohos_startup_init_feature_ab_partition=true enable_ohos_startup_init_feature_loader=true dsoftbus_feature_conn_p2p=true dsoftbus_feature_disc_ble=true dsoftbus_feature_conn_br=true dsoftbus_feature_conn_ble=true dsoftbus_feature_trans_udp_stream=true wifi_feature_non_seperate_p2p=true wifi_feature_non_hdf_driver=true graphic_2d_feature_rs_enable_eglimage=true graphic_2d_feature_use_texgine=true audio_framework_feature_dtmf_tone=true audio_framework_feature_opensl_es=true input_feature_combination_key=true input_feature_pointer_drawing=true input_feature_interceptor=true input_feature_monitor=true input_feature_keyboard=true input_feature_mouse=true input_feature_touchscreen=true input_feature_input_device=true memmgr_purgeable_memory=true fusion_interaction_coordination=false wpa_supplicant_driver_nl80211=true hdf_core_platform_test_support=true drivers_peripheral_input_feature_model=true drivers_peripheral_display_community=true drivers_peripheral_display_vdi_default=true drivers_peripheral_wlan_feature_enable_HDF_NL80211=true drivers_peripheral_wlan_feature_enable_HDF_UT=false drivers_peripheral_sensor_feature_model=true drivers_peripheral_audio_feature_full_test_suite=true drivers_peripheral_audio_feature_alsa_lib=false drivers_peripheral_audio_feature_effect=true drivers_peripheral_light_feature_model=true drivers_peripheral_vibrator_feature_model=true drivers_peripheral_codec_feature_support_omx_extend_test=true drivers_peripheral_codec_feature_support_hdi_v1=true use_ffrt=true ohos_build_enable_ccache=true ohos_build_type="debug" device_type="default" build_variant="root" root_perf_main="main" runtime_mode="release" /home/anybody/ohos/master/newsrc/out/rk3568

简单解读常见Q&A解读
常见七类问题
错误原因:
子系统配置清单中的子系统名和部件配置清单中的子系统名不一致;或bundle.json中的部件名和部件配置清单中的部件名不一致
Warning: find subsystem startup_ext failed, please check it in /home/XXX/workspace/system_single_frame/system_component/out/products_ext/vendor/xxx/XXX/config.json.

Exception: find subsystem startup_ext failed, please check it in /home/XXX/workspace/system_single_frame/system_component/out/products_ext/vendor/xxx/XXX/config.json.
Warning: find component hiview_plugins_xxx failed, please check it in /home/XXX/workspace/system_single_frame/system_component/out/products_ext/vendor/xxx/XXX/config.json.

Exception: find component hiview_plugins failed, please check it in /home/XXX/workspace/system_single_frame/system_component/out/products_ext/vendor/xxx/XXX/config.json.
解读:
“subsystem” 代表产品部件列表(config.json)配置的子系统名错误
“component”代表产品部件列表(config.json)配置的部件名错误
此类问题代表vendor\xxx\build\component_config\system\XXX\part_config.json 文件中配置的子系统名或者部件名错误,component 代表部件名配置错误, subsystem 代表子系统名配置错误
整改方法:
如果是子系统名配置错误,请排查 part_config.json中配置的子系统名是否在subsystem_config.json中有配置
OHOS的subsystem_config.json路径:build/subsystem_config.json
如果是部件名配置错误,请排查part_config.json文件中的部件名是否和该部件的bundle.json中的部件名配置一致

错误原因:
bundle.json中定义的子系统名和子系统配置清单中的不一致
具体日志
warning: subsystem name config incorrect in '/home/XXX/workspace/system_single_frame/system_component/foundation/ability/ability_base/bundle.json', build file subsystem name is ability, configured subsystem name is aafwk.

Exception: subsystem name config incorrect in '/home/XXX/workspace/system_single_frame/system_component/foundation/ability/ability_base/bundle.json', build file subsystem name is ability, configured subsystem name is aafwk.
解读:
该问题代表bundle.json里的子系统名称配置和subsystem_config.json配置不一致,需要整改bundle.json的子系统名称
bundle.json路径:foundation/ability/ability_base/bundle.json
整改方法:
请检查本部件bundle.json中是否有配置子系统并且配置的子系统名与subsystem_config.json中一致,若不一致,请将bundle.json中的子系统名改为subsystem_config.json中的子系统名

错误原因:
BUILD.gn中定义的部件名或子系统名与bundle.json中定义的不一致
具体日志:
[OHOS INFO] warning: subsystem name or part name is incorrect, target is //foundation/distributedhardware/distributed_audio/hdf_service/distributed_audio/hdi_service/audio/v1_0:libaudio_manager_daudio_primary_service_1.0, subsystem name is hdf, part name is drivers_peripheral_distributed_audio

Exception: subsystem name or part name is incorrect, target is //foundation/distributedhardware/distributed_audio/hdf_service/distributed_audio/hdi_service/audio/v1_0:libaudio_manager_daudio_primary_service_1.0, subsystem name is hdf, part name is drivers_peripheral_distributed_audio
解读:
该问题代表模块的BUILD.gn里面配置的子系统名或者部件名不准确,需要和部件bundle.json对齐
BUILD.gn路径:foundation/distributedhardware/distributed_audio/hdf_service/distributed_audio/hdi_service/audio/v1_0/BUILD.gn
编译目标:libaudio_manager_daudio_primary_service_1.0
整改方法:
将本部件下该模块BUILD.gn中的部件名与子系统名改为本部件bundle.json中的子系统名和部件名
如果已确认BUILD.gn和bundle.json中的子系统名和部件名一致,请再确认part_config.json中是否正确配置了该子系统名和部件名
part_config.json路径:(和编译命令中abi-type、device-type参数一致)
系统组件:
vendor/xxx/build/component_config/system/XXX/part_config.json
vendor/xxx/build/component_config/system/XXX/part_config.json
芯片组件:
vendor/xxx/build/component_config/chipset/XXX/part_config.json
vendor/xxx/build/component_config/chipset/XXX/part_config.json

错误原因:
BUILD.gn中使用deps依赖了外部部件的模块
具体日志:
[OHOS INFO] WARNING:deps validation part_name: 'distributed_camera', target: '//foundation/distributedhardware/distributed_camera/services/channel:distributed_camera_channel', dep: '//foundation/distributedhardware/distributed_hardware_fwk/interfaces/inner_kits:libdhfwk_sdk' failed!!
解读:
该问题代表该模块通过deps依赖了部件外的模块,应该用external_deps依赖
BUILD.gn路径:foundation/distributedhardware/distributed_camera/services/channel/BUILD.gn
编译目标:distributed_camera_channel
deps中依赖的外部模块:foundation/distributedhardware/distributed_hardware_fwk/interfaces/inner_kits:libdhfwk_sdk
整改方法:
将该模块从deps转移到external_deps中
注:deps中使用的是"路径:模块名",而改到external_deps中是使用 "部件名:模块名" 的方式

错误原因:
使用external_deps依赖了本部件的模块
具体日志:
[OHOS INFO] WARNING: preferences in target //foundation/distributeddatamgr/preferences/frameworks/js/napi/preferences:preferences is dependency within part preferences, Need to used deps

Exception: preferences in target //foundation/distributeddatamgr/preferences/frameworks/js/napi/preferences:preferences is dependency within part preferences, Need to used deps
解读:
该日志代表该模块通过external_deps依赖了本部件模块,需要改成deps依赖
BUILD.gn路径:foundation/distributeddatamgr/preferences/frameworks/js/napi/preferences
external_deps中依赖的本部件:preferences
整改方法:
将该依赖从external_deps转移到deps中

错误原因:BUILD.gn中外部依赖了其他部件的模块,但是bundle.json中没有添加这个部件
注:对于三方部件,如果BUILD.gn里面用的是deps依赖,那在bundle.json中需要加到third_party中,如果使用的是external_deps依赖的三方部件,那在bundle.json中需要加到components中
具体日志:
[OHOS INFO] WARNING: //base/theme/wallpaper_mgr/frameworks/kits/extension:wallpaperextension depend part window_manager, need set part deps info to /home/XXX/workspace/system_single_frame/system_component/base/theme/wallpaper_mgr/bundle.json.

Exception: //base/theme/wallpaper_mgr/frameworks/kits/extension:wallpaperextension depend part window_manager, need set part deps info to /home/XXX/workspace/system_single_frame/system_component/base/theme/wallpaper_mgr/bundle.json.
解读:
该日志代表该模块(BUILD.gn)里面依赖的外部部件,但没有在部件bundle.json声明,需要在bundle.json声明。
BUILD.gn路径:base/theme/wallpaper_mgr/frameworks/kits/extension/BUILD.gn
编译目标:wallpaperextension
依赖的部件:window_manager
bundle.json路径:base/theme/wallpaper_mgr/bundle.json.
整改方法:
将被依赖的外部部件添加到bundle.json中的deps:components字段中,如上述例子中,需要将”input”和”window_manager”添加到bundle.json中

错误原因:
BUILD.gn中依赖了三方部件,但是部件bundle.json中没有添加该三方部件
具体日志:
[OHOS INFO] WARNING: //base/security/device_auth/services:deviceauth_service depend part //third_party/cJSON:cjson, need set part deps cjson info to /home/XXX/workspace/chipset_single_frame/vendor_baltimore_musl/base/security/device_auth/bundle.json.

Exception: //base/security/device_auth/services:deviceauth_service depend part //third_party/cJSON:cjson, need set part deps cjson info to /home/XXX/workspace/chipset_single_frame/vendor_baltimore_musl/base/security/device_auth/bundle.json.
解读:
该日志代表该模块(BUILD.gn)里面依赖的三方部件,没有在部件bundle.json中的third_party中声明,需要在bundle.json声明。
BUILD.gn路径:base/security/device_auth/services
编译目标:deviceauth_service
依赖的三方部件:cjson
bundle.json路径:vendor_baltimore_musl/base/security/device_auth/bundle.json
整改方法:
将被依赖的三方部件添加到bundle.json中的deps:third_party字段中,如上述例子中,需要将 "cjson" 添加到bundle.json中








欢迎光临 OpenHarmony开发者论坛 (https://forums.openharmony.cn/) Powered by Discuz! X3.5