Skip version mutator for host/ramdisk/recovery
"version" mutator creates stubs variants for "cc" libraries with
"stubs.versions". These stubs are for APEX-APEX or APEX-Platform
boundaries.
For host/ramdisk/recovery variants, stubs are not necessary.
Exempt-From-Owner-Approval: cp from internal
Bug: 153698496
Test: m
Merged-In: Id576c4318d9d69246a4a7e2fb4145d5fd2ab9416
Change-Id: Id576c4318d9d69246a4a7e2fb4145d5fd2ab9416
(cherry picked from commit c40b5193fe
)
This commit is contained in:
11
cc/cc.go
11
cc/cc.go
@@ -1909,8 +1909,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
|
||||
@@ -1920,7 +1919,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{
|
||||
@@ -2318,7 +2317,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)
|
||||
|
||||
@@ -2334,8 +2333,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
|
||||
}
|
||||
|
@@ -1528,10 +1528,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()
|
||||
checkVersions(mctx, versions)
|
||||
@@ -1567,7 +1575,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
|
||||
}
|
||||
|
@@ -39,6 +39,8 @@ type LinkableInterface interface {
|
||||
Shared() bool
|
||||
Toc() android.OptionalPath
|
||||
|
||||
Host() bool
|
||||
|
||||
InRamdisk() bool
|
||||
OnlyInRamdisk() bool
|
||||
|
||||
|
@@ -735,13 +735,14 @@ func (mod *Module) DepsMutator(actx android.BottomUpMutatorContext) {
|
||||
|
||||
deps := mod.deps(ctx)
|
||||
commonDepVariations := []blueprint.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"},
|
||||
|
Reference in New Issue
Block a user