Move cc.imageMutator into the android package

Prepare for making the image mutator available to all modules and
moving it between the os and arch mutators by moving it into the
android package and using an interface implemented by the module
types to control it.

Bug: 142286466
Test: No unexpected changes to out/soong/build.ninja
Change-Id: I0dcc9c7b5ec80edffade340c367f6ae4da34151b
This commit is contained in:
Colin Cross 2019-11-18 16:00:16 -08:00
parent 43b92e0d0f
commit 7228ecd5e3
18 changed files with 253 additions and 193 deletions

View File

@ -51,6 +51,7 @@ bootstrap_go_package {
"android/expand.go",
"android/filegroup.go",
"android/hooks.go",
"android/image.go",
"android/makevars.go",
"android/module.go",
"android/mutator.go",

83
android/image.go Normal file
View File

@ -0,0 +1,83 @@
// Copyright 2019 Google Inc. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package android
// ImageInterface is implemented by modules that need to be split by the ImageMutator.
type ImageInterface interface {
// ImageMutatorBegin is called before any other method in the ImageInterface.
ImageMutatorBegin(ctx BaseModuleContext)
// CoreVariantNeeded should return true if the module needs a core variant (installed on the system image).
CoreVariantNeeded(ctx BaseModuleContext) bool
// RecoveryVariantNeeded should return true if the module needs a recovery variant (installed on the
// recovery partition).
RecoveryVariantNeeded(ctx BaseModuleContext) bool
// ExtraImageVariations should return a list of the additional variations needed for the module. After the
// variants are created the SetImageVariation method will be called on each newly created variant with the
// its variation.
ExtraImageVariations(ctx BaseModuleContext) []string
// SetImageVariation will be passed a newly created recovery variant of the module. ModuleBase implements
// SetImageVariation, most module types will not need to override it, and those that do must call the
// overridden method. Implementors of SetImageVariation must be careful to modify the module argument
// and not the receiver.
SetImageVariation(ctx BaseModuleContext, variation string, module Module)
}
const (
// CoreVariation is the variant used for framework-private libraries, or
// SDK libraries. (which framework-private libraries can use), which
// will be installed to the system image.
CoreVariation string = "core"
// RecoveryVariation means a module to be installed to recovery image.
RecoveryVariation string = "recovery"
)
// ImageMutator creates variants for modules that implement the ImageInterface that
// allow them to build differently for each partition (recovery, core, vendor, etc.).
func ImageMutator(ctx BottomUpMutatorContext) {
if ctx.Os() != Android {
return
}
if m, ok := ctx.Module().(ImageInterface); ok {
m.ImageMutatorBegin(ctx)
var variations []string
if m.CoreVariantNeeded(ctx) {
variations = append(variations, CoreVariation)
}
if m.RecoveryVariantNeeded(ctx) {
variations = append(variations, RecoveryVariation)
}
extraVariations := m.ExtraImageVariations(ctx)
variations = append(variations, extraVariations...)
if len(variations) == 0 {
return
}
mod := ctx.CreateVariations(variations...)
for i, v := range variations {
mod[i].base().setImageVariation(v)
m.SetImageVariation(ctx, v, mod[i])
}
}
}

View File

@ -431,6 +431,9 @@ type commonProperties struct {
DebugName string `blueprint:"mutated"`
DebugMutators []string `blueprint:"mutated"`
DebugVariations []string `blueprint:"mutated"`
// set by ImageMutator
ImageVariation string `blueprint:"mutated"`
}
type hostAndDeviceProperties struct {
@ -865,6 +868,21 @@ func (m *ModuleBase) NoticeFile() OptionalPath {
return m.noticeFile
}
func (m *ModuleBase) setImageVariation(variant string) {
m.commonProperties.ImageVariation = variant
}
func (m *ModuleBase) ImageVariation() blueprint.Variation {
return blueprint.Variation{
Mutator: "image",
Variation: m.base().commonProperties.ImageVariation,
}
}
func (m *ModuleBase) InRecovery() bool {
return m.base().commonProperties.ImageVariation == RecoveryVariation
}
func (m *ModuleBase) generateModuleTarget(ctx ModuleContext) {
allInstalledFiles := Paths{}
allCheckbuildFiles := Paths{}

View File

@ -25,10 +25,6 @@ func init() {
RegisterModuleType("prebuilt_usr_share_host", PrebuiltUserShareHostFactory)
RegisterModuleType("prebuilt_font", PrebuiltFontFactory)
RegisterModuleType("prebuilt_firmware", PrebuiltFirmwareFactory)
PreDepsMutators(func(ctx RegisterMutatorsContext) {
ctx.BottomUp("prebuilt_etc", prebuiltEtcMutator).Parallel()
})
}
type prebuiltEtcProperties struct {
@ -48,8 +44,6 @@ type prebuiltEtcProperties struct {
// Make this module available when building for recovery.
Recovery_available *bool
InRecovery bool `blueprint:"mutated"`
// Whether this module is directly installable to one of the partitions. Default: true.
Installable *bool
}
@ -76,7 +70,7 @@ type PrebuiltEtc struct {
}
func (p *PrebuiltEtc) inRecovery() bool {
return p.properties.InRecovery || p.ModuleBase.InstallInRecovery()
return p.ModuleBase.InRecovery() || p.ModuleBase.InstallInRecovery()
}
func (p *PrebuiltEtc) onlyInRecovery() bool {
@ -87,6 +81,25 @@ func (p *PrebuiltEtc) InstallInRecovery() bool {
return p.inRecovery()
}
var _ ImageInterface = (*PrebuiltEtc)(nil)
func (p *PrebuiltEtc) ImageMutatorBegin(ctx BaseModuleContext) {}
func (p *PrebuiltEtc) CoreVariantNeeded(ctx BaseModuleContext) bool {
return !p.ModuleBase.InstallInRecovery()
}
func (p *PrebuiltEtc) RecoveryVariantNeeded(ctx BaseModuleContext) bool {
return Bool(p.properties.Recovery_available) || p.ModuleBase.InstallInRecovery()
}
func (p *PrebuiltEtc) ExtraImageVariations(ctx BaseModuleContext) []string {
return nil
}
func (p *PrebuiltEtc) SetImageVariation(ctx BaseModuleContext, variation string, module Module) {
}
func (p *PrebuiltEtc) DepsMutator(ctx BottomUpMutatorContext) {
if p.properties.Src == nil {
ctx.PropertyErrorf("src", "missing prebuilt source file")
@ -222,49 +235,6 @@ func PrebuiltUserShareHostFactory() Module {
return module
}
const (
// coreMode is the variant for modules to be installed to system.
coreMode = "core"
// recoveryMode means a module to be installed to recovery image.
recoveryMode = "recovery"
)
// prebuiltEtcMutator creates the needed variants to install the module to
// system or recovery.
func prebuiltEtcMutator(mctx BottomUpMutatorContext) {
m, ok := mctx.Module().(*PrebuiltEtc)
if !ok || m.Host() {
return
}
var coreVariantNeeded bool = true
var recoveryVariantNeeded bool = false
if Bool(m.properties.Recovery_available) {
recoveryVariantNeeded = true
}
if m.ModuleBase.InstallInRecovery() {
recoveryVariantNeeded = true
coreVariantNeeded = false
}
var variants []string
if coreVariantNeeded {
variants = append(variants, coreMode)
}
if recoveryVariantNeeded {
variants = append(variants, recoveryMode)
}
mod := mctx.CreateVariations(variants...)
for i, v := range variants {
if v == recoveryMode {
m := mod[i].(*PrebuiltEtc)
m.properties.InRecovery = true
}
}
}
// prebuilt_font installs a font in <partition>/fonts directory.
func PrebuiltFontFactory() Module {
module := &PrebuiltEtc{}

View File

@ -30,7 +30,7 @@ func testPrebuiltEtc(t *testing.T, bp string) (*TestContext, Config) {
ctx.RegisterModuleType("prebuilt_font", ModuleFactoryAdaptor(PrebuiltFontFactory))
ctx.RegisterModuleType("prebuilt_firmware", ModuleFactoryAdaptor(PrebuiltFirmwareFactory))
ctx.PreDepsMutators(func(ctx RegisterMutatorsContext) {
ctx.BottomUp("prebuilt_etc", prebuiltEtcMutator).Parallel()
ctx.BottomUp("prebuilt_etc", ImageMutator).Parallel()
})
ctx.Register()
mockFiles := map[string][]byte{

View File

@ -874,12 +874,12 @@ func (a *apexBundle) installable() bool {
func (a *apexBundle) getImageVariation(config android.DeviceConfig) string {
if a.vndkApex {
return "vendor." + a.vndkVersion(config)
return cc.VendorVariationPrefix + a.vndkVersion(config)
}
if config.VndkVersion() != "" && proptools.Bool(a.properties.Use_vendor) {
return "vendor." + config.PlatformVndkVersion()
return cc.VendorVariationPrefix + config.PlatformVndkVersion()
} else {
return "core"
return android.CoreVariation
}
}

View File

@ -138,7 +138,7 @@ func testApexContext(t *testing.T, bp string, handlers ...testCustomizer) (*andr
ctx.BottomUp("prebuilts", android.PrebuiltMutator).Parallel()
})
ctx.PreDepsMutators(func(ctx android.RegisterMutatorsContext) {
ctx.BottomUp("image", cc.ImageMutator).Parallel()
ctx.BottomUp("image", android.ImageMutator).Parallel()
ctx.BottomUp("link", cc.LinkageMutator).Parallel()
ctx.BottomUp("vndk", cc.VndkMutator).Parallel()
ctx.BottomUp("test_per_src", cc.TestPerSrcMutator).Parallel()

161
cc/cc.go
View File

@ -37,7 +37,7 @@ func init() {
android.PreDepsMutators(func(ctx android.RegisterMutatorsContext) {
ctx.BottomUp("vndk", VndkMutator).Parallel()
ctx.BottomUp("image", ImageMutator).Parallel()
ctx.BottomUp("image", android.ImageMutator).Parallel()
ctx.BottomUp("link", LinkageMutator).Parallel()
ctx.BottomUp("ndk_api", ndkApiMutator).Parallel()
ctx.BottomUp("test_per_src", TestPerSrcMutator).Parallel()
@ -218,7 +218,10 @@ type BaseProperties struct {
// Make this module available when building for recovery
Recovery_available *bool
InRecovery bool `blueprint:"mutated"`
// Set by ImageMutator
CoreVariantNeeded bool `blueprint:"mutated"`
RecoveryVariantNeeded bool `blueprint:"mutated"`
VendorVariants []string `blueprint:"mutated"`
// Allows this module to use non-APEX version of libraries. Useful
// for building binaries that are started before APEXes are activated.
@ -822,7 +825,7 @@ func (c *Module) HasVendorVariant() bool {
}
func (c *Module) InRecovery() bool {
return c.Properties.InRecovery || c.ModuleBase.InstallInRecovery()
return c.ModuleBase.InRecovery() || c.ModuleBase.InstallInRecovery()
}
func (c *Module) OnlyInRecovery() bool {
@ -1584,8 +1587,7 @@ func (c *Module) DepsMutator(actx android.BottomUpMutatorContext) {
depTag = headerExportDepTag
}
if buildStubs {
actx.AddFarVariationDependencies(append(ctx.Target().Variations(),
blueprint.Variation{Mutator: "image", Variation: c.imageVariation()}),
actx.AddFarVariationDependencies(append(ctx.Target().Variations(), c.ImageVariation()),
depTag, lib)
} else {
actx.AddVariationDependencies(nil, depTag, lib)
@ -1723,14 +1725,8 @@ func (c *Module) DepsMutator(actx android.BottomUpMutatorContext) {
if vndkdep := c.vndkdep; vndkdep != nil {
if vndkdep.isVndkExt() {
var baseModuleMode string
if actx.DeviceConfig().VndkVersion() == "" {
baseModuleMode = coreMode
} else {
baseModuleMode = c.imageVariation()
}
actx.AddVariationDependencies([]blueprint.Variation{
{Mutator: "image", Variation: baseModuleMode},
c.ImageVariation(),
{Mutator: "link", Variation: "shared"},
}, vndkExtDepTag, vndkdep.getVndkExtendsModuleName())
}
@ -2385,15 +2381,6 @@ func (c *Module) installable() bool {
return c.installer != nil && !c.Properties.PreventInstall && c.IsForPlatform() && c.outputFile.Valid()
}
func (c *Module) imageVariation() string {
if c.UseVndk() {
return vendorMode + "." + c.Properties.VndkVersion
} else if c.InRecovery() {
return recoveryMode
}
return coreMode
}
func (c *Module) IDEInfo(dpInfo *android.IdeInfo) {
outputFiles, err := c.OutputFiles("")
if err != nil {
@ -2477,15 +2464,9 @@ func DefaultsFactory(props ...interface{}) android.Module {
}
const (
// coreMode is the variant used for framework-private libraries, or
// SDK libraries. (which framework-private libraries can use)
coreMode = "core"
// vendorMode is the variant prefix used for /vendor code that compiles
// VendorVariationPrefix is the variant prefix used for /vendor code that compiles
// against the VNDK.
vendorMode = "vendor"
recoveryMode = "recovery"
VendorVariationPrefix = "vendor."
)
func squashVendorSrcs(m *Module) {
@ -2508,74 +2489,9 @@ func squashRecoverySrcs(m *Module) {
}
}
func ImageMutator(mctx android.BottomUpMutatorContext) {
if mctx.Os() != android.Android {
return
}
if g, ok := mctx.Module().(*genrule.Module); ok {
if props, ok := g.Extra.(*GenruleExtraProperties); ok {
var coreVariantNeeded bool = false
var vendorVariantNeeded bool = false
var recoveryVariantNeeded bool = false
if mctx.DeviceConfig().VndkVersion() == "" {
coreVariantNeeded = true
} else if Bool(props.Vendor_available) {
coreVariantNeeded = true
vendorVariantNeeded = true
} else if mctx.SocSpecific() || mctx.DeviceSpecific() {
vendorVariantNeeded = true
} else {
coreVariantNeeded = true
}
if Bool(props.Recovery_available) {
recoveryVariantNeeded = true
}
if recoveryVariantNeeded {
primaryArch := mctx.Config().DevicePrimaryArchType()
moduleArch := g.Target().Arch.ArchType
if moduleArch != primaryArch {
recoveryVariantNeeded = false
}
}
var variants []string
if coreVariantNeeded {
variants = append(variants, coreMode)
}
if vendorVariantNeeded {
variants = append(variants, vendorMode+"."+mctx.DeviceConfig().PlatformVndkVersion())
if vndkVersion := mctx.DeviceConfig().VndkVersion(); vndkVersion != "current" {
variants = append(variants, vendorMode+"."+vndkVersion)
}
}
if recoveryVariantNeeded {
variants = append(variants, recoveryMode)
}
mod := mctx.CreateVariations(variants...)
for i, v := range variants {
if v == recoveryMode {
m := mod[i].(*genrule.Module)
m.Extra.(*GenruleExtraProperties).InRecovery = true
}
}
}
}
//TODO When LinkableInterface supports VNDK, this should be mctx.Module().(LinkableInterface)
m, ok := mctx.Module().(*Module)
if !ok {
if linkable, ok := mctx.Module().(LinkableInterface); ok {
variations := []string{coreMode}
if linkable.InRecovery() {
variations = append(variations, recoveryMode)
}
mctx.CreateVariations(variations...)
}
return
}
var _ android.ImageInterface = (*Module)(nil)
func (m *Module) ImageMutatorBegin(mctx android.BaseModuleContext) {
// Sanity check
vendorSpecific := mctx.SocSpecific() || mctx.DeviceSpecific()
productSpecific := mctx.ProductSpecific()
@ -2583,7 +2499,6 @@ func ImageMutator(mctx android.BottomUpMutatorContext) {
if m.VendorProperties.Vendor_available != nil && vendorSpecific {
mctx.PropertyErrorf("vendor_available",
"doesn't make sense at the same time as `vendor: true`, `proprietary: true`, or `device_specific:true`")
return
}
if vndkdep := m.vndkdep; vndkdep != nil {
@ -2591,38 +2506,32 @@ func ImageMutator(mctx android.BottomUpMutatorContext) {
if productSpecific {
mctx.PropertyErrorf("product_specific",
"product_specific must not be true when `vndk: {enabled: true}`")
return
}
if vendorSpecific {
if !vndkdep.isVndkExt() {
mctx.PropertyErrorf("vndk",
"must set `extends: \"...\"` to vndk extension")
return
}
} else {
if vndkdep.isVndkExt() {
mctx.PropertyErrorf("vndk",
"must set `vendor: true` to set `extends: %q`",
m.getVndkExtendsModuleName())
return
}
if m.VendorProperties.Vendor_available == nil {
mctx.PropertyErrorf("vndk",
"vendor_available must be set to either true or false when `vndk: {enabled: true}`")
return
}
}
} else {
if vndkdep.isVndkSp() {
mctx.PropertyErrorf("vndk",
"must set `enabled: true` to set `support_system_process: true`")
return
}
if vndkdep.isVndkExt() {
mctx.PropertyErrorf("vndk",
"must set `enabled: true` to set `extends: %q`",
m.getVndkExtendsModuleName())
return
}
}
}
@ -2701,28 +2610,34 @@ func ImageMutator(mctx android.BottomUpMutatorContext) {
}
}
var variants []string
if coreVariantNeeded {
variants = append(variants, coreMode)
}
for _, variant := range android.FirstUniqueStrings(vendorVariants) {
variants = append(variants, vendorMode+"."+variant)
m.Properties.VendorVariants = append(m.Properties.VendorVariants, VendorVariationPrefix+variant)
}
if recoveryVariantNeeded {
variants = append(variants, recoveryMode)
}
mod := mctx.CreateVariations(variants...)
for i, v := range variants {
if strings.HasPrefix(v, vendorMode+".") {
m := mod[i].(*Module)
m.Properties.VndkVersion = strings.TrimPrefix(v, vendorMode+".")
squashVendorSrcs(m)
} else if v == recoveryMode {
m := mod[i].(*Module)
m.Properties.InRecovery = true
m.MakeAsPlatform()
squashRecoverySrcs(m)
}
m.Properties.RecoveryVariantNeeded = recoveryVariantNeeded
m.Properties.CoreVariantNeeded = coreVariantNeeded
}
func (c *Module) CoreVariantNeeded(ctx android.BaseModuleContext) bool {
return c.Properties.CoreVariantNeeded
}
func (c *Module) RecoveryVariantNeeded(ctx android.BaseModuleContext) bool {
return c.Properties.RecoveryVariantNeeded
}
func (c *Module) ExtraImageVariations(ctx android.BaseModuleContext) []string {
return c.Properties.VendorVariants
}
func (c *Module) SetImageVariation(ctx android.BaseModuleContext, variant string, module android.Module) {
m := module.(*Module)
if variant == android.RecoveryVariation {
m.MakeAsPlatform()
squashRecoverySrcs(m)
} else if strings.HasPrefix(variant, VendorVariationPrefix) {
m.Properties.VndkVersion = strings.TrimPrefix(variant, VendorVariationPrefix)
squashVendorSrcs(m)
}
}

View File

@ -26,9 +26,6 @@ func init() {
type GenruleExtraProperties struct {
Vendor_available *bool
Recovery_available *bool
// This genrule is for recovery variant
InRecovery bool `blueprint:"mutated"`
}
// cc_genrule is a genrule that can depend on other cc_* objects.
@ -37,7 +34,9 @@ type GenruleExtraProperties struct {
func genRuleFactory() android.Module {
module := genrule.NewGenRule()
module.Extra = &GenruleExtraProperties{}
extra := &GenruleExtraProperties{}
module.Extra = extra
module.ImageInterface = extra
module.AddProperties(module.Extra)
android.InitAndroidArchModule(module, android.HostAndDeviceSupported, android.MultilibBoth)
@ -46,3 +45,44 @@ func genRuleFactory() android.Module {
return module
}
var _ android.ImageInterface = (*GenruleExtraProperties)(nil)
func (g *GenruleExtraProperties) ImageMutatorBegin(ctx android.BaseModuleContext) {}
func (g *GenruleExtraProperties) CoreVariantNeeded(ctx android.BaseModuleContext) bool {
if ctx.DeviceConfig().VndkVersion() == "" {
return true
}
return Bool(g.Vendor_available) || !(ctx.SocSpecific() || ctx.DeviceSpecific())
}
func (g *GenruleExtraProperties) RecoveryVariantNeeded(ctx android.BaseModuleContext) bool {
if Bool(g.Recovery_available) {
primaryArch := ctx.Config().DevicePrimaryArchType()
moduleArch := ctx.Target().Arch.ArchType
return moduleArch == primaryArch
}
return false
}
func (g *GenruleExtraProperties) ExtraImageVariations(ctx android.BaseModuleContext) []string {
if ctx.DeviceConfig().VndkVersion() == "" {
return nil
}
if Bool(g.Vendor_available) || ctx.SocSpecific() || ctx.DeviceSpecific() {
var variants []string
variants = append(variants, VendorVariationPrefix+ctx.DeviceConfig().PlatformVndkVersion())
if vndkVersion := ctx.DeviceConfig().VndkVersion(); vndkVersion != "current" {
variants = append(variants, VendorVariationPrefix+vndkVersion)
}
return variants
}
return nil
}
func (g *GenruleExtraProperties) SetImageVariation(ctx android.BaseModuleContext, variation string, module android.Module) {
}

View File

@ -1355,9 +1355,11 @@ func VersionMutator(mctx android.BottomUpMutatorContext) {
return
}
if genrule, ok := mctx.Module().(*genrule.Module); ok {
if props, ok := genrule.Extra.(*GenruleExtraProperties); ok && !props.InRecovery {
mctx.CreateVariations("")
return
if _, ok := genrule.Extra.(*GenruleExtraProperties); ok {
if !genrule.InRecovery() {
mctx.CreateVariations("")
return
}
}
}
}

View File

@ -886,13 +886,13 @@ func sanitizerRuntimeMutator(mctx android.BottomUpMutatorContext) {
// static executable gets static runtime libs
mctx.AddFarVariationDependencies(append(mctx.Target().Variations(), []blueprint.Variation{
{Mutator: "link", Variation: "static"},
{Mutator: "image", Variation: c.imageVariation()},
c.ImageVariation(),
}...), StaticDepTag, append([]string{runtimeLibrary}, extraStaticDeps...)...)
} else if !c.static() && !c.header() {
// dynamic executable and shared libs get shared runtime libs
mctx.AddFarVariationDependencies(append(mctx.Target().Variations(), []blueprint.Variation{
{Mutator: "link", Variation: "shared"},
{Mutator: "image", Variation: c.imageVariation()},
c.ImageVariation(),
}...), earlySharedDepTag, runtimeLibrary)
}
// static lib does not have dependency to the runtime library. The

View File

@ -271,7 +271,7 @@ func CreateTestContext(bp string, fs map[string][]byte,
ctx.RegisterModuleType("vndk_prebuilt_shared", android.ModuleFactoryAdaptor(VndkPrebuiltSharedFactory))
ctx.RegisterModuleType("vndk_libraries_txt", android.ModuleFactoryAdaptor(VndkLibrariesTxtFactory))
ctx.PreDepsMutators(func(ctx android.RegisterMutatorsContext) {
ctx.BottomUp("image", ImageMutator).Parallel()
ctx.BottomUp("image", android.ImageMutator).Parallel()
ctx.BottomUp("link", LinkageMutator).Parallel()
ctx.BottomUp("vndk", VndkMutator).Parallel()
ctx.BottomUp("version", VersionMutator).Parallel()

View File

@ -118,6 +118,7 @@ type Module struct {
// For other packages to make their own genrules with extra
// properties
Extra interface{}
android.ImageInterface
properties generatorProperties
@ -532,9 +533,20 @@ func generatorFactory(taskGenerator taskFunc, props ...interface{}) *Module {
module.AddProperties(props...)
module.AddProperties(&module.properties)
module.ImageInterface = noopImageInterface{}
return module
}
type noopImageInterface struct{}
func (x noopImageInterface) ImageMutatorBegin(android.BaseModuleContext) {}
func (x noopImageInterface) CoreVariantNeeded(android.BaseModuleContext) bool { return false }
func (x noopImageInterface) RecoveryVariantNeeded(android.BaseModuleContext) bool { return false }
func (x noopImageInterface) ExtraImageVariations(ctx android.BaseModuleContext) []string { return nil }
func (x noopImageInterface) SetImageVariation(ctx android.BaseModuleContext, variation string, module android.Module) {
}
// replace "out" with "__SBOX_OUT_DIR__/<the value of ${out}>"
func pathToSandboxOut(path android.Path, genDir android.Path) string {
relOut, err := filepath.Rel(genDir.String(), path.String())

View File

@ -77,6 +77,25 @@ type Module struct {
outputFile android.OptionalPath
}
var _ android.ImageInterface = (*Module)(nil)
func (mod *Module) ImageMutatorBegin(ctx android.BaseModuleContext) {}
func (mod *Module) CoreVariantNeeded(ctx android.BaseModuleContext) bool {
return true
}
func (mod *Module) RecoveryVariantNeeded(android.BaseModuleContext) bool {
return mod.InRecovery()
}
func (mod *Module) ExtraImageVariations(android.BaseModuleContext) []string {
return nil
}
func (c *Module) SetImageVariation(ctx android.BaseModuleContext, variant string, module android.Module) {
}
func (mod *Module) BuildStubs() bool {
return false
}
@ -674,7 +693,7 @@ func (mod *Module) DepsMutator(actx android.BottomUpMutatorContext) {
blueprint.Variation{Mutator: "version", Variation: ""})
if !mod.Host() {
commonDepVariations = append(commonDepVariations,
blueprint.Variation{Mutator: "image", Variation: "core"})
blueprint.Variation{Mutator: "image", Variation: android.CoreVariation})
}
actx.AddVariationDependencies(

View File

@ -185,7 +185,7 @@ func CreateTestContext(bp string) *android.TestContext {
ctx.RegisterModuleType("toolchain_library", android.ModuleFactoryAdaptor(cc.ToolchainLibraryFactory))
ctx.PreDepsMutators(func(ctx android.RegisterMutatorsContext) {
// cc mutators
ctx.BottomUp("image", cc.ImageMutator).Parallel()
ctx.BottomUp("image", android.ImageMutator).Parallel()
ctx.BottomUp("link", cc.LinkageMutator).Parallel()
ctx.BottomUp("version", cc.VersionMutator).Parallel()
ctx.BottomUp("begin", cc.BeginMutator).Parallel()

View File

@ -176,7 +176,7 @@ func memberMutator(mctx android.BottomUpMutatorContext) {
version = cc.LatestStubsVersionFor(mctx.Config(), name)
}
mctx.AddFarVariationDependencies(append(target.Variations(), []blueprint.Variation{
{Mutator: "image", Variation: "core"},
{Mutator: "image", Variation: android.CoreVariation},
{Mutator: "link", Variation: "shared"},
{Mutator: "version", Variation: version},
}...), sdkMemberDepTag, name)

View File

@ -55,7 +55,7 @@ func testSdkContext(t *testing.T, bp string) (*android.TestContext, android.Conf
ctx.RegisterModuleType("llndk_library", android.ModuleFactoryAdaptor(cc.LlndkLibraryFactory))
ctx.RegisterModuleType("toolchain_library", android.ModuleFactoryAdaptor(cc.ToolchainLibraryFactory))
ctx.PreDepsMutators(func(ctx android.RegisterMutatorsContext) {
ctx.BottomUp("image", cc.ImageMutator).Parallel()
ctx.BottomUp("image", android.ImageMutator).Parallel()
ctx.BottomUp("link", cc.LinkageMutator).Parallel()
ctx.BottomUp("vndk", cc.VndkMutator).Parallel()
ctx.BottomUp("test_per_src", cc.TestPerSrcMutator).Parallel()

View File

@ -73,7 +73,7 @@ func testContext(config android.Config, bp string,
ctx.RegisterModuleType("llndk_library", android.ModuleFactoryAdaptor(cc.LlndkLibraryFactory))
ctx.RegisterModuleType("toolchain_library", android.ModuleFactoryAdaptor(cc.ToolchainLibraryFactory))
ctx.PreDepsMutators(func(ctx android.RegisterMutatorsContext) {
ctx.BottomUp("image", cc.ImageMutator).Parallel()
ctx.BottomUp("image", android.ImageMutator).Parallel()
ctx.BottomUp("link", cc.LinkageMutator).Parallel()
ctx.BottomUp("vndk", cc.VndkMutator).Parallel()
ctx.BottomUp("version", cc.VersionMutator).Parallel()