From 5be6333692b6881b223b672c2251efaf4605bb33 Mon Sep 17 00:00:00 2001 From: Spandan Das Date: Wed, 13 Dec 2023 00:06:32 +0000 Subject: Use the correct bootjars when multiple prebuilt apexes exist hiddenapi and dexpreopt require boot and system server jars from apexes. When building with prebuilts, this comes via java_import/java_sdk_library_import, which acts as a hook for prebuilt_apex/apex_set. If we have multiple apexes in the tree, this hook becomes 1:many. This CL prepares dex_bootjars to select the right deapexerd .jar files when mutliple prebuilts exist. Implementation details - Update prebuilt module types (prebuilt_apex/apex_set) and source apexes to set a map of library name to dex jar path on host. - dex_bootjars will access the path of the .dex jar on host via the provider. These then copied/installed to the right locations. This CL does not drop the old mechanism to get the dex file (i.e. by creating a dep on java_library). Once all mainline modules have been flagged using apex_contributions, the old mechanism will be dropped Bug: 308790457 Test: git_master-art-host:art-gtest https://android-build.corp.google.com/builds/abtd/run/L21500030000926533 Test: git_main:art_standalone_dexpreopt_tests https://android-build.corp.google.com/builds/abtd/run/L99000030000891212 Test: Added a unit test that checks that the right .jar is selected when multiple prebuilts exists Change-Id: I6ef94135b9303a35135810930af4b641df13a583 --- apex/prebuilt.go | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'apex/prebuilt.go') diff --git a/apex/prebuilt.go b/apex/prebuilt.go index 37a9ff5a1..1f57b63e8 100644 --- a/apex/prebuilt.go +++ b/apex/prebuilt.go @@ -778,9 +778,17 @@ func (p *prebuiltCommon) provideApexExportsInfo(ctx android.ModuleContext) { return } if di, err := android.FindDeapexerProviderForModule(ctx); err == nil { + javaModuleToDexPath := map[string]android.Path{} + for _, commonModule := range di.GetExportedModuleNames() { + if dex := di.PrebuiltExportPath(java.ApexRootRelativePathToJavaLib(commonModule)); dex != nil { + javaModuleToDexPath[commonModule] = dex + } + } + exports := android.ApexExportsInfo{ - ApexName: p.ApexVariationName(), - ProfilePathOnHost: di.PrebuiltExportPath(java.ProfileInstallPathInApex), + ApexName: p.ApexVariationName(), + ProfilePathOnHost: di.PrebuiltExportPath(java.ProfileInstallPathInApex), + LibraryNameToDexJarPathOnHost: javaModuleToDexPath, } ctx.SetProvider(android.ApexExportsInfoProvider, exports) } else { -- cgit v1.2.3-59-g8ed1b