1、问题描述

全新的编译环境,编译时报错信息摘要如下:

[OHOS ERROR] [12402/69853] /usr/bin/env ../../build/templates/common/check_build_target.py --part-name device_rk3588 --subsystem-name device_
rk3588 --target-path //device/board/hihope/dayu210/camera/vdi_impl/v4l2:camera_host_vdi_impl_1.0 --depfile gen/device/board/hihope/dayu210/ca
mera/vdi_impl/v4l2/camera_host_vdi_impl_1.0__check.d --output obj/device/board/hihope/dayu210/camera/vdi_impl/v4l2/camera_host_vdi_impl_1.0__
check.txt --compile-standard-allow-file ../preloader/dayu210/compile_standard_whitelist.json --deps //device/board/hihope/dayu210/camera/vdi_
impl/v4l2/device_manager:camera_device_manager //device/board/hihope/dayu210/camera/vdi_impl/v4l2/pipeline_core:camera_pipeline_core --extern
al-deps c_utils:utils drivers_peripheral_camera:peripheral_camera_buffer_manager drivers_peripheral_camera:peripheral_camera_device_manager d
rivers_peripheral_camera:peripheral_camera_metadata_manager drivers_peripheral_camera:peripheral_camera_pipeline_core drivers_peripheral_came
ra:peripheral_camera_utils drivers_peripheral_camera:peripheral_camera_v4l2_adapter graphic_chipsetsdk:surface hdf_core:libhdf_host hdf_core:
libhdf_ipc_adapter hdf_core:libhdf_utils hdf_core:libhdi hilog:libhilog ipc:ipc_single drivers_interface_camera:libbuffer_producer_sequenceab
le_1.0 drivers_interface_camera:metadata drivers_interface_display:libdisplay_composer_proxy_1.0 hitrace:hitrace_meter ipc:ipc_single        
[OHOS ERROR] FAILED: obj/device/board/hihope/dayu210/camera/vdi_impl/v4l2/camera_host_vdi_impl_1.0__check.txt 
[OHOS ERROR] /usr/bin/env ../../build/templates/common/check_build_target.py --part-name device_rk3588 --subsystem-name device_rk3588 --targe
t-path //device/board/hihope/dayu210/camera/vdi_impl/v4l2:camera_host_vdi_impl_1.0 --depfile gen/device/board/hihope/dayu210/camera/vdi_impl/
v4l2/camera_host_vdi_impl_1.0__check.d --output obj/device/board/hihope/dayu210/camera/vdi_impl/v4l2/camera_host_vdi_impl_1.0__check.txt --co
mpile-standard-allow-file ../preloader/dayu210/compile_standard_whitelist.json --deps //device/board/hihope/dayu210/camera/vdi_impl/v4l2/devi
ce_manager:camera_device_manager //device/board/hihope/dayu210/camera/vdi_impl/v4l2/pipeline_core:camera_pipeline_core --external-deps c_util
s:utils drivers_peripheral_camera:peripheral_camera_buffer_manager drivers_peripheral_camera:peripheral_camera_device_manager drivers_periphe
ral_camera:peripheral_camera_metadata_manager drivers_peripheral_camera:peripheral_camera_pipeline_core drivers_peripheral_camera:peripheral_
camera_utils drivers_peripheral_camera:peripheral_camera_v4l2_adapter graphic_chipsetsdk:surface hdf_core:libhdf_host hdf_core:libhdf_ipc_ada
pter hdf_core:libhdf_utils hdf_core:libhdi hilog:libhilog ipc:ipc_single drivers_interface_camera:libbuffer_producer_sequenceable_1.0 drivers
_interface_camera:metadata drivers_interface_display:libdisplay_composer_proxy_1.0 hitrace:hitrace_meter ipc:ipc_single
[OHOS ERROR] Traceback (most recent call last):
[OHOS ERROR]   File "../../build/templates/common/check_build_target.py", line 71, in <module>
[OHOS ERROR]     sys.exit(main())
[OHOS ERROR]   File "../../build/templates/common/check_build_target.py", line 58, in main
[OHOS ERROR]     _depfile = check_external_deps.check(args)
[OHOS ERROR]   File "/openharmony/build/templates/common/check_external_deps.py", line 77, in check
[OHOS ERROR]     check_parts_deps(args, external_part_name, parts_deps_info)
[OHOS ERROR]   File "/openharmony/build/templates/common/check_external_deps.py", line 56, in check_parts_deps
[OHOS ERROR]     raise Exception(_warning_info)
[OHOS ERROR] Exception: //device/board/hihope/dayu210/camera/vdi_impl/v4l2:camera_host_vdi_impl_1.0 depend part c_utils, need set part deps info to device_rk3588.

[OHOS ERROR] Exception: //device/board/hihope/dayu210/camera/vdi_impl/v4l2/device_manager:camera_device_manager depend part c_utils, need set part deps info to device_rk3588.

[OHOS ERROR] Exception: //device/board/hihope/dayu210/camera/vdi_impl/v4l2/pipeline_core:camera_ipp_algo_example depend part c_utils, need set part deps info to device_rk3588.

