Merge "Remove deapexer and prebuilt apex select mutators" am: 4b786d2da1 am: 0630dacc0c am: 9d697b3d94

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

MUST ONLY BE SUBMITTED BY AUTOMERGER

Change-Id: I4670d011f304c943cc6156312b0154e9236ca08f
This commit is contained in:
Paul Duffin
2021-03-03 00:23:03 +00:00
committed by Automerger Merge Worker
6 changed files with 35 additions and 46 deletions

View File

@@ -108,8 +108,10 @@ type Prebuilt struct {
type ApexFileProperties struct {
// the path to the prebuilt .apex file to import.
Source string `blueprint:"mutated"`
//
// This cannot be marked as `android:"arch_variant"` because the `prebuilt_apex` is only mutated
// for android_common. That is so that it will have the same arch variant as, and so be compatible
// with, the source `apex` module type that it replaces.
Src *string
Arch struct {
Arm struct {
@@ -127,15 +129,20 @@ type ApexFileProperties struct {
}
}
func (p *ApexFileProperties) selectSource(ctx android.BottomUpMutatorContext) error {
// This is called before prebuilt_select and prebuilt_postdeps mutators
// The mutators requires that src to be set correctly for each arch so that
// arch variants are disabled when src is not provided for the arch.
if len(ctx.MultiTargets()) != 1 {
return fmt.Errorf("compile_multilib shouldn't be \"both\" for prebuilt_apex")
// prebuiltApexSelector selects the correct prebuilt APEX file for the build target.
//
// The ctx parameter can be for any module not just the prebuilt module so care must be taken not
// to use methods on it that are specific to the current module.
//
// See the ApexFileProperties.Src property.
func (p *ApexFileProperties) prebuiltApexSelector(ctx android.BaseModuleContext, prebuilt android.Module) []string {
multiTargets := prebuilt.MultiTargets()
if len(multiTargets) != 1 {
ctx.OtherModuleErrorf(prebuilt, "compile_multilib shouldn't be \"both\" for prebuilt_apex")
return nil
}
var src string
switch ctx.MultiTargets()[0].Arch.ArchType {
switch multiTargets[0].Arch.ArchType {
case android.Arm:
src = String(p.Arch.Arm.Src)
case android.Arm64:
@@ -145,14 +152,14 @@ func (p *ApexFileProperties) selectSource(ctx android.BottomUpMutatorContext) er
case android.X86_64:
src = String(p.Arch.X86_64.Src)
default:
return fmt.Errorf("prebuilt_apex does not support %q", ctx.MultiTargets()[0].Arch.String())
ctx.OtherModuleErrorf(prebuilt, "prebuilt_apex does not support %q", multiTargets[0].Arch.String())
return nil
}
if src == "" {
src = String(p.Src)
}
p.Source = src
return nil
return []string{src}
}
type PrebuiltProperties struct {
@@ -216,7 +223,7 @@ func (p *Prebuilt) Name() string {
func PrebuiltFactory() android.Module {
module := &Prebuilt{}
module.AddProperties(&module.properties)
android.InitSingleSourcePrebuiltModule(module, &module.properties, "Source")
android.InitPrebuiltModuleWithSrcSupplier(module, module.properties.prebuiltApexSelector, "src")
android.InitAndroidMultiTargetsArchModule(module, android.DeviceSupported, android.MultilibCommon)
android.AddLoadHook(module, func(ctx android.LoadHookContext) {
@@ -249,16 +256,6 @@ func prebuiltApexExportedModuleName(ctx android.BottomUpMutatorContext, name str
return name
}
func prebuiltSelectSourceMutator(ctx android.BottomUpMutatorContext) {
p, ok := ctx.Module().(*Prebuilt)
if !ok {
return
}
if err := p.properties.selectSource(ctx); err != nil {
ctx.ModuleErrorf("%s", err)
}
}
type exportedDependencyTag struct {
blueprint.BaseDependencyTag
name string
@@ -531,7 +528,7 @@ func apexSetFactory() android.Module {
module := &ApexSet{}
module.AddProperties(&module.properties)
srcsSupplier := func(ctx android.BaseModuleContext) []string {
srcsSupplier := func(ctx android.BaseModuleContext, _ android.Module) []string {
return module.prebuiltSrcs(ctx)
}