Dedup package build components registration
Bug: 146540677
Test: m nothing
Change-Id: Iff2d7063b7f06313e9068c61a5627229463c98dd
diff --git a/android/package.go b/android/package.go
index ed604c6..077c4a4 100644
--- a/android/package.go
+++ b/android/package.go
@@ -22,7 +22,19 @@
)
func init() {
- RegisterModuleType("package", PackageFactory)
+ RegisterPackageBuildComponents(InitRegistrationContext)
+}
+
+// Register the package module type and supporting mutators.
+//
+// This must be called in the correct order (relative to other methods that also
+// register mutators) to match the order of mutator registration in mutator.go.
+// Failing to do so will result in an unrealistic test environment.
+func RegisterPackageBuildComponents(ctx RegistrationContext) {
+ ctx.RegisterModuleType("package", PackageFactory)
+
+ // Register mutators that are hard coded in to mutator.go.
+ ctx.HardCodedPreArchMutators(RegisterPackageRenamer)
}
// The information maintained about each package.
diff --git a/android/package_test.go b/android/package_test.go
index bc66928..4710e39 100644
--- a/android/package_test.go
+++ b/android/package_test.go
@@ -87,8 +87,7 @@
config := TestArchConfig(buildDir, nil, "", fs)
ctx := NewTestArchContext()
- ctx.RegisterModuleType("package", PackageFactory)
- ctx.PreArchMutators(RegisterPackageRenamer)
+ RegisterPackageBuildComponents(ctx)
ctx.Register(config)
_, errs := ctx.ParseBlueprintsFiles(".")
diff --git a/android/visibility_test.go b/android/visibility_test.go
index fbf2fb7..c74271a 100644
--- a/android/visibility_test.go
+++ b/android/visibility_test.go
@@ -871,10 +871,9 @@
config := TestArchConfig(buildDir, nil, "", fs)
ctx := NewTestArchContext()
- ctx.RegisterModuleType("package", PackageFactory)
ctx.RegisterModuleType("mock_library", newMockLibraryModule)
ctx.RegisterModuleType("mock_defaults", defaultsFactory)
- ctx.PreArchMutators(RegisterPackageRenamer)
+ RegisterPackageBuildComponents(ctx)
ctx.PreArchMutators(RegisterVisibilityRuleChecker)
ctx.PreArchMutators(RegisterDefaultsPreArchMutators)
ctx.PreArchMutators(RegisterVisibilityRuleGatherer)
diff --git a/sdk/testing.go b/sdk/testing.go
index 8097889..c9cc30f 100644
--- a/sdk/testing.go
+++ b/sdk/testing.go
@@ -62,14 +62,12 @@
ctx := android.NewTestArchContext()
// from android package
- ctx.PreArchMutators(android.RegisterPackageRenamer)
+ android.RegisterPackageBuildComponents(ctx)
ctx.PreArchMutators(android.RegisterVisibilityRuleChecker)
ctx.PreArchMutators(android.RegisterDefaultsPreArchMutators)
ctx.PreArchMutators(android.RegisterVisibilityRuleGatherer)
ctx.PostDepsMutators(android.RegisterVisibilityRuleEnforcer)
- ctx.RegisterModuleType("package", android.PackageFactory)
-
// from java package
java.RegisterJavaBuildComponents(ctx)
java.RegisterAppBuildComponents(ctx)