Move prebuilts mutators after defaults have been applied
A follow up change will add a mechanism for a module to register a hook
that is called after any defaults have been applied. That is intended
for use by modules like java_sdk_library that create child modules that
are dependent upon properties that could be supplied by defaults.
Creating those child modules after prebuilts mutators are run will
cause problems if those child modules clash with prebuilts modules.
Moving the prebuilts mutators after the defaults mutators will fix
that.
Tests are currently being run with the mutators in different orders so
this change also cleans that up so they are consistent with the actual
code that is being run.
Bug: 155295806
Test: m checkbuild
Change-Id: I825c6df09058fb3a45db196661959eb332aca2f3
diff --git a/android/mutator.go b/android/mutator.go
index 79a8506..be74099 100644
--- a/android/mutator.go
+++ b/android/mutator.go
@@ -82,10 +82,6 @@
var preArch = []RegisterMutatorFunc{
RegisterNamespaceMutator,
- // Create an association between prebuilt modules and their corresponding source
- // modules (if any).
- RegisterPrebuiltsPreArchMutators,
-
// Check the visibility rules are valid.
//
// This must run after the package renamer mutators so that any issues found during
@@ -116,6 +112,10 @@
// Apply properties from defaults modules to the referencing modules.
RegisterDefaultsPreArchMutators,
+ // Create an association between prebuilt modules and their corresponding source
+ // modules (if any).
+ RegisterPrebuiltsPreArchMutators,
+
// Gather the visibility rules for all modules for us during visibility enforcement.
//
// This must come after the defaults mutators to ensure that any visibility supplied
diff --git a/apex/apex_test.go b/apex/apex_test.go
index ce39b39..dc69862 100644
--- a/apex/apex_test.go
+++ b/apex/apex_test.go
@@ -4530,12 +4530,12 @@
ctx.RegisterModuleType("apex", BundleFactory)
ctx.RegisterModuleType("apex_key", ApexKeyFactory)
ctx.RegisterModuleType("filegroup", android.FileGroupFactory)
+ ctx.PreArchMutators(android.RegisterDefaultsPreArchMutators)
cc.RegisterRequiredBuildComponentsForTest(ctx)
java.RegisterJavaBuildComponents(ctx)
java.RegisterSystemModulesBuildComponents(ctx)
java.RegisterAppBuildComponents(ctx)
java.RegisterDexpreoptBootJarsComponents(ctx)
- ctx.PreArchMutators(android.RegisterDefaultsPreArchMutators)
ctx.PostDepsMutators(android.RegisterOverridePostDepsMutators)
ctx.PreDepsMutators(RegisterPreDepsMutators)
ctx.PostDepsMutators(RegisterPostDepsMutators)
diff --git a/cc/testing.go b/cc/testing.go
index 53f0995..6119920 100644
--- a/cc/testing.go
+++ b/cc/testing.go
@@ -485,8 +485,8 @@
ctx.RegisterModuleType("filegroup", android.FileGroupFactory)
ctx.RegisterModuleType("vndk_prebuilt_shared", VndkPrebuiltSharedFactory)
ctx.RegisterModuleType("vndk_libraries_txt", VndkLibrariesTxtFactory)
- RegisterRequiredBuildComponentsForTest(ctx)
ctx.PreArchMutators(android.RegisterDefaultsPreArchMutators)
+ RegisterRequiredBuildComponentsForTest(ctx)
ctx.RegisterSingletonType("vndk-snapshot", VndkSnapshotSingleton)
ctx.RegisterSingletonType("vendor-snapshot", VendorSnapshotSingleton)