Loading android/defaults.go +2 −2 Original line number Diff line number Diff line Loading @@ -273,8 +273,8 @@ func (defaultable *DefaultableModuleBase) applyDefaultProperties(ctx BottomUpMut } func RegisterDefaultsPreArchMutators(ctx RegisterMutatorsContext) { ctx.BottomUp("defaults_deps", defaultsDepsMutator).Parallel() ctx.BottomUp("defaults", defaultsMutator).Parallel().UsesCreateModule() ctx.BottomUp("defaults_deps", defaultsDepsMutator) ctx.BottomUp("defaults", defaultsMutator).UsesCreateModule() } func defaultsDepsMutator(ctx BottomUpMutatorContext) { Loading android/licenses.go +3 −3 Original line number Diff line number Diff line Loading @@ -106,19 +106,19 @@ func moduleToPackageDefaultLicensesMap(config Config) *sync.Map { // // This goes before defaults expansion so the defaults can pick up the package default. func RegisterLicensesPackageMapper(ctx RegisterMutatorsContext) { ctx.BottomUp("licensesPackageMapper", licensesPackageMapper).Parallel() ctx.BottomUp("licensesPackageMapper", licensesPackageMapper) } // Registers the function that gathers the license dependencies for each module. // // This goes after defaults expansion so that it can pick up default licenses and before visibility enforcement. func RegisterLicensesPropertyGatherer(ctx RegisterMutatorsContext) { ctx.BottomUp("licensesPropertyGatherer", licensesPropertyGatherer).Parallel() ctx.BottomUp("licensesPropertyGatherer", licensesPropertyGatherer) } // Registers the function that verifies the licenses and license_kinds dependency types for each module. func RegisterLicensesDependencyChecker(ctx RegisterMutatorsContext) { ctx.BottomUp("licensesPropertyChecker", licensesDependencyChecker).Parallel() ctx.BottomUp("licensesPropertyChecker", licensesDependencyChecker) } // Maps each package to its default applicable licenses. Loading android/mutator.go +6 −18 Original line number Diff line number Diff line Loading @@ -211,10 +211,7 @@ type BottomUpMutatorContext interface { // AddDependency adds a dependency to the given module. It returns a slice of modules for each // dependency (some entries may be nil). // // If the mutator is parallel (see MutatorHandle.Parallel), this method will pause until the // new dependencies have had the current mutator called on them. If the mutator is not // parallel this method does not affect the ordering of the current mutator pass, but will // be ordered correctly for all future mutator passes. // This method will pause until the new dependencies have had the current mutator called on them. AddDependency(module blueprint.Module, tag blueprint.DependencyTag, name ...string) []blueprint.Module // AddReverseDependency adds a dependency from the destination to the given module. Loading @@ -230,10 +227,7 @@ type BottomUpMutatorContext interface { // each dependency (some entries may be nil). A variant of the dependency must exist that matches // all the non-local variations of the current module, plus the variations argument. // // If the mutator is parallel (see MutatorHandle.Parallel), this method will pause until the // new dependencies have had the current mutator called on them. If the mutator is not // parallel this method does not affect the ordering of the current mutator pass, but will // be ordered correctly for all future mutator passes. // This method will pause until the new dependencies have had the current mutator called on them. AddVariationDependencies(variations []blueprint.Variation, tag blueprint.DependencyTag, names ...string) []blueprint.Module // AddReverseVariationDependency adds a dependency from the named module to the current Loading @@ -256,10 +250,7 @@ type BottomUpMutatorContext interface { // Unlike AddVariationDependencies, the variations of the current module are ignored - the // dependency only needs to match the supplied variations. // // If the mutator is parallel (see MutatorHandle.Parallel), this method will pause until the // new dependencies have had the current mutator called on them. If the mutator is not // parallel this method does not affect the ordering of the current mutator pass, but will // be ordered correctly for all future mutator passes. // This method will pause until the new dependencies have had the current mutator called on them. AddFarVariationDependencies([]blueprint.Variation, blueprint.DependencyTag, ...string) []blueprint.Module // ReplaceDependencies finds all the variants of the module with the specified name, then Loading Loading @@ -628,9 +619,6 @@ func (mutator *mutator) register(ctx *Context) { } // Forward booleans set on the MutatorHandle to the blueprint.MutatorHandle. if mutator.parallel { handle.Parallel() } if mutator.usesRename { handle.UsesRename() } Loading @@ -655,6 +643,7 @@ type MutatorHandle interface { // Parallel sets the mutator to visit modules in parallel while maintaining ordering. Calling any // method on the mutator context is thread-safe, but the mutator must handle synchronization // for any modifications to global state or any modules outside the one it was invoked on. // Deprecated: all Mutators are parallel by default. Parallel() MutatorHandle // UsesRename marks the mutator as using the BottomUpMutatorContext.Rename method, which prevents Loading Loading @@ -683,7 +672,6 @@ type MutatorHandle interface { } func (mutator *mutator) Parallel() MutatorHandle { mutator.parallel = true return mutator } Loading Loading @@ -718,7 +706,7 @@ func (mutator *mutator) MutatesGlobalState() MutatorHandle { } func RegisterComponentsMutator(ctx RegisterMutatorsContext) { ctx.BottomUp("component-deps", componentDepsMutator).Parallel() ctx.BottomUp("component-deps", componentDepsMutator) } // A special mutator that runs just prior to the deps mutator to allow the dependencies Loading @@ -736,7 +724,7 @@ func depsMutator(ctx BottomUpMutatorContext) { } func registerDepsMutator(ctx RegisterMutatorsContext) { ctx.BottomUp("deps", depsMutator).Parallel().UsesReverseDependencies() ctx.BottomUp("deps", depsMutator).UsesReverseDependencies() } // android.topDownMutatorContext either has to embed blueprint.TopDownMutatorContext, in which case every method that Loading android/mutator_test.go +14 −4 Original line number Diff line number Diff line Loading @@ -17,6 +17,8 @@ package android import ( "fmt" "strings" "sync" "sync/atomic" "testing" "github.com/google/blueprint" Loading Loading @@ -220,7 +222,7 @@ func TestFinalDepsPhase(t *testing.T) { } ` finalGot := map[string]int{} finalGot := sync.Map{} GroupFixturePreparers( FixtureRegisterWithContext(func(ctx RegistrationContext) { Loading Loading @@ -251,9 +253,11 @@ func TestFinalDepsPhase(t *testing.T) { } }) ctx.BottomUp("final", func(ctx BottomUpMutatorContext) { finalGot[ctx.Module().String()] += 1 counter, _ := finalGot.LoadOrStore(ctx.Module().String(), &atomic.Int64{}) counter.(*atomic.Int64).Add(1) ctx.VisitDirectDeps(func(mod Module) { finalGot[fmt.Sprintf("%s -> %s", ctx.Module().String(), mod)] += 1 counter, _ := finalGot.LoadOrStore(fmt.Sprintf("%s -> %s", ctx.Module().String(), mod), &atomic.Int64{}) counter.(*atomic.Int64).Add(1) }) }) }) Loading @@ -276,7 +280,13 @@ func TestFinalDepsPhase(t *testing.T) { "foo{variant:b} -> common_dep_2{variant:a}": 1, } AssertDeepEquals(t, "final", finalWant, finalGot) finalGotMap := make(map[string]int) finalGot.Range(func(k, v any) bool { finalGotMap[k.(string)] = int(v.(*atomic.Int64).Load()) return true }) AssertDeepEquals(t, "final", finalWant, finalGotMap) } func TestTransitionMutatorInFinalDeps(t *testing.T) { Loading android/namespace.go +1 −1 Original line number Diff line number Diff line Loading @@ -457,7 +457,7 @@ func NamespaceFactory() Module { } func RegisterNamespaceMutator(ctx RegisterMutatorsContext) { ctx.BottomUp("namespace_deps", namespaceMutator).Parallel().MutatesGlobalState() ctx.BottomUp("namespace_deps", namespaceMutator).MutatesGlobalState() } func namespaceMutator(ctx BottomUpMutatorContext) { Loading Loading
android/defaults.go +2 −2 Original line number Diff line number Diff line Loading @@ -273,8 +273,8 @@ func (defaultable *DefaultableModuleBase) applyDefaultProperties(ctx BottomUpMut } func RegisterDefaultsPreArchMutators(ctx RegisterMutatorsContext) { ctx.BottomUp("defaults_deps", defaultsDepsMutator).Parallel() ctx.BottomUp("defaults", defaultsMutator).Parallel().UsesCreateModule() ctx.BottomUp("defaults_deps", defaultsDepsMutator) ctx.BottomUp("defaults", defaultsMutator).UsesCreateModule() } func defaultsDepsMutator(ctx BottomUpMutatorContext) { Loading
android/licenses.go +3 −3 Original line number Diff line number Diff line Loading @@ -106,19 +106,19 @@ func moduleToPackageDefaultLicensesMap(config Config) *sync.Map { // // This goes before defaults expansion so the defaults can pick up the package default. func RegisterLicensesPackageMapper(ctx RegisterMutatorsContext) { ctx.BottomUp("licensesPackageMapper", licensesPackageMapper).Parallel() ctx.BottomUp("licensesPackageMapper", licensesPackageMapper) } // Registers the function that gathers the license dependencies for each module. // // This goes after defaults expansion so that it can pick up default licenses and before visibility enforcement. func RegisterLicensesPropertyGatherer(ctx RegisterMutatorsContext) { ctx.BottomUp("licensesPropertyGatherer", licensesPropertyGatherer).Parallel() ctx.BottomUp("licensesPropertyGatherer", licensesPropertyGatherer) } // Registers the function that verifies the licenses and license_kinds dependency types for each module. func RegisterLicensesDependencyChecker(ctx RegisterMutatorsContext) { ctx.BottomUp("licensesPropertyChecker", licensesDependencyChecker).Parallel() ctx.BottomUp("licensesPropertyChecker", licensesDependencyChecker) } // Maps each package to its default applicable licenses. Loading
android/mutator.go +6 −18 Original line number Diff line number Diff line Loading @@ -211,10 +211,7 @@ type BottomUpMutatorContext interface { // AddDependency adds a dependency to the given module. It returns a slice of modules for each // dependency (some entries may be nil). // // If the mutator is parallel (see MutatorHandle.Parallel), this method will pause until the // new dependencies have had the current mutator called on them. If the mutator is not // parallel this method does not affect the ordering of the current mutator pass, but will // be ordered correctly for all future mutator passes. // This method will pause until the new dependencies have had the current mutator called on them. AddDependency(module blueprint.Module, tag blueprint.DependencyTag, name ...string) []blueprint.Module // AddReverseDependency adds a dependency from the destination to the given module. Loading @@ -230,10 +227,7 @@ type BottomUpMutatorContext interface { // each dependency (some entries may be nil). A variant of the dependency must exist that matches // all the non-local variations of the current module, plus the variations argument. // // If the mutator is parallel (see MutatorHandle.Parallel), this method will pause until the // new dependencies have had the current mutator called on them. If the mutator is not // parallel this method does not affect the ordering of the current mutator pass, but will // be ordered correctly for all future mutator passes. // This method will pause until the new dependencies have had the current mutator called on them. AddVariationDependencies(variations []blueprint.Variation, tag blueprint.DependencyTag, names ...string) []blueprint.Module // AddReverseVariationDependency adds a dependency from the named module to the current Loading @@ -256,10 +250,7 @@ type BottomUpMutatorContext interface { // Unlike AddVariationDependencies, the variations of the current module are ignored - the // dependency only needs to match the supplied variations. // // If the mutator is parallel (see MutatorHandle.Parallel), this method will pause until the // new dependencies have had the current mutator called on them. If the mutator is not // parallel this method does not affect the ordering of the current mutator pass, but will // be ordered correctly for all future mutator passes. // This method will pause until the new dependencies have had the current mutator called on them. AddFarVariationDependencies([]blueprint.Variation, blueprint.DependencyTag, ...string) []blueprint.Module // ReplaceDependencies finds all the variants of the module with the specified name, then Loading Loading @@ -628,9 +619,6 @@ func (mutator *mutator) register(ctx *Context) { } // Forward booleans set on the MutatorHandle to the blueprint.MutatorHandle. if mutator.parallel { handle.Parallel() } if mutator.usesRename { handle.UsesRename() } Loading @@ -655,6 +643,7 @@ type MutatorHandle interface { // Parallel sets the mutator to visit modules in parallel while maintaining ordering. Calling any // method on the mutator context is thread-safe, but the mutator must handle synchronization // for any modifications to global state or any modules outside the one it was invoked on. // Deprecated: all Mutators are parallel by default. Parallel() MutatorHandle // UsesRename marks the mutator as using the BottomUpMutatorContext.Rename method, which prevents Loading Loading @@ -683,7 +672,6 @@ type MutatorHandle interface { } func (mutator *mutator) Parallel() MutatorHandle { mutator.parallel = true return mutator } Loading Loading @@ -718,7 +706,7 @@ func (mutator *mutator) MutatesGlobalState() MutatorHandle { } func RegisterComponentsMutator(ctx RegisterMutatorsContext) { ctx.BottomUp("component-deps", componentDepsMutator).Parallel() ctx.BottomUp("component-deps", componentDepsMutator) } // A special mutator that runs just prior to the deps mutator to allow the dependencies Loading @@ -736,7 +724,7 @@ func depsMutator(ctx BottomUpMutatorContext) { } func registerDepsMutator(ctx RegisterMutatorsContext) { ctx.BottomUp("deps", depsMutator).Parallel().UsesReverseDependencies() ctx.BottomUp("deps", depsMutator).UsesReverseDependencies() } // android.topDownMutatorContext either has to embed blueprint.TopDownMutatorContext, in which case every method that Loading
android/mutator_test.go +14 −4 Original line number Diff line number Diff line Loading @@ -17,6 +17,8 @@ package android import ( "fmt" "strings" "sync" "sync/atomic" "testing" "github.com/google/blueprint" Loading Loading @@ -220,7 +222,7 @@ func TestFinalDepsPhase(t *testing.T) { } ` finalGot := map[string]int{} finalGot := sync.Map{} GroupFixturePreparers( FixtureRegisterWithContext(func(ctx RegistrationContext) { Loading Loading @@ -251,9 +253,11 @@ func TestFinalDepsPhase(t *testing.T) { } }) ctx.BottomUp("final", func(ctx BottomUpMutatorContext) { finalGot[ctx.Module().String()] += 1 counter, _ := finalGot.LoadOrStore(ctx.Module().String(), &atomic.Int64{}) counter.(*atomic.Int64).Add(1) ctx.VisitDirectDeps(func(mod Module) { finalGot[fmt.Sprintf("%s -> %s", ctx.Module().String(), mod)] += 1 counter, _ := finalGot.LoadOrStore(fmt.Sprintf("%s -> %s", ctx.Module().String(), mod), &atomic.Int64{}) counter.(*atomic.Int64).Add(1) }) }) }) Loading @@ -276,7 +280,13 @@ func TestFinalDepsPhase(t *testing.T) { "foo{variant:b} -> common_dep_2{variant:a}": 1, } AssertDeepEquals(t, "final", finalWant, finalGot) finalGotMap := make(map[string]int) finalGot.Range(func(k, v any) bool { finalGotMap[k.(string)] = int(v.(*atomic.Int64).Load()) return true }) AssertDeepEquals(t, "final", finalWant, finalGotMap) } func TestTransitionMutatorInFinalDeps(t *testing.T) { Loading
android/namespace.go +1 −1 Original line number Diff line number Diff line Loading @@ -457,7 +457,7 @@ func NamespaceFactory() Module { } func RegisterNamespaceMutator(ctx RegisterMutatorsContext) { ctx.BottomUp("namespace_deps", namespaceMutator).Parallel().MutatesGlobalState() ctx.BottomUp("namespace_deps", namespaceMutator).MutatesGlobalState() } func namespaceMutator(ctx BottomUpMutatorContext) { Loading