通过更改 .bp 文件仅在 AOSP 的某些构建中包含应用程序

问题描述 投票:0回答:1

有没有办法在 AOSP 中更改应用程序的 .bp 文件,以便仅包含在特定构建中。

例如,我只想在 userdebug 应用程序中包含测试应用程序?

android-source android-soong
1个回答
0
投票

正确的做法不是更改 Android.bp 文件,而是更改 device//.mk 文件以仅在 userdebug 构建中包含测试应用程序,如下所示:

PRODUCT_PACKAGES += main_app_1

ifneq (,$(filter userdebug eng, $(TARGET_BUILD_VARIANT)))
PRODUCT_PACKAGES += test_main_app_1
endif

在Android.bp中,你应该分别构建主应用和测试应用,像这样:

cc_binary {
    name: "main_app_1",
    cflags: [
        "-std=c++17",
        "-ffunction-sections",
        "-fPIC",
        "-Werror",
        "-Wall",
        "-Wextra",
        "-O2",
    ],
    srcs: [
        "src/**/*.cc",
    ],
    shared_libs: [
        "liblog",
        "libcutils",
        "libandroid_runtime",
        "libutils",
    ],
}

cc_binary {
    name: "test_main_app_1",
    cflags: [
        "-std=c++17",
        "-ffunction-sections",
        "-fPIC",
        "-Werror",
        "-Wall",
        "-Wextra",
        "-O2",
    ],
    srcs: [
        "test/**/*.cc",
    ],
    local_include_dirs: ["test/"],
    shared_libs: [
        "liblog",
        "libcutils",
        "libandroid_runtime",
        "libutils",
    ],
}
© www.soinside.com 2019 - 2024. All rights reserved.