Merge "Simplify deapexer support" am: 0d7f2d30b5

Original change: https://android-review.googlesource.com/c/platform/build/soong/+/1740316

Change-Id: I69b8e53916f848e9cb15f58756efba0b76c2bedd
This commit is contained in:
Paul Duffin
2021-06-20 18:29:09 +00:00
committed by Automerger Merge Worker
6 changed files with 48 additions and 74 deletions

View File

@@ -930,13 +930,12 @@ func (module *prebuiltBootclasspathFragmentModule) produceBootImageFiles(ctx and
}
di := ctx.OtherModuleProvider(deapexerModule, android.DeapexerProvider).(android.DeapexerInfo)
name := module.BaseModuleName()
for _, variant := range imageConfig.apexVariants() {
arch := variant.target.Arch.ArchType
for _, toPath := range variant.imagesDeps {
apexRelativePath := apexRootRelativePathToBootImageFile(arch, toPath.Base())
// Get the path to the file that the deapexer extracted from the prebuilt apex file.
tag := createBootImageTag(arch, toPath.Base())
fromPath := di.PrebuiltExportPath(name, tag)
fromPath := di.PrebuiltExportPath(apexRelativePath)
// Copy the file to the predefined location.
ctx.Build(pctx, android.BuildParams{
@@ -967,19 +966,16 @@ func createBootImageTag(arch android.ArchType, baseName string) string {
//
// If there is no image config associated with this fragment then it returns nil. Otherwise, it
// returns the files that are listed in the image config.
func (module *prebuiltBootclasspathFragmentModule) RequiredFilesFromPrebuiltApex(ctx android.BaseModuleContext) map[string]string {
func (module *prebuiltBootclasspathFragmentModule) RequiredFilesFromPrebuiltApex(ctx android.BaseModuleContext) []string {
imageConfig := module.getImageConfig(ctx)
if imageConfig != nil {
// Add the boot image files, e.g. .art, .oat and .vdex files.
files := map[string]string{}
name := module.BaseModuleName()
files := []string{}
for _, variant := range imageConfig.apexVariants() {
arch := variant.target.Arch.ArchType
for _, path := range variant.imagesDeps.Paths() {
base := path.Base()
tag := createBootImageTag(arch, base)
key := fmt.Sprintf("%s{%s}", name, tag)
files[key] = filepath.Join("javalib", arch.String(), base)
files = append(files, apexRootRelativePathToBootImageFile(arch, base))
}
}
return files
@@ -987,6 +983,10 @@ func (module *prebuiltBootclasspathFragmentModule) RequiredFilesFromPrebuiltApex
return nil
}
func apexRootRelativePathToBootImageFile(arch android.ArchType, base string) string {
return filepath.Join("javalib", arch.String(), base)
}
var _ android.RequiredFilesFromPrebuiltApex = (*prebuiltBootclasspathFragmentModule)(nil)
func prebuiltBootclasspathFragmentFactory() android.Module {

View File

@@ -1309,7 +1309,7 @@ func (j *Import) GenerateAndroidBuildActions(ctx android.ModuleContext) {
// Get the path of the dex implementation jar from the `deapexer` module.
di := ctx.OtherModuleProvider(deapexerModule, android.DeapexerProvider).(android.DeapexerInfo)
if dexOutputPath := di.PrebuiltExportPath(j.BaseModuleName(), ".dexjar"); dexOutputPath != nil {
if dexOutputPath := di.PrebuiltExportPath(apexRootRelativePathToJavaLib(j.BaseModuleName())); dexOutputPath != nil {
j.dexJarFile = dexOutputPath
// Initialize the hiddenapi structure.
@@ -1429,17 +1429,22 @@ func (j *Import) ShouldSupportSdkVersion(ctx android.BaseModuleContext,
// requiredFilesFromPrebuiltApexForImport returns information about the files that a java_import or
// java_sdk_library_import with the specified base module name requires to be exported from a
// prebuilt_apex/apex_set.
func requiredFilesFromPrebuiltApexForImport(name string) map[string]string {
// Add the dex implementation jar to the set of exported files. The path here must match the
// path of the file in the APEX created by apexFileForJavaModule(...).
return map[string]string{
name + "{.dexjar}": filepath.Join("javalib", name+".jar"),
func requiredFilesFromPrebuiltApexForImport(name string) []string {
// Add the dex implementation jar to the set of exported files.
return []string{
apexRootRelativePathToJavaLib(name),
}
}
// apexRootRelativePathToJavaLib returns the path, relative to the root of the apex's contents, for
// the java library with the specified name.
func apexRootRelativePathToJavaLib(name string) string {
return filepath.Join("javalib", name+".jar")
}
var _ android.RequiredFilesFromPrebuiltApex = (*Import)(nil)
func (j *Import) RequiredFilesFromPrebuiltApex(ctx android.BaseModuleContext) map[string]string {
func (j *Import) RequiredFilesFromPrebuiltApex(_ android.BaseModuleContext) []string {
name := j.BaseModuleName()
return requiredFilesFromPrebuiltApexForImport(name)
}

View File

@@ -2144,7 +2144,7 @@ func (module *SdkLibraryImport) GenerateAndroidBuildActions(ctx android.ModuleCo
// Get the path of the dex implementation jar from the `deapexer` module.
di := ctx.OtherModuleProvider(deapexerModule, android.DeapexerProvider).(android.DeapexerInfo)
if dexOutputPath := di.PrebuiltExportPath(module.BaseModuleName(), ".dexjar"); dexOutputPath != nil {
if dexOutputPath := di.PrebuiltExportPath(apexRootRelativePathToJavaLib(module.BaseModuleName())); dexOutputPath != nil {
module.dexJarFile = dexOutputPath
module.initHiddenAPI(ctx, dexOutputPath, module.findScopePaths(apiScopePublic).stubsImplPath[0], nil)
} else {
@@ -2271,7 +2271,7 @@ func (module *SdkLibraryImport) ImplementationAndResourcesJars() android.Paths {
var _ android.RequiredFilesFromPrebuiltApex = (*SdkLibraryImport)(nil)
func (module *SdkLibraryImport) RequiredFilesFromPrebuiltApex(ctx android.BaseModuleContext) map[string]string {
func (module *SdkLibraryImport) RequiredFilesFromPrebuiltApex(ctx android.BaseModuleContext) []string {
name := module.BaseModuleName()
return requiredFilesFromPrebuiltApexForImport(name)
}