[OHOS ERROR] FAILED: obj/device/board/hihope/dayu210/camera/vdi_impl/v4l2/pipeline_core/camera_pipeline_core__check.txt                      
[OHOS ERROR] /usr/bin/env ../../build/templates/common/check_build_target.py --part-name device_rk3588 --subsystem-name device_rk3588 --targe
t-path //device/board/hihope/dayu210/camera/vdi_impl/v4l2/pipeline_core:camera_pipeline_core --depfile gen/device/board/hihope/dayu210/camera
/vdi_impl/v4l2/pipeline_core/camera_pipeline_core__check.d --output obj/device/board/hihope/dayu210/camera/vdi_impl/v4l2/pipeline_core/camera
_pipeline_core__check.txt --compile-standard-allow-file ../preloader/dayu210/compile_standard_whitelist.json --deps //device/board/hihope/day
u210/camera/vdi_impl/v4l2:config.c //device/board/hihope/dayu210/camera/vdi_impl/v4l2:params.c //device/board/hihope/dayu210/camera/vdi_impl/
v4l2/device_manager:camera_device_manager //device/soc/rockchip/rk3588/hardware/mpp:libmpp //device/soc/rockchip/rk3588/hardware/rga:librga /
/third_party/libjpeg-turbo:turbojpeg_static --external-deps drivers_peripheral_camera:peripheral_camera_buffer_manager drivers_peripheral_cam
era:peripheral_camera_device_manager drivers_peripheral_camera:peripheral_camera_metadata_manager drivers_peripheral_camera:peripheral_camera
_pipeline_core drivers_peripheral_camera:peripheral_camera_utils drivers_peripheral_camera:peripheral_camera_v4l2_adapter hdf_core:libhdf_uti
ls hilog:libhilog c_utils:utils drivers_interface_camera:libbuffer_producer_sequenceable_1.0 drivers_interface_camera:metadata graphic_chipse
tsdk:surface ipc:ipc_single                                                                                                                  
[OHOS ERROR] Traceback (most recent call last):                                                                                              
[OHOS ERROR]   File "../../build/templates/common/check_build_target.py", line 71, in <module>                                               
[OHOS ERROR]     sys.exit(main())                                                                                                            
[OHOS ERROR]   File "../../build/templates/common/check_build_target.py", line 54, in main                                                   
[OHOS ERROR]     _depfile = check_deps_handler.check(args)                                                                                   
[OHOS ERROR]   File "/openharmony/build/templates/common/check_deps_handler.py", line 175, in check                                          
[OHOS ERROR]     check_part_deps(args, part_pattern, path_parts_info,compile_standard_allow_info, depfiles)                                  
[OHOS ERROR]   File "/openharmony/build/templates/common/check_deps_handler.py", line 150, in check_part_deps                                
[OHOS ERROR]     raise Exception(message) 
[OHOS ERROR] Exception: deps validation part_name: 'device_rk3588', target: '//device/board/hihope/dayu210/camera/vdi_impl/v4l2/pipeline_core
:camera_pipeline_core', dep: '//device/soc/rockchip/rk3588/hardware/mpp:libmpp' failed!!!

2、问题分析

从日志看有两类报错,前三个属于一种情况,都是device_rk3588这个part没有显示声明依赖c_utils这个part导致的;第四个属于一种情况。

2.1 device_rk3588这个part没有显示声明依赖c_utils

