Merge "Rename release_variable to release_flag in selects" into main
diff --git a/android/config.go b/android/config.go
index f6711e6..76c590a 100644
--- a/android/config.go
+++ b/android/config.go
@@ -2109,6 +2109,7 @@
"RELEASE_APEX_CONTRIBUTIONS_NEURALNETWORKS",
"RELEASE_APEX_CONTRIBUTIONS_ONDEVICEPERSONALIZATION",
"RELEASE_APEX_CONTRIBUTIONS_PERMISSION",
+ "RELEASE_APEX_CONTRIBUTIONS_PRIMARY_LIBS",
"RELEASE_APEX_CONTRIBUTIONS_REMOTEKEYPROVISIONING",
"RELEASE_APEX_CONTRIBUTIONS_RESOLV",
"RELEASE_APEX_CONTRIBUTIONS_SCHEDULING",
diff --git a/android/override_module.go b/android/override_module.go
index 55f384f..21cf381 100644
--- a/android/override_module.go
+++ b/android/override_module.go
@@ -28,7 +28,6 @@
// module based on it.
import (
- "fmt"
"sort"
"sync"
@@ -121,7 +120,7 @@
addOverride(o OverrideModule)
getOverrides() []OverrideModule
- override(ctx BaseModuleContext, bm OverridableModule, o OverrideModule)
+ override(ctx BaseModuleContext, m Module, o OverrideModule)
GetOverriddenBy() string
GetOverriddenByModuleDir() string
@@ -192,14 +191,15 @@
}
// Overrides a base module with the given OverrideModule.
-func (b *OverridableModuleBase) override(ctx BaseModuleContext, bm OverridableModule, o OverrideModule) {
+func (b *OverridableModuleBase) override(ctx BaseModuleContext, m Module, o OverrideModule) {
+
for _, p := range b.overridableProperties {
for _, op := range o.getOverridingProperties() {
if proptools.TypeEqual(p, op) {
err := proptools.ExtendProperties(p, op, nil, proptools.OrderReplace)
if err != nil {
if propertyErr, ok := err.(*proptools.ExtendPropertyError); ok {
- ctx.OtherModulePropertyErrorf(bm, propertyErr.Property, "%s", propertyErr.Err.Error())
+ ctx.PropertyErrorf(propertyErr.Property, "%s", propertyErr.Err.Error())
} else {
panic(err)
}
@@ -210,7 +210,7 @@
// Adds the base module to the overrides property, if exists, of the overriding module. See the
// comment on OverridableModuleBase.overridesProperty for details.
if b.overridesProperty != nil {
- *b.overridesProperty = append(*b.overridesProperty, ctx.OtherModuleName(bm))
+ *b.overridesProperty = append(*b.overridesProperty, ctx.ModuleName())
}
b.overridableModuleProperties.OverriddenBy = o.Name()
b.overridableModuleProperties.OverriddenByModuleDir = o.ModuleDir()
@@ -235,7 +235,7 @@
// to keep them in this order and not put any order mutators between them.
func RegisterOverridePostDepsMutators(ctx RegisterMutatorsContext) {
ctx.BottomUp("override_deps", overrideModuleDepsMutator).Parallel()
- ctx.Transition("override", &overrideTransitionMutator{})
+ ctx.BottomUp("perform_override", performOverrideMutator).Parallel()
// overridableModuleDepsMutator calls OverridablePropertiesDepsMutator so that overridable modules can
// add deps from overridable properties.
ctx.BottomUp("overridable_deps", overridableModuleDepsMutator).Parallel()
@@ -262,6 +262,18 @@
ctx.PropertyErrorf("base", "%q is not a valid module name", base)
return
}
+ // See if there's a prebuilt module that overrides this override module with prefer flag,
+ // in which case we call HideFromMake on the corresponding variant later.
+ ctx.VisitDirectDepsWithTag(PrebuiltDepTag, func(dep Module) {
+ prebuilt := GetEmbeddedPrebuilt(dep)
+ if prebuilt == nil {
+ panic("PrebuiltDepTag leads to a non-prebuilt module " + dep.Name())
+ }
+ if prebuilt.UsePrebuilt() {
+ module.setOverriddenByPrebuilt(dep)
+ return
+ }
+ })
baseModule := ctx.AddDependency(ctx.Module(), overrideBaseDepTag, *module.getOverrideModuleProperties().Base)[0]
if o, ok := baseModule.(OverridableModule); ok {
overrideModule := ctx.Module().(OverrideModule)
@@ -273,13 +285,11 @@
// Now, goes through all overridable modules, finds all modules overriding them, creates a local
// variant for each of them, and performs the actual overriding operation by calling override().
-type overrideTransitionMutator struct{}
-
-func (overrideTransitionMutator) Split(ctx BaseModuleContext) []string {
+func performOverrideMutator(ctx BottomUpMutatorContext) {
if b, ok := ctx.Module().(OverridableModule); ok {
overrides := b.getOverrides()
if len(overrides) == 0 {
- return []string{""}
+ return
}
variants := make([]string, len(overrides)+1)
// The first variant is for the original, non-overridden, base module.
@@ -287,69 +297,27 @@
for i, o := range overrides {
variants[i+1] = o.(Module).Name()
}
- return variants
+ mods := ctx.CreateLocalVariations(variants...)
+ // Make the original variation the default one to depend on if no other override module variant
+ // is specified.
+ ctx.AliasVariation(variants[0])
+ for i, o := range overrides {
+ mods[i+1].(OverridableModule).override(ctx, mods[i+1], o)
+ if prebuilt := o.getOverriddenByPrebuilt(); prebuilt != nil {
+ // The overriding module itself, too, is overridden by a prebuilt.
+ // Perform the same check for replacement
+ checkInvariantsForSourceAndPrebuilt(ctx, mods[i+1], prebuilt)
+ // Copy the flag and hide it in make
+ mods[i+1].ReplacedByPrebuilt()
+ }
+ }
} else if o, ok := ctx.Module().(OverrideModule); ok {
// Create a variant of the overriding module with its own name. This matches the above local
// variant name rule for overridden modules, and thus allows ReplaceDependencies to match the
// two.
- return []string{o.Name()}
- }
-
- return []string{""}
-}
-
-func (overrideTransitionMutator) OutgoingTransition(ctx OutgoingTransitionContext, sourceVariation string) string {
- if o, ok := ctx.Module().(OverrideModule); ok {
- if ctx.DepTag() == overrideBaseDepTag {
- return o.Name()
- }
- }
-
- // Variations are always local and shouldn't affect the variant used for dependencies
- return ""
-}
-
-func (overrideTransitionMutator) IncomingTransition(ctx IncomingTransitionContext, incomingVariation string) string {
- if _, ok := ctx.Module().(OverridableModule); ok {
- return incomingVariation
- } else if o, ok := ctx.Module().(OverrideModule); ok {
- // To allow dependencies to be added without having to know the variation.
- return o.Name()
- }
-
- return ""
-}
-
-func (overrideTransitionMutator) Mutate(ctx BottomUpMutatorContext, variation string) {
- if o, ok := ctx.Module().(OverrideModule); ok {
- overridableDeps := ctx.GetDirectDepsWithTag(overrideBaseDepTag)
- if len(overridableDeps) > 1 {
- panic(fmt.Errorf("expected a single dependency with overrideBaseDepTag, found %q", overridableDeps))
- } else if len(overridableDeps) == 1 {
- b := overridableDeps[0].(OverridableModule)
- b.override(ctx, b, o)
-
- checkPrebuiltReplacesOverride(ctx, b)
- }
- }
-}
-
-func checkPrebuiltReplacesOverride(ctx BottomUpMutatorContext, b OverridableModule) {
- // See if there's a prebuilt module that overrides this override module with prefer flag,
- // in which case we call HideFromMake on the corresponding variant later.
- prebuiltDeps := ctx.GetDirectDepsWithTag(PrebuiltDepTag)
- for _, prebuiltDep := range prebuiltDeps {
- prebuilt := GetEmbeddedPrebuilt(prebuiltDep)
- if prebuilt == nil {
- panic("PrebuiltDepTag leads to a non-prebuilt module " + prebuiltDep.Name())
- }
- if prebuilt.UsePrebuilt() {
- // The overriding module itself, too, is overridden by a prebuilt.
- // Perform the same check for replacement
- checkInvariantsForSourceAndPrebuilt(ctx, b, prebuiltDep)
- // Copy the flag and hide it in make
- b.ReplacedByPrebuilt()
- }
+ ctx.CreateLocalVariations(o.Name())
+ // To allow dependencies to be added without having to know the above variation.
+ ctx.AliasVariation(o.Name())
}
}
diff --git a/cmd/release_config/crunch_flags/main.go b/cmd/release_config/crunch_flags/main.go
index 4d763c8..cd39ffd 100644
--- a/cmd/release_config/crunch_flags/main.go
+++ b/cmd/release_config/crunch_flags/main.go
@@ -137,7 +137,9 @@
workflow := rc_proto.Workflow(rc_proto.Workflow_PREBUILT)
switch {
case declName == "RELEASE_ACONFIG_VALUE_SETS":
- rootAconfigModule = declValue[1 : len(declValue)-1]
+ if strings.HasPrefix(declValue, "\"") {
+ rootAconfigModule = declValue[1 : len(declValue)-1]
+ }
continue
case strings.HasPrefix(declValue, "\""):
// String values mean that the flag workflow is (most likely) either MANUAL or PREBUILT.
diff --git a/python/python.go b/python/python.go
index e14fdf3..1ee533f 100644
--- a/python/python.go
+++ b/python/python.go
@@ -506,8 +506,8 @@
}
for _, d := range expandedData {
- if d.Ext() == pyExt || d.Ext() == protoExt {
- ctx.PropertyErrorf("data", "found (.py|.proto) file: %q!", d.String())
+ if d.Ext() == pyExt {
+ ctx.PropertyErrorf("data", "found (.py) file: %q!", d.String())
continue
}
runfilesPath := filepath.Join(pkgPath, d.Rel())
@@ -523,19 +523,19 @@
relativeRootMap := make(map[string]android.Paths)
var protoSrcs android.Paths
addPathMapping := func(path pathMapping) {
- // handle proto sources separately
- if path.src.Ext() == protoExt {
- protoSrcs = append(protoSrcs, path.src)
- } else {
- relativeRoot := strings.TrimSuffix(path.src.String(), path.src.Rel())
- relativeRootMap[relativeRoot] = append(relativeRootMap[relativeRoot], path.src)
- }
+ relativeRoot := strings.TrimSuffix(path.src.String(), path.src.Rel())
+ relativeRootMap[relativeRoot] = append(relativeRootMap[relativeRoot], path.src)
}
// "srcs" or "data" properties may contain filegroups so it might happen that
// the root directory for each source path is different.
for _, path := range p.srcsPathMappings {
- addPathMapping(path)
+ // handle proto sources separately
+ if path.src.Ext() == protoExt {
+ protoSrcs = append(protoSrcs, path.src)
+ } else {
+ addPathMapping(path)
+ }
}
for _, path := range p.dataPathMappings {
addPathMapping(path)
diff --git a/python/python_test.go b/python/python_test.go
index c0b7295..6a6bd1d 100644
--- a/python/python_test.go
+++ b/python/python_test.go
@@ -50,7 +50,7 @@
" Second file: in module %s at path %q."
noSrcFileErr = moduleVariantErrTemplate + "doesn't have any source files!"
badSrcFileExtErr = moduleVariantErrTemplate + "srcs: found non (.py|.proto) file: %q!"
- badDataFileExtErr = moduleVariantErrTemplate + "data: found (.py|.proto) file: %q!"
+ badDataFileExtErr = moduleVariantErrTemplate + "data: found (.py) file: %q!"
bpFile = "Android.bp"
data = []struct {