Extract ApexFileProperties from apex PrebuiltProperties
The properties and logic to select the appropriate arch specific src property will need to be shared between the 'prebuilt_apex' module type and an upcoming 'deapexer' module type to which the `prebuilt_apex` will delegate responsibility for exporting the '.apex' file's contents. This refactoring extracts them into the new ApexFileProperties struct for reuse. Bug: 171061220 Test: m nothing Change-Id: Iac321a28afc469e885ee5b19ad33fecd94117236
This commit is contained in:
parent
66f7fdd1c8
commit
851f3995bc
|
@ -107,7 +107,7 @@ type Prebuilt struct {
|
||||||
compatSymlinks []string
|
compatSymlinks []string
|
||||||
}
|
}
|
||||||
|
|
||||||
type PrebuiltProperties struct {
|
type ApexFileProperties struct {
|
||||||
// the path to the prebuilt .apex file to import.
|
// the path to the prebuilt .apex file to import.
|
||||||
Source string `blueprint:"mutated"`
|
Source string `blueprint:"mutated"`
|
||||||
|
|
||||||
|
@ -126,6 +126,38 @@ type PrebuiltProperties struct {
|
||||||
Src *string
|
Src *string
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
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")
|
||||||
|
}
|
||||||
|
var src string
|
||||||
|
switch ctx.MultiTargets()[0].Arch.ArchType {
|
||||||
|
case android.Arm:
|
||||||
|
src = String(p.Arch.Arm.Src)
|
||||||
|
case android.Arm64:
|
||||||
|
src = String(p.Arch.Arm64.Src)
|
||||||
|
case android.X86:
|
||||||
|
src = String(p.Arch.X86.Src)
|
||||||
|
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())
|
||||||
|
}
|
||||||
|
if src == "" {
|
||||||
|
src = String(p.Src)
|
||||||
|
}
|
||||||
|
p.Source = src
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
type PrebuiltProperties struct {
|
||||||
|
ApexFileProperties
|
||||||
|
|
||||||
Installable *bool
|
Installable *bool
|
||||||
// Optional name for the installed apex. If unspecified, name of the
|
// Optional name for the installed apex. If unspecified, name of the
|
||||||
|
@ -175,31 +207,10 @@ func PrebuiltFactory() android.Module {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *Prebuilt) DepsMutator(ctx android.BottomUpMutatorContext) {
|
func (p *Prebuilt) DepsMutator(ctx android.BottomUpMutatorContext) {
|
||||||
// This is called before prebuilt_select and prebuilt_postdeps mutators
|
if err := p.properties.selectSource(ctx); err != nil {
|
||||||
// The mutators requires that src to be set correctly for each arch so that
|
ctx.ModuleErrorf("%s", err)
|
||||||
// arch variants are disabled when src is not provided for the arch.
|
|
||||||
if len(ctx.MultiTargets()) != 1 {
|
|
||||||
ctx.ModuleErrorf("compile_multilib shouldn't be \"both\" for prebuilt_apex")
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
var src string
|
|
||||||
switch ctx.MultiTargets()[0].Arch.ArchType {
|
|
||||||
case android.Arm:
|
|
||||||
src = String(p.properties.Arch.Arm.Src)
|
|
||||||
case android.Arm64:
|
|
||||||
src = String(p.properties.Arch.Arm64.Src)
|
|
||||||
case android.X86:
|
|
||||||
src = String(p.properties.Arch.X86.Src)
|
|
||||||
case android.X86_64:
|
|
||||||
src = String(p.properties.Arch.X86_64.Src)
|
|
||||||
default:
|
|
||||||
ctx.ModuleErrorf("prebuilt_apex does not support %q", ctx.MultiTargets()[0].Arch.String())
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if src == "" {
|
|
||||||
src = String(p.properties.Src)
|
|
||||||
}
|
|
||||||
p.properties.Source = src
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *Prebuilt) GenerateAndroidBuildActions(ctx android.ModuleContext) {
|
func (p *Prebuilt) GenerateAndroidBuildActions(ctx android.ModuleContext) {
|
||||||
|
|
Loading…
Reference in New Issue