diff options
author | Cole Faust <colefaust@google.com> | 2024-05-15 11:17:55 -0700 |
---|---|---|
committer | Cole Faust <colefaust@google.com> | 2024-05-15 11:17:55 -0700 |
commit | 7c991b4e339015cb55d7f6a8eb6683d85c881666 (patch) | |
tree | f100d461fffa2546d9b40ddc15db1df5b0947683 | |
parent | 3ef813bdf2982e2dbc6226507544925632601cc9 (diff) | |
download | soong-7c991b4e339015cb55d7f6a8eb6683d85c881666.tar.gz |
Qualify prebuilt_etc apex module name by relative paths
Currently, you can't have two prebuilt_etcs in one apex with the same
file name, because apexes emit make modules for all the files in the
apex, and the module name for the prebuilt_etc's make representation
is based on the base filename of the installed file. We can change it to
be qualified based on the full relative path of the outputfile so that
you don't hit the conflicts as much.
Fixes: 340207931
Test: Presubmits
Change-Id: I7836fd4661fcaafd91901eba7e0b89506946c3e2
-rw-r--r-- | apex/apex.go | 3 | ||||
-rw-r--r-- | apex/apex_test.go | 39 |
2 files changed, 41 insertions, 1 deletions
diff --git a/apex/apex.go b/apex/apex.go index 9a80ec633..802991009 100644 --- a/apex/apex.go +++ b/apex/apex.go @@ -1636,7 +1636,8 @@ func apexFileForShBinary(ctx android.BaseModuleContext, sh *sh.ShBinary) apexFil func apexFileForPrebuiltEtc(ctx android.BaseModuleContext, prebuilt prebuilt_etc.PrebuiltEtcModule, outputFile android.Path) apexFile { dirInApex := filepath.Join(prebuilt.BaseDir(), prebuilt.SubDir()) - return newApexFile(ctx, outputFile, outputFile.Base(), dirInApex, etc, prebuilt) + makeModuleName := strings.ReplaceAll(filepath.Join(dirInApex, outputFile.Base()), "/", "_") + return newApexFile(ctx, outputFile, makeModuleName, dirInApex, etc, prebuilt) } func apexFileForCompatConfig(ctx android.BaseModuleContext, config java.PlatformCompatConfigIntf, depName string) apexFile { diff --git a/apex/apex_test.go b/apex/apex_test.go index 9a5c2b49b..74b2eec5b 100644 --- a/apex/apex_test.go +++ b/apex/apex_test.go @@ -11531,3 +11531,42 @@ func TestAconfifDeclarationsValidation(t *testing.T) { "depend on java_aconfig_library not passed as an input", aconfigFlagArgs, fmt.Sprintf("%s/%s/intermediate.pb", outDir, "quux")) } + +func TestMultiplePrebuiltsWithSameBase(t *testing.T) { + ctx := testApex(t, ` + apex { + name: "myapex", + key: "myapex.key", + prebuilts: ["myetc", "myetc2"], + min_sdk_version: "29", + } + apex_key { + name: "myapex.key", + public_key: "testkey.avbpubkey", + private_key: "testkey.pem", + } + + prebuilt_etc { + name: "myetc", + src: "myprebuilt", + filename: "myfilename", + } + prebuilt_etc { + name: "myetc2", + sub_dir: "mysubdir", + src: "myprebuilt", + filename: "myfilename", + } + `, withFiles(android.MockFS{ + "packages/modules/common/build/allowed_deps.txt": nil, + })) + + ab := ctx.ModuleForTests("myapex", "android_common_myapex").Module().(*apexBundle) + data := android.AndroidMkDataForTest(t, ctx, ab) + var builder strings.Builder + data.Custom(&builder, ab.BaseModuleName(), "TARGET_", "", data) + androidMk := builder.String() + + android.AssertStringDoesContain(t, "not found", androidMk, "LOCAL_MODULE := etc_myfilename.myapex") + android.AssertStringDoesContain(t, "not found", androidMk, "LOCAL_MODULE := etc_mysubdir_myfilename.myapex") +} |