Android.bp编译报错

avatar
作者
猴君
阅读量:0
[100% 3/3] out/soong/.bootstrap/bin/soong_build out/soong/build.ninja FAILED: out/soong/build.ninja out/soong/.bootstrap/bin/soong_build -t -l out/.module_paths/Android.bp.list -b out/soong -n out -d out/soong/build.ninja.d -globFile out/soong/.bootstrap/build-globs.ninja -o out/soong/build.ninja Android.bp Clang SA is not enabled error: external/test_prog/Android.bp:1:1: dependency "libc++fs" of "test_prog" missing variant:   os:android, image:vendor.30, arch:arm64_armv8-a, sdk:, link:static, version: available variants:   os:android, image:, arch:arm64_armv8-a, sdk:, link:static, version:   os:android, image:, arch:arm_armv7-a-neon_cortex-a9, sdk:, link:static, version:   os:android, image:recovery, arch:arm64_armv8-a, sdk:, link:static   os:linux_glibc, arch:x86, link:static   os:linux_glibc, arch:x86_64, link:static   os:windows, arch:x86, link:static   os:windows, arch:x86_64, link:static 17:10:46 soong bootstrap failed with: exit status 1 
  1. 背景
    这个错误是由于在.bp文件中引用了libc++fs库,同时这个模块声明了vendor: true属性,但libc++fs不支持vendor使用。
    libc++fs这个库是external/libcxx中的一个模块,默认编译方式不允许vendor使用(Android11上C++版本较低,filesystem尚未正式标准化)
cc_binary {     name: "test_prog",     vendor: true,     static_libs: [         // "libc++experimental",         "libc++fs",     ],     ... } 
  1. 分析编译报错:
    提示:编译模块test_prog依赖libc++fs,缺少可用的版本类型(variant),所需的类型已注明。这个是期望类型。
error: external/test_prog/Android.bp:1:1: dependency "libc++fs" of "test_prog" missing variant:   os:android, image:vendor.30, arch:arm64_armv8-a, sdk:, link:static, version: 

同时,提示当前可用版本类型(available variants),每行是一个类型。

available variants:   os:android, image:, arch:arm64_armv8-a, sdk:, link:static, version:   os:android, image:, arch:arm_armv7-a-neon_cortex-a9, sdk:, link:static, version:   os:android, image:recovery, arch:arm64_armv8-a, sdk:, link:static   os:linux_glibc, arch:x86, link:static   os:linux_glibc, arch:x86_64, link:static   os:windows, arch:x86, link:static   os:windows, arch:x86_64, link:static 
  1. 确认可用类型
    查找编译目录,找到以下几种平台类型的静态库。前面几种arm类型的都能对应上,x86平台的只编译出来linux_glibc_x86_64_static版本,这个是和当前PC编译环境对应的,其他3中x86类型缺失是由于当前环境下不具备编译条件。
out/soong/.intermediates/external/libcxx/libc++fs$ find . -name *.a ./android_arm64_armv8-a_static_cfi/libc++fs.a ./android_arm_armv7-a-neon_cortex-a9_static/libc++fs.a ./android_recovery_arm64_armv8-a_static/libc++fs.a ./android_arm64_armv8-a_static/libc++fs.a ./linux_glibc_x86_64_static/libc++fs.a 
  1. 定位问题
    把“期望类型”和“已有类型”对比差异,逐个字段比较,看缺少哪项。
    这个例子中发现缺少:image:vendor.30。可以通过libc++fs库对应的.bp文件进行确认。
cc_defaults {     name: "libc++ defaults",     host_supported: true,   // <<---------编译PC主机的对应版本,linux_glibc_x86_64_static     ... }  cc_library_static {     name: "libc++_static",     defaults: ["libc++ defaults"],     vendor_available: true,  // <<---------libc++的静态库vendor可用     ... }  cc_library_shared {     name: "libc++",     host_supported: true,     vendor_available: true,  // <<---------libc++的动态库vendor可用     ... }  cc_library_static {     name: "libc++fs",                              // <<---------无vendor_available选项,vendor不可用     recovery_available: true,     defaults: ["libc++ defaults"],  // <<---------继承defaults选项,会编译pc host对应的版本,linux_glibc_x86_64_static     ... } 
  1. 练习题
    以下这个错误是什么原因?试着分析一下
FAILED: out/soong/build.ninja out/soong/.bootstrap/bin/soong_build -t -l out/.module_paths/Android.bp.list -b out/soong - n out -d out/soong/build.ninja.d -globFile out/soong/.bootstrap/build-globs.ninja -o out/so ong/build.ninja Android.bp Clang SA is not enabled error: external/test_prog/Android.bp:1:1: dependency "vhal_v2_0_common_headers" of "test_prog" missing variant:   os:android, image:, arch:arm64_armv8-a, sdk:, version: available variants:   os:android, image:vendor.30, arch:arm64_armv8-a, sdk:, version:   os:android, image:vendor.30, arch:arm_armv7-a-neon_cortex-a9, sdk:, version: error: external/test_prog/Android.bp:1:1: dependency "android.hardware.automotive.vehicle@2. 0-manager-lib" of "test_prog" missing variant:   os:android, image:, arch:arm64_armv8-a, sdk:, link:shared, version: available variants:   os:android, image:vendor.30, arch:arm64_armv8-a, sdk:, link:shared, version:   os:android, image:vendor.30, arch:arm64_armv8-a, sdk:, link:static, version:   os:android, image:vendor.30, arch:arm_armv7-a-neon_cortex-a9, sdk:, link:shared, version:   os:android, image:vendor.30, arch:arm_armv7-a-neon_cortex-a9, sdk:, link:static, version: 17:47:58 soong bootstrap failed with: exit status 1  

广告一刻

为您即时展示最新活动产品广告消息,让您随时掌握产品活动新动态!