diff options
author | 2024-10-07 15:05:23 -0700 | |
---|---|---|
committer | 2024-10-07 20:12:40 -0700 | |
commit | b2388e3e3d67ab20292ada184bfbeb32d65d7d4c (patch) | |
tree | 63cdf7c1a2605ba9dba49ef7a6eb111905cdfc80 | |
parent | d224fcab8b898f2cd68b10360a1e3aa17d46ba09 (diff) |
Remove unused TopDownMutatorContext methods
Remove methods on TopDownMutatorContext that are no longer used.
This deletes everything unique to BaseMutatorContext, so delete that
too and replace it with BaseModuleContext.
Bug: 367784740
Test: builds
Flag: EXEMPT refactor
Change-Id: Id37c7b7e3d46d75afaf7752862b08f766217f08b
-rw-r--r-- | android/arch.go | 2 | ||||
-rw-r--r-- | android/early_module_context.go | 2 | ||||
-rw-r--r-- | android/mutator.go | 53 | ||||
-rw-r--r-- | android/mutator_test.go | 38 | ||||
-rw-r--r-- | android/prebuilt.go | 4 | ||||
-rw-r--r-- | androidmk/parser/parser_test.go | 4 | ||||
-rw-r--r-- | apex/apex.go | 2 | ||||
-rw-r--r-- | compliance/notice_test.go | 2 |
8 files changed, 33 insertions, 74 deletions
diff --git a/android/arch.go b/android/arch.go index 1ec971d15..e2d0d0dbb 100644 --- a/android/arch.go +++ b/android/arch.go @@ -1369,7 +1369,7 @@ func GetCompoundTargetField(os OsType, arch ArchType) string { // Returns the structs corresponding to the properties specific to the given // architecture and OS in archProperties. -func getArchProperties(ctx BaseMutatorContext, archProperties interface{}, arch Arch, os OsType, nativeBridgeEnabled bool) []reflect.Value { +func getArchProperties(ctx BaseModuleContext, archProperties interface{}, arch Arch, os OsType, nativeBridgeEnabled bool) []reflect.Value { result := make([]reflect.Value, 0) archPropValues := reflect.ValueOf(archProperties).Elem() diff --git a/android/early_module_context.go b/android/early_module_context.go index 11de77146..9b1a9ea7e 100644 --- a/android/early_module_context.go +++ b/android/early_module_context.go @@ -29,7 +29,7 @@ type EarlyModuleContext interface { Module() Module // ModuleName returns the name of the module. This is generally the value that was returned by Module.Name() when - // the module was created, but may have been modified by calls to BaseMutatorContext.Rename. + // the module was created, but may have been modified by calls to BottomUpMutatorContext.Rename. ModuleName() string // ModuleDir returns the path to the directory that contains the definition of the module. diff --git a/android/mutator.go b/android/mutator.go index 8265458ba..ebe03a4d4 100644 --- a/android/mutator.go +++ b/android/mutator.go @@ -192,25 +192,10 @@ func FinalDepsMutators(f RegisterMutatorFunc) { finalDeps = append(finalDeps, f) } -type BaseMutatorContext interface { - BaseModuleContext - - // MutatorName returns the name that this mutator was registered with. - MutatorName() string - - // Rename all variants of a module. The new name is not visible to calls to ModuleName, - // AddDependency or OtherModuleName until after this mutator pass is complete. - Rename(name string) - - // CreateModule creates a new module by calling the factory method for the specified moduleType, and applies - // the specified property structs to it as if the properties were set in a blueprint file. - CreateModule(ModuleFactory, ...interface{}) Module -} - type TopDownMutator func(TopDownMutatorContext) type TopDownMutatorContext interface { - BaseMutatorContext + BaseModuleContext } type topDownMutatorContext struct { @@ -221,7 +206,7 @@ type topDownMutatorContext struct { type BottomUpMutator func(BottomUpMutatorContext) type BottomUpMutatorContext interface { - BaseMutatorContext + BaseModuleContext // AddDependency adds a dependency to the given module. It returns a slice of modules for each // dependency (some entries may be nil). @@ -285,6 +270,14 @@ type BottomUpMutatorContext interface { // as long as the supplied predicate returns true. // Replacements don't take effect until after the mutator pass is finished. ReplaceDependenciesIf(string, blueprint.ReplaceDependencyPredicate) + + // Rename all variants of a module. The new name is not visible to calls to ModuleName, + // AddDependency or OtherModuleName until after this mutator pass is complete. + Rename(name string) + + // CreateModule creates a new module by calling the factory method for the specified moduleType, and applies + // the specified property structs to it as if the properties were set in a blueprint file. + CreateModule(ModuleFactory, ...interface{}) Module } // An outgoingTransitionContextImpl and incomingTransitionContextImpl is created for every dependency of every module @@ -669,32 +662,6 @@ func registerDepsMutator(ctx RegisterMutatorsContext) { // non-overridden method has to be forwarded. There are fewer non-overridden methods, so use the latter. The following // methods forward to the identical blueprint versions for topDownMutatorContext and bottomUpMutatorContext. -func (t *topDownMutatorContext) MutatorName() string { - return t.bp.MutatorName() -} - -func (t *topDownMutatorContext) Rename(name string) { - t.bp.Rename(name) - t.Module().base().commonProperties.DebugName = name -} - -func (t *topDownMutatorContext) createModule(factory blueprint.ModuleFactory, name string, props ...interface{}) blueprint.Module { - return t.bp.CreateModule(factory, name, props...) -} - -func (t *topDownMutatorContext) CreateModule(factory ModuleFactory, props ...interface{}) Module { - return createModule(t, factory, "_topDownMutatorModule", props...) -} - -func (t *topDownMutatorContext) createModuleWithoutInheritance(factory ModuleFactory, props ...interface{}) Module { - module := t.bp.CreateModule(ModuleFactoryAdaptor(factory), "", props...).(Module) - return module -} - -func (b *bottomUpMutatorContext) MutatorName() string { - return b.bp.MutatorName() -} - func (b *bottomUpMutatorContext) Rename(name string) { b.bp.Rename(name) b.Module().base().commonProperties.DebugName = name diff --git a/android/mutator_test.go b/android/mutator_test.go index 5d4074a54..88bf1d2ea 100644 --- a/android/mutator_test.go +++ b/android/mutator_test.go @@ -134,10 +134,6 @@ func TestModuleString(t *testing.T) { return []string{"a", "b"} }, }) - ctx.TopDown("rename_top_down", func(ctx TopDownMutatorContext) { - moduleStrings = append(moduleStrings, ctx.Module().String()) - ctx.Rename(ctx.Module().base().Name() + "_renamed1") - }) }) ctx.PreDepsMutators(func(ctx RegisterMutatorsContext) { @@ -161,7 +157,7 @@ func TestModuleString(t *testing.T) { }) ctx.BottomUp("rename_bottom_up", func(ctx BottomUpMutatorContext) { moduleStrings = append(moduleStrings, ctx.Module().String()) - ctx.Rename(ctx.Module().base().Name() + "_renamed2") + ctx.Rename(ctx.Module().base().Name() + "_renamed1") }) ctx.BottomUp("final", func(ctx BottomUpMutatorContext) { moduleStrings = append(moduleStrings, ctx.Module().String()) @@ -181,17 +177,23 @@ func TestModuleString(t *testing.T) { "foo{pre_arch:b}", "foo{pre_arch:a}", - // After rename_top_down (reversed because pre_deps TransitionMutator.Split is TopDown). - "foo_renamed1{pre_arch:b}", - "foo_renamed1{pre_arch:a}", - // After pre_deps (reversed because post_deps TransitionMutator.Split is TopDown). - "foo_renamed1{pre_arch:b,pre_deps:d}", - "foo_renamed1{pre_arch:b,pre_deps:c}", - "foo_renamed1{pre_arch:a,pre_deps:d}", - "foo_renamed1{pre_arch:a,pre_deps:c}", + "foo{pre_arch:b,pre_deps:d}", + "foo{pre_arch:b,pre_deps:c}", + "foo{pre_arch:a,pre_deps:d}", + "foo{pre_arch:a,pre_deps:c}", // After post_deps. + "foo{pre_arch:a,pre_deps:c,post_deps:e}", + "foo{pre_arch:a,pre_deps:c,post_deps:f}", + "foo{pre_arch:a,pre_deps:d,post_deps:e}", + "foo{pre_arch:a,pre_deps:d,post_deps:f}", + "foo{pre_arch:b,pre_deps:c,post_deps:e}", + "foo{pre_arch:b,pre_deps:c,post_deps:f}", + "foo{pre_arch:b,pre_deps:d,post_deps:e}", + "foo{pre_arch:b,pre_deps:d,post_deps:f}", + + // After rename_bottom_up. "foo_renamed1{pre_arch:a,pre_deps:c,post_deps:e}", "foo_renamed1{pre_arch:a,pre_deps:c,post_deps:f}", "foo_renamed1{pre_arch:a,pre_deps:d,post_deps:e}", @@ -200,16 +202,6 @@ func TestModuleString(t *testing.T) { "foo_renamed1{pre_arch:b,pre_deps:c,post_deps:f}", "foo_renamed1{pre_arch:b,pre_deps:d,post_deps:e}", "foo_renamed1{pre_arch:b,pre_deps:d,post_deps:f}", - - // After rename_bottom_up. - "foo_renamed2{pre_arch:a,pre_deps:c,post_deps:e}", - "foo_renamed2{pre_arch:a,pre_deps:c,post_deps:f}", - "foo_renamed2{pre_arch:a,pre_deps:d,post_deps:e}", - "foo_renamed2{pre_arch:a,pre_deps:d,post_deps:f}", - "foo_renamed2{pre_arch:b,pre_deps:c,post_deps:e}", - "foo_renamed2{pre_arch:b,pre_deps:c,post_deps:f}", - "foo_renamed2{pre_arch:b,pre_deps:d,post_deps:e}", - "foo_renamed2{pre_arch:b,pre_deps:d,post_deps:f}", } AssertDeepEquals(t, "module String() values", want, moduleStrings) diff --git a/android/prebuilt.go b/android/prebuilt.go index 4f04d057b..e5d06dded 100644 --- a/android/prebuilt.go +++ b/android/prebuilt.go @@ -677,7 +677,7 @@ type createdByJavaSdkLibraryName interface { // // Even though this is a cc_prebuilt_library_shared, we create both the variants today // https://source.corp.google.com/h/googleplex-android/platform/build/soong/+/e08e32b45a18a77bc3c3e751f730539b1b374f1b:cc/library.go;l=2113-2116;drc=2c4a9779cd1921d0397a12b3d3521f4c9b30d747;bpv=1;bpt=0 -func (p *Prebuilt) variantIsDisabled(ctx BaseMutatorContext, prebuilt Module) bool { +func (p *Prebuilt) variantIsDisabled(ctx BaseModuleContext, prebuilt Module) bool { return p.srcsSupplier != nil && len(p.srcsSupplier(ctx, prebuilt)) == 0 } @@ -687,7 +687,7 @@ type apexVariationName interface { // usePrebuilt returns true if a prebuilt should be used instead of the source module. The prebuilt // will be used if it is marked "prefer" or if the source module is disabled. -func (p *Prebuilt) usePrebuilt(ctx BaseMutatorContext, source Module, prebuilt Module) bool { +func (p *Prebuilt) usePrebuilt(ctx BaseModuleContext, source Module, prebuilt Module) bool { isMainlinePrebuilt := func(prebuilt Module) bool { apex, ok := prebuilt.(apexVariationName) if !ok { diff --git a/androidmk/parser/parser_test.go b/androidmk/parser/parser_test.go index e238f8b11..21baf6bf9 100644 --- a/androidmk/parser/parser_test.go +++ b/androidmk/parser/parser_test.go @@ -142,7 +142,7 @@ endif t.Fatalf("Unexpected errors while parsing: %v", errs) } - if got[0].End() < got[len(got) -1].Pos() { - t.Errorf("Rule's end (%d) is smaller than directive that inside of rule's start (%v)\n", got[0].End(), got[len(got) -1].Pos()) + if got[0].End() < got[len(got)-1].Pos() { + t.Errorf("Rule's end (%d) is smaller than directive that inside of rule's start (%v)\n", got[0].End(), got[len(got)-1].Pos()) } } diff --git a/apex/apex.go b/apex/apex.go index d3e7eee9d..b53cb0f9f 100644 --- a/apex/apex.go +++ b/apex/apex.go @@ -292,7 +292,7 @@ type ResolvedApexNativeDependencies struct { } // Merge combines another ApexNativeDependencies into this one -func (a *ResolvedApexNativeDependencies) Merge(ctx android.BaseMutatorContext, b ApexNativeDependencies) { +func (a *ResolvedApexNativeDependencies) Merge(ctx android.BaseModuleContext, b ApexNativeDependencies) { a.Native_shared_libs = append(a.Native_shared_libs, b.Native_shared_libs.GetOrDefault(ctx, nil)...) a.Jni_libs = append(a.Jni_libs, b.Jni_libs.GetOrDefault(ctx, nil)...) a.Rust_dyn_libs = append(a.Rust_dyn_libs, b.Rust_dyn_libs...) diff --git a/compliance/notice_test.go b/compliance/notice_test.go index 6187e5332..e8578ec3b 100644 --- a/compliance/notice_test.go +++ b/compliance/notice_test.go @@ -35,4 +35,4 @@ func TestPrebuiltEtcOutputFile(t *testing.T) { m := result.Module("notice_xml_system", "android_arm64_armv8-a").(*NoticeXmlModule) android.AssertStringEquals(t, "output file", "NOTICE.xml.gz", m.outputFile.Base()) -}
\ No newline at end of file +} |