Merge "Derive deapexer module properties from transitive dependencies" am: eeec6bd460
am: 955ddedc44
am: 0bdaee7798
Original change: https://android-review.googlesource.com/c/platform/build/soong/+/1697058 Change-Id: I866f0a2df8493077a9f81e16fcaafb0644586df9
This commit is contained in:
commit
e8e6b89dd6
|
@ -113,19 +113,21 @@ func prebuiltApexModuleCreatorMutator(ctx android.TopDownMutatorContext) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *prebuiltCommon) deapexerDeps(ctx android.BottomUpMutatorContext) {
|
// 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
|
// Add dependencies onto the java modules that represent the java libraries that are provided by
|
||||||
// and exported from this prebuilt apex.
|
// and exported from this prebuilt apex.
|
||||||
for _, exported := range p.deapexerProperties.Exported_java_libs {
|
for _, exported := range p.deapexerProperties.Exported_java_libs {
|
||||||
dep := prebuiltApexExportedModuleName(ctx, exported)
|
dep := android.PrebuiltNameFromSource(exported)
|
||||||
ctx.AddFarVariationDependencies(ctx.Config().AndroidCommonTarget.Variations(), exportedJavaLibTag, dep)
|
ctx.AddDependency(module, exportedJavaLibTag, dep)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add dependencies onto the bootclasspath fragment modules that are exported from this prebuilt
|
// Add dependencies onto the bootclasspath fragment modules that are exported from this prebuilt
|
||||||
// apex.
|
// apex.
|
||||||
for _, exported := range p.deapexerProperties.Exported_bootclasspath_fragments {
|
for _, exported := range p.deapexerProperties.Exported_bootclasspath_fragments {
|
||||||
dep := prebuiltApexExportedModuleName(ctx, exported)
|
dep := android.PrebuiltNameFromSource(exported)
|
||||||
ctx.AddFarVariationDependencies(ctx.Config().AndroidCommonTarget.Variations(), exportedBootclasspathFragmentTag, dep)
|
ctx.AddDependency(module, exportedBootclasspathFragmentTag, dep)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -397,15 +399,36 @@ func createApexSelectorModule(ctx android.TopDownMutatorContext, name string, ap
|
||||||
|
|
||||||
// createDeapexerModuleIfNeeded will create a deapexer module if it is needed.
|
// createDeapexerModuleIfNeeded will create a deapexer module if it is needed.
|
||||||
//
|
//
|
||||||
// A deapexer module is only needed when the prebuilt apex specifies an `exported_java_libs`
|
// A deapexer module is only needed when the prebuilt apex specifies one or more modules in either
|
||||||
// property as that indicates that the listed modules need access to files from within the prebuilt
|
// the `exported_java_libs` or `exported_bootclasspath_fragments` properties as that indicates that
|
||||||
// .apex file.
|
// the listed modules need access to files from within the prebuilt .apex file.
|
||||||
func createDeapexerModuleIfNeeded(ctx android.TopDownMutatorContext, deapexerName string, apexFileSource string, deapexerProperties *DeapexerProperties) {
|
func createDeapexerModuleIfNeeded(ctx android.TopDownMutatorContext, deapexerName string, apexFileSource string, deapexerProperties *DeapexerProperties) {
|
||||||
// Only create the deapexer module if it is needed.
|
// Only create the deapexer module if it is needed.
|
||||||
if len(deapexerProperties.Exported_java_libs) == 0 {
|
if len(deapexerProperties.Exported_java_libs)+len(deapexerProperties.Exported_bootclasspath_fragments) == 0 {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Compute the deapexer properties from the transitive dependencies of this module.
|
||||||
|
deapexerProperties = &DeapexerProperties{}
|
||||||
|
ctx.WalkDeps(func(child, parent android.Module) bool {
|
||||||
|
tag := ctx.OtherModuleDependencyTag(child)
|
||||||
|
|
||||||
|
name := android.RemoveOptionalPrebuiltPrefix(ctx.OtherModuleName(child))
|
||||||
|
if java.IsBootclasspathFragmentContentDepTag(tag) || tag == exportedJavaLibTag {
|
||||||
|
deapexerProperties.Exported_java_libs = append(deapexerProperties.Exported_java_libs, name)
|
||||||
|
} else if tag == exportedBootclasspathFragmentTag {
|
||||||
|
deapexerProperties.Exported_bootclasspath_fragments = append(deapexerProperties.Exported_bootclasspath_fragments, name)
|
||||||
|
// Only visit the children of the bootclasspath_fragment for now.
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
return false
|
||||||
|
})
|
||||||
|
|
||||||
|
// Remove any duplicates from the deapexer lists.
|
||||||
|
deapexerProperties.Exported_bootclasspath_fragments = android.FirstUniqueStrings(deapexerProperties.Exported_bootclasspath_fragments)
|
||||||
|
deapexerProperties.Exported_java_libs = android.FirstUniqueStrings(deapexerProperties.Exported_java_libs)
|
||||||
|
|
||||||
props := struct {
|
props := struct {
|
||||||
Name *string
|
Name *string
|
||||||
Selected_apex *string
|
Selected_apex *string
|
||||||
|
@ -510,8 +533,8 @@ func (p *Prebuilt) createPrebuiltApexModules(ctx android.TopDownMutatorContext)
|
||||||
p.selectedApexProperties.Selected_apex = proptools.StringPtr(apexFileSource)
|
p.selectedApexProperties.Selected_apex = proptools.StringPtr(apexFileSource)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *Prebuilt) DepsMutator(ctx android.BottomUpMutatorContext) {
|
func (p *Prebuilt) ComponentDepsMutator(ctx android.BottomUpMutatorContext) {
|
||||||
p.deapexerDeps(ctx)
|
p.prebuiltApexContentsDeps(ctx)
|
||||||
}
|
}
|
||||||
|
|
||||||
var _ ApexInfoMutator = (*Prebuilt)(nil)
|
var _ ApexInfoMutator = (*Prebuilt)(nil)
|
||||||
|
@ -768,8 +791,8 @@ func (a *ApexSet) createPrebuiltApexModules(ctx android.TopDownMutatorContext) {
|
||||||
a.selectedApexProperties.Selected_apex = proptools.StringPtr(apexFileSource)
|
a.selectedApexProperties.Selected_apex = proptools.StringPtr(apexFileSource)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a *ApexSet) DepsMutator(ctx android.BottomUpMutatorContext) {
|
func (a *ApexSet) ComponentDepsMutator(ctx android.BottomUpMutatorContext) {
|
||||||
a.deapexerDeps(ctx)
|
a.prebuiltApexContentsDeps(ctx)
|
||||||
}
|
}
|
||||||
|
|
||||||
var _ ApexInfoMutator = (*ApexSet)(nil)
|
var _ ApexInfoMutator = (*ApexSet)(nil)
|
||||||
|
|
|
@ -95,9 +95,6 @@ func TestSnapshotWithBootclasspathFragment_ImageName(t *testing.T) {
|
||||||
prebuilt_apex {
|
prebuilt_apex {
|
||||||
name: "com.android.art",
|
name: "com.android.art",
|
||||||
src: "art.apex",
|
src: "art.apex",
|
||||||
exported_java_libs: [
|
|
||||||
"mybootlib",
|
|
||||||
],
|
|
||||||
exported_bootclasspath_fragments: [
|
exported_bootclasspath_fragments: [
|
||||||
"mybootclasspathfragment",
|
"mybootclasspathfragment",
|
||||||
],
|
],
|
||||||
|
|
Loading…
Reference in New Issue