From e812805e756d37108d16cfe7da784169369c7e86 Mon Sep 17 00:00:00 2001 From: Yo Chiang Date: Thu, 23 Jul 2020 20:09:18 +0800 Subject: Use BaseModuleName() + SubName as apexFile.moduleName This change fixes this error: ``` TARGET module com.android.adbd.flattened requires non-existent TARGET module: prebuilt_libclang_rt.ubsan_standalone-arm-android ``` apexFile.moduleName is used as Make dependency name, so it should use m.BaseModuleName() instead of m.Name(), because soong may prepend "prebuilt_" to or mutate the output of m.Name() in other ways. android/androidmk.go emits Android.mk modules with `LOCAL_MODULE := module.BaseModuleName() + `, so replace apexFile.moduleName with BaseModuleName() + as much as possible. Bug: 7456955 Test: Add unit test in apex/apex_test.go Test: lunch blueline_hwasan && SANITIZE_TARGET='hwaddress fuzzer' m nothing Test: Verify out/soong/Android-blueline_hwasan.mk Change-Id: If8537fc1bedbe6c3405de3662a5df210a073c43f --- apex/apex_test.go | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) (limited to 'apex/apex_test.go') diff --git a/apex/apex_test.go b/apex/apex_test.go index f06433848..360061410 100644 --- a/apex/apex_test.go +++ b/apex/apex_test.go @@ -5179,6 +5179,57 @@ func TestSymlinksFromApexToSystem(t *testing.T) { ensureRealfileExists(t, files, "lib64/myotherlib.so") // this is a real file } +func TestSymlinksFromApexToSystemRequiredModuleNames(t *testing.T) { + ctx, config := testApex(t, ` + apex { + name: "myapex", + key: "myapex.key", + native_shared_libs: ["mylib"], + } + + apex_key { + name: "myapex.key", + public_key: "testkey.avbpubkey", + private_key: "testkey.pem", + } + + cc_library_shared { + name: "mylib", + srcs: ["mylib.cpp"], + shared_libs: ["myotherlib"], + system_shared_libs: [], + stl: "none", + apex_available: [ + "myapex", + "//apex_available:platform", + ], + } + + cc_prebuilt_library_shared { + name: "myotherlib", + srcs: ["prebuilt.so"], + system_shared_libs: [], + stl: "none", + apex_available: [ + "myapex", + "//apex_available:platform", + ], + } + `) + + apexBundle := ctx.ModuleForTests("myapex", "android_common_myapex_image").Module().(*apexBundle) + data := android.AndroidMkDataForTest(t, config, "", apexBundle) + var builder strings.Builder + data.Custom(&builder, apexBundle.BaseModuleName(), "TARGET_", "", data) + androidMk := builder.String() + // `myotherlib` is added to `myapex` as symlink + ensureContains(t, androidMk, "LOCAL_MODULE := mylib.myapex\n") + ensureNotContains(t, androidMk, "LOCAL_MODULE := prebuilt_myotherlib.myapex\n") + ensureNotContains(t, androidMk, "LOCAL_MODULE := myotherlib.myapex\n") + // `myapex` should have `myotherlib` in its required line, not `prebuilt_myotherlib` + ensureContains(t, androidMk, "LOCAL_REQUIRED_MODULES += mylib.myapex myotherlib apex_manifest.pb.myapex apex_pubkey.myapex\n") +} + func TestApexWithJniLibs(t *testing.T) { ctx, _ := testApex(t, ` apex { -- cgit v1.2.3-59-g8ed1b