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) {
|
addSharedLibDependencies := func(depTag DependencyTag, name string, version string) {
|
||||||
var variations []blueprint.Variation
|
var variations []blueprint.Variation
|
||||||
variations = append(variations, blueprint.Variation{Mutator: "link", Variation: "shared"})
|
variations = append(variations, blueprint.Variation{Mutator: "link", Variation: "shared"})
|
||||||
versionVariantAvail := !c.InRecovery() && !c.InRamdisk()
|
if version != "" && VersionVariantAvailable(c) {
|
||||||
if version != "" && versionVariantAvail {
|
|
||||||
// Version is explicitly specified. i.e. libFoo#30
|
// Version is explicitly specified. i.e. libFoo#30
|
||||||
variations = append(variations, blueprint.Variation{Mutator: "version", Variation: version})
|
variations = append(variations, blueprint.Variation{Mutator: "version", Variation: version})
|
||||||
depTag.ExplicitlyVersioned = true
|
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.
|
// 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 stubs library will be used when the depending module is built for APEX and
|
||||||
// the dependent module is not in the same APEX.
|
// the dependent module is not in the same APEX.
|
||||||
if version == "" && versionVariantAvail {
|
if version == "" && VersionVariantAvailable(c) {
|
||||||
for _, ver := range stubsVersionsFor(actx.Config())[name] {
|
for _, ver := range stubsVersionsFor(actx.Config())[name] {
|
||||||
// Note that depTag.ExplicitlyVersioned is false in this case.
|
// Note that depTag.ExplicitlyVersioned is false in this case.
|
||||||
actx.AddVariationDependencies([]blueprint.Variation{
|
actx.AddVariationDependencies([]blueprint.Variation{
|
||||||
@@ -2318,7 +2317,7 @@ func (c *Module) depsToPaths(ctx android.ModuleContext) PathDeps {
|
|||||||
}
|
}
|
||||||
if ccDep.CcLibrary() && !depIsStatic {
|
if ccDep.CcLibrary() && !depIsStatic {
|
||||||
depIsStubs := ccDep.BuildStubs()
|
depIsStubs := ccDep.BuildStubs()
|
||||||
depHasStubs := ccDep.HasStubsVariants()
|
depHasStubs := VersionVariantAvailable(c) && ccDep.HasStubsVariants()
|
||||||
depInSameApex := android.DirectlyInApex(c.ApexName(), depName)
|
depInSameApex := android.DirectlyInApex(c.ApexName(), depName)
|
||||||
depInPlatform := !android.DirectlyInAnyApex(ctx, 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
|
// If not building for APEX, use stubs only when it is from
|
||||||
// an APEX (and not from platform)
|
// an APEX (and not from platform)
|
||||||
useThisDep = (depInPlatform != depIsStubs)
|
useThisDep = (depInPlatform != depIsStubs)
|
||||||
if c.InRamdisk() || c.InRecovery() || c.bootstrap() {
|
if c.bootstrap() {
|
||||||
// However, for ramdisk, recovery or bootstrap modules,
|
// However, for host, ramdisk, recovery or bootstrap modules,
|
||||||
// always link to non-stub variant
|
// always link to non-stub variant
|
||||||
useThisDep = !depIsStubs
|
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.
|
// (which is unnamed) and zero or more stubs variants.
|
||||||
func VersionMutator(mctx android.BottomUpMutatorContext) {
|
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 {
|
if library.CcLibrary() && library.BuildSharedVariant() && len(library.StubsVersions()) > 0 {
|
||||||
versions := library.StubsVersions()
|
versions := library.StubsVersions()
|
||||||
checkVersions(mctx, versions)
|
checkVersions(mctx, versions)
|
||||||
@@ -1567,7 +1575,7 @@ func VersionMutator(mctx android.BottomUpMutatorContext) {
|
|||||||
}
|
}
|
||||||
if genrule, ok := mctx.Module().(*genrule.Module); ok {
|
if genrule, ok := mctx.Module().(*genrule.Module); ok {
|
||||||
if _, ok := genrule.Extra.(*GenruleExtraProperties); ok {
|
if _, ok := genrule.Extra.(*GenruleExtraProperties); ok {
|
||||||
if !genrule.InRecovery() {
|
if VersionVariantAvailable(genrule) {
|
||||||
mctx.CreateVariations("")
|
mctx.CreateVariations("")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@@ -39,6 +39,8 @@ type LinkableInterface interface {
|
|||||||
Shared() bool
|
Shared() bool
|
||||||
Toc() android.OptionalPath
|
Toc() android.OptionalPath
|
||||||
|
|
||||||
|
Host() bool
|
||||||
|
|
||||||
InRamdisk() bool
|
InRamdisk() bool
|
||||||
OnlyInRamdisk() bool
|
OnlyInRamdisk() bool
|
||||||
|
|
||||||
|
@@ -735,13 +735,14 @@ func (mod *Module) DepsMutator(actx android.BottomUpMutatorContext) {
|
|||||||
|
|
||||||
deps := mod.deps(ctx)
|
deps := mod.deps(ctx)
|
||||||
commonDepVariations := []blueprint.Variation{}
|
commonDepVariations := []blueprint.Variation{}
|
||||||
|
if cc.VersionVariantAvailable(mod) {
|
||||||
commonDepVariations = append(commonDepVariations,
|
commonDepVariations = append(commonDepVariations,
|
||||||
blueprint.Variation{Mutator: "version", Variation: ""})
|
blueprint.Variation{Mutator: "version", Variation: ""})
|
||||||
|
}
|
||||||
if !mod.Host() {
|
if !mod.Host() {
|
||||||
commonDepVariations = append(commonDepVariations,
|
commonDepVariations = append(commonDepVariations,
|
||||||
blueprint.Variation{Mutator: "image", Variation: android.CoreVariation})
|
blueprint.Variation{Mutator: "image", Variation: android.CoreVariation})
|
||||||
}
|
}
|
||||||
|
|
||||||
actx.AddVariationDependencies(
|
actx.AddVariationDependencies(
|
||||||
append(commonDepVariations, []blueprint.Variation{
|
append(commonDepVariations, []blueprint.Variation{
|
||||||
{Mutator: "rust_libraries", Variation: "rlib"},
|
{Mutator: "rust_libraries", Variation: "rlib"},
|
||||||
|
Reference in New Issue
Block a user