目标//device/board/hihope/dayu210/camera/vdi_impl/v4l2:camera_host_vdi_impl_1.0定义如下,通过external_deps标识自己依赖c_utils:utils

  ohos_shared_library("camera_host_vdi_impl_1.0") {
    sources = host_sources
...
    if (is_standard_system) {
      external_deps = [
        "c_utils:utils",
        "drivers_peripheral_camera:peripheral_camera_buffer_manager",
        "drivers_peripheral_camera:peripheral_camera_device_manager",
        "drivers_peripheral_camera:peripheral_camera_metadata_manager",
        "drivers_peripheral_camera:peripheral_camera_pipeline_core",
        "drivers_peripheral_camera:peripheral_camera_utils",
        "drivers_peripheral_camera:peripheral_camera_v4l2_adapter",
        "graphic_chipsetsdk:surface",
        "hdf_core:libhdf_host",
...

查看ohos_shared_library这个模板的定义,其中有一步会执行脚本//build/templates/common/check_build_target.py检查构建目标的依赖配置。

template("ohos_shared_library") {
...
  if (is_use_check_deps && !_test_target) {
    _check_target = "${target_name}__check"
    target_path = get_label_info(":${target_name}", "label_no_toolchain")
    check_target(_check_target) {
      module_deps = []
      if (defined(invoker.deps)) {
        module_deps += invoker.deps
      }
      if (defined(invoker.public_deps)) {
        module_deps += invoker.public_deps
      }
      if (defined(invoker.external_deps)) {
        module_ex_deps = invoker.external_deps
      }
    }
  }
...
template("check_target") {
...
  action(target_name) {
    script = "//build/templates/common/check_build_target.py"
    depfile = "${target_gen_dir}/$target_name.d"
    outputs = [ "${target_out_dir}/${target_name}.txt" ]
    _compile_standard_allow_file =
        "$preloader_output_dir/compile_standard_whitelist.json"
    args = [
      "--part-name",
      part_name,
      "--subsystem-name",
      subsystem_name,
      "--target-path",
      target_path,
      "--depfile",
      rebase_path(depfile, root_build_dir),
      "--output",
      rebase_path(outputs[0], root_build_dir),
      "--compile-standard-allow-file",
      rebase_path(_compile_standard_allow_file, root_build_dir),
    ]

    if (defined(invoker.skip_check_subsystem) &&
        invoker.skip_check_subsystem == true) {
      args += [ "--skip-check-subsystem" ]
    }

    if (defined(invoker.module_deps)) {
      dep_labels = []
      foreach(label, invoker.module_deps) {
        dep_labels += [ get_label_info(label, "label_no_toolchain") ]
      }
      args += [ "--deps" ]
      args += dep_labels
    }

    if (defined(invoker.module_ex_deps)) {
      args += [ "--external-deps" ]
      args += invoker.module_ex_deps
    }
  }
}

check_build_target.py脚本会根据传参执行几种检查

def main():
    args = parse_args()
    
    depfiles = []
    if not args.skip_check_subsystem:
        _depfile = check_part_subsystem_name.check(args)
        depfiles.extend(_depfile)
    
    if args.deps:
        _depfile = check_deps_handler.check(args)
        depfiles.extend(_depfile)
    
    if args.external_deps:
        _depfile = check_external_deps.check(args)
        depfiles.extend(_depfile)
    
    if depfiles:
        depfiles = list(set(depfiles))
        write_depfile(args.depfile, args.output, depfiles)
    
    touch(args.output)
    
    return 0

如果external_deps有值就执行check_external_deps.check(args)检查外部依赖

def check(args):
    depfiles = []
    if len(args.external_deps) == 0:
        return depfiles

    external_deps = args.external_deps

    parts_deps_file = 'build_configs/parts_info/parts_deps.json'
    parts_deps_info = read_json_file(parts_deps_file)
    if parts_deps_info is None:
        raise Exception("read pre_build parts_deps failed.")
    depfiles.append(parts_deps_file)

    for external_lib in external_deps:
        deps_desc = external_lib.split(':')
        external_part_name = deps_desc[0]
        check_parts_deps(args, external_part_name, parts_deps_info)

    return depfiles

def check_parts_deps(args, external_part_name, parts_deps_info):
    compile_standard_allow_file = args.compile_standard_allow_file
    compile_standard_allow_info = read_json_file(compile_standard_allow_file)
    added_self_part_allow_list = compile_standard_allow_info.get("external_deps_added_self_part_module", []) 
    bundle_not_add_allow_list = compile_standard_allow_info.get("external_deps_bundle_not_add", []) 
    if external_part_name == args.part_name:
        message = "{} in target {} is dependency within part {}, Need to used deps".format(
            external_part_name, args.target_path, args.part_name)
        if args.target_path in added_self_part_allow_list:
            print(f"[0/0] WARNING: {message}")
            return
        else:
            raise Exception(message)

    _tips_info = "{} depend part {}, need set part deps info to".format(
        args.target_path, external_part_name)

    part_deps_info = parts_deps_info.get(args.part_name)
    if not part_deps_info:
        _warning_info = "{} {}.".format(_tips_info, args.part_name)
    elif not part_deps_info.get('components') or \
        not external_part_name in part_deps_info.get('components'):
        _warning_info = "{} {}.".format(_tips_info, part_deps_info.get('build_config_file'))
    else:
        _warning_info = ""

    if _warning_info != "": 
        if args.target_path in bundle_not_add_allow_list:
            print(f"[0/0] WARNING: {_warning_info}")
        else:
            raise Exception(_warning_info)

    return

具体检查项目是,external_part_name必须在当前构建part的deps列表中,这个deps列表是从//out/rk3588/build_configs/parts_info/parts_deps.json读取的,但是当前构建part是device_rk3588parts_deps.json中的deps列表是空值。

...
  "device_rk3588": null,
  "device_security_level": {
    "build_config_file": "/openharmony/base/security/device_security_level/bundle.json",
    "components": [
      "c_utils",
      "device_auth",
      "device_manager",
      "dsoftbus",
      "hilog",
      "hisysevent",
      "hitrace",
      "huks",
      "ipc",
      "safwk",
      "samgr"
    ],
    "third_party": [
      "cJSON",
      "openssl"
    ]
  },
...

参考上面这个device_security_levelpart的信息,应该是通过bundle.json文件维护part的依赖组件列表,但是device_rk3588device/board/hihope/dayu210/目录下没有bundle.json。
那么,针对这个问题,应该在哪儿指定device_rk3588所依赖的parts呢?

2.2 deps校验失败

这个问题的触发原因类似问题1,只是检查的对象是构建目标的deps参数。
同样,该问题,应该在哪儿指定依赖的target?

3 临时解决办法

hb build时指定gn变量is_use_check_deps = false
hb build --gn-args 'is_use_check_deps=false'

Logo

社区规范:仅讨论OpenHarmony相关问题。

更多推荐