diff options
author | 2024-01-19 00:22:22 +0000 | |
---|---|---|
committer | 2024-02-06 21:56:05 +0000 | |
commit | 161e468774beca6dbcedec7fbc1ac3eee6858a91 (patch) | |
tree | 4eb1d110df4531cd9ef7f57a06628256623ce104 /java/dexpreopt_bootjars.go | |
parent | cc53063b07d621bad238f8a88ffe4f15e4672cab (diff) |
Use source_module_name to determine the contents of prebuilt apexes
There are a couple of instances in apex/ and java/ that rely on the naming
convention that the jars exported by prebuilt apexes follow the name of
the java_sdk_library_import, minus the prebuilt_ prefix. With muliple
module sdk prebuilts in trunk stable, this naming convention might not
be valid. Use `source_module_name` instead.
```
prebuilt_sscp_fragment {name: "", contents: ["service-foo.v2"]}
java_import {name: "service-foo.v2", source_module_name: "service-foo"},
```
We should use service-foo and not service-foo.v2 because
1. The prebuilt apex contains service-foo.dex
2. PRODUCT_*JARS will contain service-foo and not service-foo.v2
For clarity, this CL does not drop the current mechanism where prebuilt bcp
fragments create a dependency edge to prebuilt java or java_sdk_library
imports. There is still some discussion around whether we can remove
that completely (b/320711431). If we were to do that, then the
Android.bp files will become
```
prebuilt_sscp_fragment {name: "", contents: ["service-foo"]}
```
Bug: 322175508
Test: Added a unit test
Test: In internal, lunch cf_x86_64_only_phone-next-userdebug && m
nothing # .ninja files identical
Test: In internal, created a parallel set of v2 prebuilts of
java_sdk_library_import and prebuilt_bcp_fragments for adservices && m
nothing # build passes
Change-Id: Ia899d75e826fa1a559368d706eaa65835f748d40
Diffstat (limited to 'java/dexpreopt_bootjars.go')
-rw-r--r-- | java/dexpreopt_bootjars.go | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/java/dexpreopt_bootjars.go b/java/dexpreopt_bootjars.go index 01f60d403..f7e3cb93a 100644 --- a/java/dexpreopt_bootjars.go +++ b/java/dexpreopt_bootjars.go @@ -726,13 +726,19 @@ func (m *apexNameToApexExportsInfoMap) javaLibraryDexPathOnHost(ctx android.Modu return nil, false } +// Returns the stem of an artifact inside a prebuilt apex +func ModuleStemForDeapexing(m android.Module) string { + bmn, _ := m.(interface{ BaseModuleName() string }) + return bmn.BaseModuleName() +} + // Returns the java libraries exported by the apex for hiddenapi and dexpreopt // This information can come from two mechanisms // 1. New: Direct deps to _selected_ apexes. The apexes return a ApexExportsInfo // 2. Legacy: An edge to java_library or java_import (java_sdk_library) module. For prebuilt apexes, this serves as a hook and is populated by deapexers of prebuilt apxes // TODO: b/308174306 - Once all mainline modules have been flagged, drop (2) func getDexJarForApex(ctx android.ModuleContext, pair apexJarModulePair, apexNameToApexExportsInfoMap apexNameToApexExportsInfoMap) android.Path { - if dex, found := apexNameToApexExportsInfoMap.javaLibraryDexPathOnHost(ctx, pair.apex, android.RemoveOptionalPrebuiltPrefix(pair.jarModule.Name())); found { + if dex, found := apexNameToApexExportsInfoMap.javaLibraryDexPathOnHost(ctx, pair.apex, ModuleStemForDeapexing(pair.jarModule)); found { return dex } // TODO: b/308174306 - Remove the legacy mechanism |