Merge "Simplify prebuilt_apex/apex_set common properties"
This commit is contained in:
@@ -47,10 +47,9 @@ type prebuilt interface {
|
|||||||
|
|
||||||
type prebuiltCommon struct {
|
type prebuiltCommon struct {
|
||||||
prebuilt android.Prebuilt
|
prebuilt android.Prebuilt
|
||||||
properties prebuiltCommonProperties
|
|
||||||
|
|
||||||
deapexerProperties DeapexerProperties
|
// Properties common to both prebuilt_apex and apex_set.
|
||||||
selectedApexProperties SelectedApexProperties
|
prebuiltCommonProperties prebuiltCommonProperties
|
||||||
}
|
}
|
||||||
|
|
||||||
type sanitizedPrebuilt interface {
|
type sanitizedPrebuilt interface {
|
||||||
@@ -58,6 +57,9 @@ type sanitizedPrebuilt interface {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type prebuiltCommonProperties struct {
|
type prebuiltCommonProperties struct {
|
||||||
|
DeapexerProperties
|
||||||
|
SelectedApexProperties
|
||||||
|
|
||||||
ForceDisable bool `blueprint:"mutated"`
|
ForceDisable bool `blueprint:"mutated"`
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -66,7 +68,7 @@ func (p *prebuiltCommon) Prebuilt() *android.Prebuilt {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (p *prebuiltCommon) isForceDisabled() bool {
|
func (p *prebuiltCommon) isForceDisabled() bool {
|
||||||
return p.properties.ForceDisable
|
return p.prebuiltCommonProperties.ForceDisable
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *prebuiltCommon) checkForceDisable(ctx android.ModuleContext) bool {
|
func (p *prebuiltCommon) checkForceDisable(ctx android.ModuleContext) bool {
|
||||||
@@ -88,7 +90,7 @@ func (p *prebuiltCommon) checkForceDisable(ctx android.ModuleContext) bool {
|
|||||||
forceDisable = forceDisable || (android.InList("hwaddress", ctx.Config().SanitizeDevice()) && !sanitized.hasSanitizedSource("hwaddress"))
|
forceDisable = forceDisable || (android.InList("hwaddress", ctx.Config().SanitizeDevice()) && !sanitized.hasSanitizedSource("hwaddress"))
|
||||||
|
|
||||||
if forceDisable && p.prebuilt.SourceExists() {
|
if forceDisable && p.prebuilt.SourceExists() {
|
||||||
p.properties.ForceDisable = true
|
p.prebuiltCommonProperties.ForceDisable = true
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
return false
|
return false
|
||||||
@@ -119,14 +121,14 @@ func (p *prebuiltCommon) prebuiltApexContentsDeps(ctx android.BottomUpMutatorCon
|
|||||||
module := ctx.Module()
|
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.prebuiltCommonProperties.Exported_java_libs {
|
||||||
dep := android.PrebuiltNameFromSource(exported)
|
dep := android.PrebuiltNameFromSource(exported)
|
||||||
ctx.AddDependency(module, 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.prebuiltCommonProperties.Exported_bootclasspath_fragments {
|
||||||
dep := android.PrebuiltNameFromSource(exported)
|
dep := android.PrebuiltNameFromSource(exported)
|
||||||
ctx.AddDependency(module, exportedBootclasspathFragmentTag, dep)
|
ctx.AddDependency(module, exportedBootclasspathFragmentTag, dep)
|
||||||
}
|
}
|
||||||
@@ -263,7 +265,6 @@ type Prebuilt struct {
|
|||||||
prebuiltCommon
|
prebuiltCommon
|
||||||
|
|
||||||
properties PrebuiltProperties
|
properties PrebuiltProperties
|
||||||
selectedApexProperties SelectedApexProperties
|
|
||||||
|
|
||||||
inputApex android.Path
|
inputApex android.Path
|
||||||
installDir android.InstallPath
|
installDir android.InstallPath
|
||||||
@@ -378,8 +379,8 @@ func (p *Prebuilt) Name() string {
|
|||||||
// prebuilt_apex imports an `.apex` file into the build graph as if it was built with apex.
|
// prebuilt_apex imports an `.apex` file into the build graph as if it was built with apex.
|
||||||
func PrebuiltFactory() android.Module {
|
func PrebuiltFactory() android.Module {
|
||||||
module := &Prebuilt{}
|
module := &Prebuilt{}
|
||||||
module.AddProperties(&module.properties, &module.deapexerProperties, &module.selectedApexProperties)
|
module.AddProperties(&module.properties, &module.prebuiltCommonProperties)
|
||||||
android.InitSingleSourcePrebuiltModule(module, &module.selectedApexProperties, "Selected_apex")
|
android.InitSingleSourcePrebuiltModule(module, &module.prebuiltCommonProperties, "Selected_apex")
|
||||||
android.InitAndroidMultiTargetsArchModule(module, android.DeviceSupported, android.MultilibCommon)
|
android.InitAndroidMultiTargetsArchModule(module, android.DeviceSupported, android.MultilibCommon)
|
||||||
|
|
||||||
return module
|
return module
|
||||||
@@ -403,14 +404,14 @@ func createApexSelectorModule(ctx android.TopDownMutatorContext, name string, ap
|
|||||||
// A deapexer module is only needed when the prebuilt apex specifies one or more modules in either
|
// 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 `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.
|
// 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, properties *prebuiltCommonProperties) {
|
||||||
// Only create the deapexer module if it is needed.
|
// Only create the deapexer module if it is needed.
|
||||||
if len(deapexerProperties.Exported_java_libs)+len(deapexerProperties.Exported_bootclasspath_fragments) == 0 {
|
if len(properties.Exported_java_libs)+len(properties.Exported_bootclasspath_fragments) == 0 {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// Compute the deapexer properties from the transitive dependencies of this module.
|
// Compute the deapexer properties from the transitive dependencies of this module.
|
||||||
deapexerProperties = &DeapexerProperties{}
|
deapexerProperties := &DeapexerProperties{}
|
||||||
ctx.WalkDeps(func(child, parent android.Module) bool {
|
ctx.WalkDeps(func(child, parent android.Module) bool {
|
||||||
tag := ctx.OtherModuleDependencyTag(child)
|
tag := ctx.OtherModuleDependencyTag(child)
|
||||||
|
|
||||||
@@ -528,10 +529,10 @@ func (p *Prebuilt) createPrebuiltApexModules(ctx android.TopDownMutatorContext)
|
|||||||
createApexSelectorModule(ctx, apexSelectorModuleName, &p.properties.ApexFileProperties)
|
createApexSelectorModule(ctx, apexSelectorModuleName, &p.properties.ApexFileProperties)
|
||||||
|
|
||||||
apexFileSource := ":" + apexSelectorModuleName
|
apexFileSource := ":" + apexSelectorModuleName
|
||||||
createDeapexerModuleIfNeeded(ctx, deapexerModuleName(baseModuleName), apexFileSource, &p.deapexerProperties)
|
createDeapexerModuleIfNeeded(ctx, deapexerModuleName(baseModuleName), apexFileSource, &p.prebuiltCommonProperties)
|
||||||
|
|
||||||
// Add a source reference to retrieve the selected apex from the selector module.
|
// Add a source reference to retrieve the selected apex from the selector module.
|
||||||
p.selectedApexProperties.Selected_apex = proptools.StringPtr(apexFileSource)
|
p.prebuiltCommonProperties.Selected_apex = proptools.StringPtr(apexFileSource)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *Prebuilt) ComponentDepsMutator(ctx android.BottomUpMutatorContext) {
|
func (p *Prebuilt) ComponentDepsMutator(ctx android.BottomUpMutatorContext) {
|
||||||
@@ -546,7 +547,7 @@ func (p *Prebuilt) ApexInfoMutator(mctx android.TopDownMutatorContext) {
|
|||||||
|
|
||||||
func (p *Prebuilt) GenerateAndroidBuildActions(ctx android.ModuleContext) {
|
func (p *Prebuilt) GenerateAndroidBuildActions(ctx android.ModuleContext) {
|
||||||
// TODO(jungjw): Check the key validity.
|
// TODO(jungjw): Check the key validity.
|
||||||
p.inputApex = android.OptionalPathForModuleSrc(ctx, p.selectedApexProperties.Selected_apex).Path()
|
p.inputApex = android.OptionalPathForModuleSrc(ctx, p.prebuiltCommonProperties.Selected_apex).Path()
|
||||||
p.installDir = android.PathForModuleInstall(ctx, "apex")
|
p.installDir = android.PathForModuleInstall(ctx, "apex")
|
||||||
p.installFilename = p.InstallFilename()
|
p.installFilename = p.InstallFilename()
|
||||||
if !strings.HasSuffix(p.installFilename, imageApexSuffix) {
|
if !strings.HasSuffix(p.installFilename, imageApexSuffix) {
|
||||||
@@ -748,9 +749,9 @@ func (a *ApexSet) Overrides() []string {
|
|||||||
// prebuilt_apex imports an `.apex` file into the build graph as if it was built with apex.
|
// prebuilt_apex imports an `.apex` file into the build graph as if it was built with apex.
|
||||||
func apexSetFactory() android.Module {
|
func apexSetFactory() android.Module {
|
||||||
module := &ApexSet{}
|
module := &ApexSet{}
|
||||||
module.AddProperties(&module.properties, &module.selectedApexProperties, &module.deapexerProperties)
|
module.AddProperties(&module.properties, &module.prebuiltCommonProperties)
|
||||||
|
|
||||||
android.InitSingleSourcePrebuiltModule(module, &module.selectedApexProperties, "Selected_apex")
|
android.InitSingleSourcePrebuiltModule(module, &module.prebuiltCommonProperties, "Selected_apex")
|
||||||
android.InitAndroidMultiTargetsArchModule(module, android.DeviceSupported, android.MultilibCommon)
|
android.InitAndroidMultiTargetsArchModule(module, android.DeviceSupported, android.MultilibCommon)
|
||||||
|
|
||||||
return module
|
return module
|
||||||
@@ -789,10 +790,10 @@ func (a *ApexSet) createPrebuiltApexModules(ctx android.TopDownMutatorContext) {
|
|||||||
createApexExtractorModule(ctx, apexExtractorModuleName, &a.properties.ApexExtractorProperties)
|
createApexExtractorModule(ctx, apexExtractorModuleName, &a.properties.ApexExtractorProperties)
|
||||||
|
|
||||||
apexFileSource := ":" + apexExtractorModuleName
|
apexFileSource := ":" + apexExtractorModuleName
|
||||||
createDeapexerModuleIfNeeded(ctx, deapexerModuleName(baseModuleName), apexFileSource, &a.deapexerProperties)
|
createDeapexerModuleIfNeeded(ctx, deapexerModuleName(baseModuleName), apexFileSource, &a.prebuiltCommonProperties)
|
||||||
|
|
||||||
// After passing the arch specific src properties to the creating the apex selector module
|
// After passing the arch specific src properties to the creating the apex selector module
|
||||||
a.selectedApexProperties.Selected_apex = proptools.StringPtr(apexFileSource)
|
a.prebuiltCommonProperties.Selected_apex = proptools.StringPtr(apexFileSource)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a *ApexSet) ComponentDepsMutator(ctx android.BottomUpMutatorContext) {
|
func (a *ApexSet) ComponentDepsMutator(ctx android.BottomUpMutatorContext) {
|
||||||
@@ -811,7 +812,7 @@ func (a *ApexSet) GenerateAndroidBuildActions(ctx android.ModuleContext) {
|
|||||||
ctx.ModuleErrorf("filename should end in %s for apex_set", imageApexSuffix)
|
ctx.ModuleErrorf("filename should end in %s for apex_set", imageApexSuffix)
|
||||||
}
|
}
|
||||||
|
|
||||||
inputApex := android.OptionalPathForModuleSrc(ctx, a.selectedApexProperties.Selected_apex).Path()
|
inputApex := android.OptionalPathForModuleSrc(ctx, a.prebuiltCommonProperties.Selected_apex).Path()
|
||||||
a.outputApex = android.PathForModuleOut(ctx, a.installFilename)
|
a.outputApex = android.PathForModuleOut(ctx, a.installFilename)
|
||||||
ctx.Build(pctx, android.BuildParams{
|
ctx.Build(pctx, android.BuildParams{
|
||||||
Rule: android.Cp,
|
Rule: android.Cp,
|
||||||
|
Reference in New Issue
Block a user