summaryrefslogtreecommitdiff
path: root/java/system_modules.go
diff options
context:
space:
mode:
author Paul Duffin <paulduffin@google.com> 2021-03-11 07:23:27 +0000
committer Paul Duffin <paulduffin@google.com> 2021-03-11 09:40:02 +0000
commit4f0a75abded278f9a6eade900c0c5abe718a4409 (patch)
tree6b708db07355f97dcae95f19f2e19aba05d24a73 /java/system_modules.go
parentc52bea9555086692a7afc0dc5cf36b60ca430057 (diff)
Ensure java_system_modules_import uses prebuilts
Make sure that java_system_modules_import always depends on the prebuilt by adding dependencies in the ComponentDepsMutator() method which is called before prebuilts without a corresponding source are renamed from prebuilt_<x> to <x>. That requires the prebuilt_ prefix to be provided but it ensures that the dependencies are safe. Similar logic also makes sure java_system_modules always depends on the source module and not on a renamed prebuilt module. Bug: 182402568 Test: m nothing Change-Id: I30db95978f5d9b205951011edf40585ee36c0c4c
Diffstat (limited to 'java/system_modules.go')
-rw-r--r--java/system_modules.go17
1 files changed, 16 insertions, 1 deletions
diff --git a/java/system_modules.go b/java/system_modules.go
index 95f71b80f..8c69051ae 100644
--- a/java/system_modules.go
+++ b/java/system_modules.go
@@ -169,7 +169,13 @@ func (system *SystemModules) GenerateAndroidBuildActions(ctx android.ModuleConte
system.outputDir, system.outputDeps = TransformJarsToSystemModules(ctx, jars)
}
-func (system *SystemModules) DepsMutator(ctx android.BottomUpMutatorContext) {
+// ComponentDepsMutator is called before prebuilt modules without a corresponding source module are
+// renamed so unless the supplied libs specifically includes the prebuilt_ prefix this is guaranteed
+// to only add dependencies on source modules.
+//
+// The systemModuleLibsTag will prevent the prebuilt mutators from replacing this dependency so it
+// will never be changed to depend on a prebuilt either.
+func (system *SystemModules) ComponentDepsMutator(ctx android.BottomUpMutatorContext) {
ctx.AddVariationDependencies(nil, systemModulesLibsTag, system.properties.Libs...)
}
@@ -225,6 +231,15 @@ func (system *systemModulesImport) Prebuilt() *android.Prebuilt {
return &system.prebuilt
}
+// ComponentDepsMutator is called before prebuilt modules without a corresponding source module are
+// renamed so as this adds a prebuilt_ prefix this is guaranteed to only add dependencies on source
+// modules.
+func (system *systemModulesImport) ComponentDepsMutator(ctx android.BottomUpMutatorContext) {
+ for _, lib := range system.properties.Libs {
+ ctx.AddVariationDependencies(nil, systemModulesLibsTag, "prebuilt_"+lib)
+ }
+}
+
type systemModulesSdkMemberType struct {
android.SdkMemberTypeBase
}