Revert "Fix non-determinism in prebuilt selection"

This reverts commit 2d8884a377.

Reason for revert: Build breakage https://groups.google.com/a/google.com/g/android-build-police-core/c/00mM-B9unVg/m/0FxBxpMbAwAJ. The validation does not check for namespace isolation which breaks libtonemap

Change-Id: Ieb4d3bc4f3ade856877ebb62a567620f5a1ed08c
This commit is contained in:
Spandan Das
2024-02-29 08:22:47 +00:00
parent 2d8884a377
commit af66212522
3 changed files with 3 additions and 120 deletions

View File

@@ -534,31 +534,6 @@ func hideUnflaggedModules(ctx BottomUpMutatorContext, psi PrebuiltSelectionInfoM
for _, moduleInFamily := range allModulesInFamily {
if moduleInFamily.Name() != selectedModuleInFamily.Name() {
moduleInFamily.HideFromMake()
// If this is a prebuilt module, unset properties.UsePrebuilt
// properties.UsePrebuilt might evaluate to true via soong config var fallback mechanism
// Set it to false explicitly so that the following mutator does not replace rdeps to this unselected prebuilt
if p := GetEmbeddedPrebuilt(moduleInFamily); p != nil {
p.properties.UsePrebuilt = false
}
}
}
}
// Do a validation pass to make sure that multiple prebuilts of a specific module are not selected.
// This might happen if the prebuilts share the same soong config var namespace.
// This should be an error, unless one of the prebuilts has been explicitly declared in apex_contributions
var selectedPrebuilt Module
for _, moduleInFamily := range allModulesInFamily {
// Skip for the top-level java_sdk_library_(_import). This has some special cases that need to be addressed first.
// This does not run into non-determinism because PrebuiltPostDepsMutator also has the special case
if sdkLibrary, ok := moduleInFamily.(interface{ SdkLibraryName() *string }); ok && sdkLibrary.SdkLibraryName() != nil {
continue
}
if p := GetEmbeddedPrebuilt(moduleInFamily); p != nil && p.properties.UsePrebuilt {
if selectedPrebuilt == nil {
selectedPrebuilt = moduleInFamily
} else {
ctx.ModuleErrorf("Multiple prebuilt modules %v and %v have been marked as preferred for this source module. "+
"Please add the appropriate prebuilt module to apex_contributions for this release config.", selectedPrebuilt.Name(), moduleInFamily.Name())
}
}
}
@@ -587,7 +562,7 @@ func PrebuiltPostDepsMutator(ctx BottomUpMutatorContext) {
// If we do not special-case this here, rdeps referring to a java_sdk_library in next builds via libs
// will get prebuilt stubs
// TODO (b/308187268): Remove this after the apexes have been added to apex_contributions
if psi.IsSelected(name) {
if psi.IsSelected(*sdkLibrary.SdkLibraryName()) {
return false
}
}