Merge "Remove version_selector mutator" am: 7f5b4e3229

Original change: https://android-review.googlesource.com/c/platform/build/soong/+/2060089

Change-Id: If6a21b33e7fcf3c9732b0220a15018114c9b5603
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
Treehugger Robot
2022-05-03 05:22:48 +00:00
committed by Automerger Merge Worker
2 changed files with 28 additions and 26 deletions

View File

@@ -48,7 +48,6 @@ func RegisterCCBuildComponents(ctx android.RegistrationContext) {
ctx.BottomUp("vndk", VndkMutator).Parallel()
ctx.BottomUp("link", LinkageMutator).Parallel()
ctx.BottomUp("test_per_src", TestPerSrcMutator).Parallel()
ctx.BottomUp("version_selector", versionSelectorMutator).Parallel()
ctx.BottomUp("version", versionMutator).Parallel()
ctx.BottomUp("begin", BeginMutator).Parallel()
ctx.BottomUp("sysprop_cc", SyspropMutator).Parallel()
@@ -2117,7 +2116,7 @@ func AddSharedLibDependenciesWithVersions(ctx android.BottomUpMutatorContext, mo
variations = append([]blueprint.Variation(nil), variations...)
if version != "" && CanBeOrLinkAgainstVersionVariants(mod) {
if version != "" && canBeOrLinkAgainstVersionVariants(mod) {
// Version is explicitly specified. i.e. libFoo#30
variations = append(variations, blueprint.Variation{Mutator: "version", Variation: version})
if tag, ok := depTag.(libraryDependencyTag); ok {

View File

@@ -2344,7 +2344,7 @@ func createPerApiVersionVariations(mctx android.BottomUpMutatorContext, minSdkVe
}
}
func CanBeOrLinkAgainstVersionVariants(module interface {
func canBeOrLinkAgainstVersionVariants(module interface {
Host() bool
InRamdisk() bool
InVendorRamdisk() bool
@@ -2352,15 +2352,14 @@ func CanBeOrLinkAgainstVersionVariants(module interface {
return !module.Host() && !module.InRamdisk() && !module.InVendorRamdisk()
}
func CanBeVersionVariant(module interface {
func canBeVersionVariant(module interface {
Host() bool
InRamdisk() bool
InVendorRamdisk() bool
InRecovery() bool
CcLibraryInterface() bool
Shared() bool
}) bool {
return CanBeOrLinkAgainstVersionVariants(module) &&
return canBeOrLinkAgainstVersionVariants(module) &&
module.CcLibraryInterface() && module.Shared()
}
@@ -2371,37 +2370,41 @@ func moduleLibraryInterface(module blueprint.Module) libraryInterface {
return nil
}
// versionSelector normalizes the versions in the Stubs.Versions property into MutatedProperties.AllStubsVersions.
func versionSelectorMutator(mctx android.BottomUpMutatorContext) {
if library := moduleLibraryInterface(mctx.Module()); library != nil && CanBeVersionVariant(mctx.Module().(*Module)) {
if library.buildShared() {
versions := library.stubsVersions(mctx)
if len(versions) > 0 {
normalizeVersions(mctx, versions)
if mctx.Failed() {
return
}
// Set the versions on the pre-mutated module so they can be read by any llndk modules that
// depend on the implementation library and haven't been mutated yet.
library.setAllStubsVersions(versions)
}
}
// setStubsVersions normalizes the versions in the Stubs.Versions property into MutatedProperties.AllStubsVersions.
func setStubsVersions(mctx android.BottomUpMutatorContext, library libraryInterface, module *Module) {
if !library.buildShared() || !canBeVersionVariant(module) {
return
}
versions := library.stubsVersions(mctx)
if len(versions) <= 0 {
return
}
normalizeVersions(mctx, versions)
if mctx.Failed() {
return
}
// Set the versions on the pre-mutated module so they can be read by any llndk modules that
// depend on the implementation library and haven't been mutated yet.
library.setAllStubsVersions(versions)
}
// 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 := moduleLibraryInterface(mctx.Module()); library != nil && CanBeVersionVariant(mctx.Module().(*Module)) {
if mctx.Os() != android.Android {
return
}
m, ok := mctx.Module().(*Module)
if library := moduleLibraryInterface(mctx.Module()); library != nil && canBeVersionVariant(m) {
setStubsVersions(mctx, library, m)
createVersionVariations(mctx, library.allStubsVersions())
return
}
if m, ok := mctx.Module().(*Module); ok {
if ok {
if m.SplitPerApiLevel() && m.IsSdkVariant() {
if mctx.Os() != android.Android {
return
}
createPerApiVersionVariations(mctx, m.MinSdkVersion())
}
}