Add exported_systemserverclasspath_fragments to prebuilt_apex rule.
This is for exporting the contents of systemserverclasspath_fragment for
dexpreopting.
Bug: 194150908
Test: manual - 1. Patch aosp/1818020 and aosp/1834534
2. m SOONG_CONFIG_art_module_source_build=false com.android.art
Change-Id: I7d2d2e02869d8a523f7c0efbbff81706672a95c5
diff --git a/apex/prebuilt.go b/apex/prebuilt.go
index d59f8bf..55a9e42 100644
--- a/apex/prebuilt.go
+++ b/apex/prebuilt.go
@@ -103,6 +103,10 @@
// List of bootclasspath fragments inside this prebuilt APEX bundle and for which this APEX
// bundle will create an APEX variant.
Exported_bootclasspath_fragments []string
+
+ // List of systemserverclasspath fragments inside this prebuilt APEX bundle and for which this
+ // APEX bundle will create an APEX variant.
+ Exported_systemserverclasspath_fragments []string
}
// initPrebuiltCommon initializes the prebuiltCommon structure and performs initialization of the
@@ -174,7 +178,8 @@
tag := ctx.OtherModuleDependencyTag(child)
name := android.RemoveOptionalPrebuiltPrefix(ctx.OtherModuleName(child))
- if java.IsBootclasspathFragmentContentDepTag(tag) || tag == exportedJavaLibTag {
+ if java.IsBootclasspathFragmentContentDepTag(tag) ||
+ java.IsSystemServerClasspathFragmentContentDepTag(tag) || tag == exportedJavaLibTag {
// If the exported java module provides a dex jar path then add it to the list of apexFiles.
path := child.(interface {
DexJarBuildPath() java.OptionalDexJarPath
@@ -194,8 +199,9 @@
}
p.apexFilesForAndroidMk = append(p.apexFilesForAndroidMk, af)
}
- } else if tag == exportedBootclasspathFragmentTag {
- // Visit the children of the bootclasspath_fragment.
+ } else if tag == exportedBootclasspathFragmentTag ||
+ tag == exportedSystemserverclasspathFragmentTag {
+ // Visit the children of the bootclasspath_fragment and systemserver_fragment.
return true
}
@@ -311,21 +317,31 @@
}
}
+func (p *prebuiltCommon) getExportedDependencies() map[string]exportedDependencyTag {
+ dependencies := make(map[string]exportedDependencyTag)
+
+ for _, dep := range p.prebuiltCommonProperties.Exported_java_libs {
+ dependencies[dep] = exportedJavaLibTag
+ }
+
+ for _, dep := range p.prebuiltCommonProperties.Exported_bootclasspath_fragments {
+ dependencies[dep] = exportedBootclasspathFragmentTag
+ }
+
+ for _, dep := range p.prebuiltCommonProperties.Exported_systemserverclasspath_fragments {
+ dependencies[dep] = exportedSystemserverclasspathFragmentTag
+ }
+
+ return dependencies
+}
+
// prebuiltApexContentsDeps adds dependencies onto the prebuilt apex module's contents.
func (p *prebuiltCommon) prebuiltApexContentsDeps(ctx android.BottomUpMutatorContext) {
module := ctx.Module()
- // Add dependencies onto the java modules that represent the java libraries that are provided by
- // and exported from this prebuilt apex.
- for _, exported := range p.prebuiltCommonProperties.Exported_java_libs {
- dep := android.PrebuiltNameFromSource(exported)
- ctx.AddDependency(module, exportedJavaLibTag, dep)
- }
- // Add dependencies onto the bootclasspath fragment modules that are exported from this prebuilt
- // apex.
- for _, exported := range p.prebuiltCommonProperties.Exported_bootclasspath_fragments {
- dep := android.PrebuiltNameFromSource(exported)
- ctx.AddDependency(module, exportedBootclasspathFragmentTag, dep)
+ for dep, tag := range p.getExportedDependencies() {
+ prebuiltDep := android.PrebuiltNameFromSource(dep)
+ ctx.AddDependency(module, tag, prebuiltDep)
}
}
@@ -576,9 +592,9 @@
// A deapexer module is only needed when the prebuilt apex specifies one or more modules in either
// the `exported_java_libs` or `exported_bootclasspath_fragments` properties as that indicates that
// the listed modules need access to files from within the prebuilt .apex file.
-func createDeapexerModuleIfNeeded(ctx android.TopDownMutatorContext, deapexerName string, apexFileSource string, properties *PrebuiltCommonProperties) {
+func (p *prebuiltCommon) createDeapexerModuleIfNeeded(ctx android.TopDownMutatorContext, deapexerName string, apexFileSource string) {
// Only create the deapexer module if it is needed.
- if len(properties.Exported_java_libs)+len(properties.Exported_bootclasspath_fragments) == 0 {
+ if len(p.getExportedDependencies()) == 0 {
return
}
@@ -674,8 +690,9 @@
var _ android.RequiresFilesFromPrebuiltApexTag = exportedDependencyTag{}
var (
- exportedJavaLibTag = exportedDependencyTag{name: "exported_java_libs"}
- exportedBootclasspathFragmentTag = exportedDependencyTag{name: "exported_bootclasspath_fragments"}
+ exportedJavaLibTag = exportedDependencyTag{name: "exported_java_libs"}
+ exportedBootclasspathFragmentTag = exportedDependencyTag{name: "exported_bootclasspath_fragments"}
+ exportedSystemserverclasspathFragmentTag = exportedDependencyTag{name: "exported_systemserverclasspath_fragments"}
)
var _ prebuiltApexModuleCreator = (*Prebuilt)(nil)
@@ -716,7 +733,7 @@
createApexSelectorModule(ctx, apexSelectorModuleName, &p.properties.ApexFileProperties)
apexFileSource := ":" + apexSelectorModuleName
- createDeapexerModuleIfNeeded(ctx, deapexerModuleName(baseModuleName), apexFileSource, p.prebuiltCommonProperties)
+ p.createDeapexerModuleIfNeeded(ctx, deapexerModuleName(baseModuleName), apexFileSource)
// Add a source reference to retrieve the selected apex from the selector module.
p.prebuiltCommonProperties.Selected_apex = proptools.StringPtr(apexFileSource)
@@ -919,7 +936,7 @@
createApexExtractorModule(ctx, apexExtractorModuleName, &a.properties.ApexExtractorProperties)
apexFileSource := ":" + apexExtractorModuleName
- createDeapexerModuleIfNeeded(ctx, deapexerModuleName(baseModuleName), apexFileSource, a.prebuiltCommonProperties)
+ a.createDeapexerModuleIfNeeded(ctx, deapexerModuleName(baseModuleName), apexFileSource)
// After passing the arch specific src properties to the creating the apex selector module
a.prebuiltCommonProperties.Selected_apex = proptools.StringPtr(apexFileSource)
diff --git a/apex/systemserver_classpath_fragment_test.go b/apex/systemserver_classpath_fragment_test.go
index 822d277..dc682fa 100644
--- a/apex/systemserver_classpath_fragment_test.go
+++ b/apex/systemserver_classpath_fragment_test.go
@@ -188,6 +188,19 @@
prepareForTestWithMyapex,
dexpreopt.FixtureSetApexSystemServerJars("myapex:foo"),
).RunTestWithBp(t, `
+ prebuilt_apex {
+ name: "myapex",
+ arch: {
+ arm64: {
+ src: "myapex-arm64.apex",
+ },
+ arm: {
+ src: "myapex-arm.apex",
+ },
+ },
+ exported_systemserverclasspath_fragments: ["mysystemserverclasspathfragment"],
+ }
+
java_import {
name: "foo",
jars: ["foo.jar"],
@@ -208,7 +221,13 @@
}
`)
- java.CheckModuleDependencies(t, result.TestContext, "mysystemserverclasspathfragment", "android_common", []string{
+ java.CheckModuleDependencies(t, result.TestContext, "myapex", "android_common_myapex", []string{
+ `myapex.apex.selector`,
+ `prebuilt_mysystemserverclasspathfragment`,
+ })
+
+ java.CheckModuleDependencies(t, result.TestContext, "mysystemserverclasspathfragment", "android_common_myapex", []string{
+ `myapex.deapexer`,
`prebuilt_foo`,
})
}