Merge "Skip version mutator for host/ramdisk/recovery" into rvc-dev

This commit is contained in:
TreeHugger Robot 2020-04-22 09:08:17 +00:00 committed by Android (Google) Code Review
commit d50865fcec
4 changed files with 22 additions and 12 deletions

View file

@ -1850,8 +1850,7 @@ func (c *Module) DepsMutator(actx android.BottomUpMutatorContext) {
addSharedLibDependencies := func(depTag DependencyTag, name string, version string) {
var variations []blueprint.Variation
variations = append(variations, blueprint.Variation{Mutator: "link", Variation: "shared"})
versionVariantAvail := !c.InRecovery() && !c.InRamdisk()
if version != "" && versionVariantAvail {
if version != "" && VersionVariantAvailable(c) {
// Version is explicitly specified. i.e. libFoo#30
variations = append(variations, blueprint.Variation{Mutator: "version", Variation: version})
depTag.ExplicitlyVersioned = true
@ -1861,7 +1860,7 @@ func (c *Module) DepsMutator(actx android.BottomUpMutatorContext) {
// If the version is not specified, add dependency to all stubs libraries.
// The stubs library will be used when the depending module is built for APEX and
// the dependent module is not in the same APEX.
if version == "" && versionVariantAvail {
if version == "" && VersionVariantAvailable(c) {
for _, ver := range stubsVersionsFor(actx.Config())[name] {
// Note that depTag.ExplicitlyVersioned is false in this case.
actx.AddVariationDependencies([]blueprint.Variation{
@ -2259,7 +2258,7 @@ func (c *Module) depsToPaths(ctx android.ModuleContext) PathDeps {
}
if ccDep.CcLibrary() && !depIsStatic {
depIsStubs := ccDep.BuildStubs()
depHasStubs := ccDep.HasStubsVariants()
depHasStubs := VersionVariantAvailable(c) && ccDep.HasStubsVariants()
depInSameApex := android.DirectlyInApex(c.ApexName(), depName)
depInPlatform := !android.DirectlyInAnyApex(ctx, depName)
@ -2275,8 +2274,8 @@ func (c *Module) depsToPaths(ctx android.ModuleContext) PathDeps {
// If not building for APEX, use stubs only when it is from
// an APEX (and not from platform)
useThisDep = (depInPlatform != depIsStubs)
if c.InRamdisk() || c.InRecovery() || c.bootstrap() {
// However, for ramdisk, recovery or bootstrap modules,
if c.bootstrap() {
// However, for host, ramdisk, recovery or bootstrap modules,
// always link to non-stub variant
useThisDep = !depIsStubs
}

View file

@ -1498,10 +1498,18 @@ func createVersionVariations(mctx android.BottomUpMutatorContext, versions []str
}
}
// Version mutator splits a module into the mandatory non-stubs variant
func VersionVariantAvailable(module interface {
Host() bool
InRamdisk() bool
InRecovery() bool
}) bool {
return !module.Host() && !module.InRamdisk() && !module.InRecovery()
}
// VersionMutator splits a module into the mandatory non-stubs variant
// (which is unnamed) and zero or more stubs variants.
func VersionMutator(mctx android.BottomUpMutatorContext) {
if library, ok := mctx.Module().(LinkableInterface); ok && !library.InRecovery() {
if library, ok := mctx.Module().(LinkableInterface); ok && VersionVariantAvailable(library) {
if library.CcLibrary() && library.BuildSharedVariant() && len(library.StubsVersions()) > 0 {
versions := library.StubsVersions()
normalizeVersions(mctx, versions)
@ -1537,7 +1545,7 @@ func VersionMutator(mctx android.BottomUpMutatorContext) {
}
if genrule, ok := mctx.Module().(*genrule.Module); ok {
if _, ok := genrule.Extra.(*GenruleExtraProperties); ok {
if !genrule.InRecovery() {
if VersionVariantAvailable(genrule) {
mctx.CreateVariations("")
return
}

View file

@ -39,6 +39,8 @@ type LinkableInterface interface {
Shared() bool
Toc() android.OptionalPath
Host() bool
InRamdisk() bool
OnlyInRamdisk() bool

View file

@ -727,13 +727,14 @@ func (mod *Module) DepsMutator(actx android.BottomUpMutatorContext) {
deps := mod.deps(ctx)
commonDepVariations := []blueprint.Variation{}
commonDepVariations = append(commonDepVariations,
blueprint.Variation{Mutator: "version", Variation: ""})
if cc.VersionVariantAvailable(mod) {
commonDepVariations = append(commonDepVariations,
blueprint.Variation{Mutator: "version", Variation: ""})
}
if !mod.Host() {
commonDepVariations = append(commonDepVariations,
blueprint.Variation{Mutator: "image", Variation: android.CoreVariation})
}
actx.AddVariationDependencies(
append(commonDepVariations, []blueprint.Variation{
{Mutator: "rust_libraries", Variation: "rlib"},