summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--android/mutator.go5
-rw-r--r--android/prebuilt.go18
-rw-r--r--java/java_test.go3
-rw-r--r--java/sdk_library.go6
4 files changed, 29 insertions, 3 deletions
diff --git a/android/mutator.go b/android/mutator.go
index 9454485a9..b70c4ff64 100644
--- a/android/mutator.go
+++ b/android/mutator.go
@@ -214,6 +214,7 @@ type BottomUpMutatorContext interface {
AddFarVariationDependencies([]blueprint.Variation, blueprint.DependencyTag, ...string)
AddInterVariantDependency(tag blueprint.DependencyTag, from, to blueprint.Module)
ReplaceDependencies(string)
+ ReplaceDependenciesIf(string, blueprint.ReplaceDependencyPredicate)
AliasVariation(variationName string)
}
@@ -428,6 +429,10 @@ func (b *bottomUpMutatorContext) ReplaceDependencies(name string) {
b.bp.ReplaceDependencies(name)
}
+func (b *bottomUpMutatorContext) ReplaceDependenciesIf(name string, predicate blueprint.ReplaceDependencyPredicate) {
+ b.bp.ReplaceDependenciesIf(name, predicate)
+}
+
func (b *bottomUpMutatorContext) AliasVariation(variationName string) {
b.bp.AliasVariation(variationName)
}
diff --git a/android/prebuilt.go b/android/prebuilt.go
index a29ec911d..9f4df2831 100644
--- a/android/prebuilt.go
+++ b/android/prebuilt.go
@@ -30,6 +30,16 @@ func RegisterPrebuiltMutators(ctx RegistrationContext) {
ctx.PostDepsMutators(RegisterPrebuiltsPostDepsMutators)
}
+// Marks a dependency tag as possibly preventing a reference to a source from being
+// replaced with the prebuilt.
+type ReplaceSourceWithPrebuilt interface {
+ blueprint.DependencyTag
+
+ // Return true if the dependency defined by this tag should be replaced with the
+ // prebuilt.
+ ReplaceSourceWithPrebuilt() bool
+}
+
type prebuiltDependencyTag struct {
blueprint.BaseDependencyTag
}
@@ -260,7 +270,13 @@ func PrebuiltPostDepsMutator(ctx BottomUpMutatorContext) {
name := m.base().BaseModuleName()
if p.properties.UsePrebuilt {
if p.properties.SourceExists {
- ctx.ReplaceDependencies(name)
+ ctx.ReplaceDependenciesIf(name, func(from blueprint.Module, tag blueprint.DependencyTag, to blueprint.Module) bool {
+ if t, ok := tag.(ReplaceSourceWithPrebuilt); ok {
+ return t.ReplaceSourceWithPrebuilt()
+ }
+
+ return true
+ })
}
} else {
m.SkipInstall()
diff --git a/java/java_test.go b/java/java_test.go
index 23dcd53ab..59a2ce7aa 100644
--- a/java/java_test.go
+++ b/java/java_test.go
@@ -718,9 +718,8 @@ func TestJavaSdkLibraryImport_Preferred(t *testing.T) {
checkModuleDependencies(t, ctx, "sdklib", "android_common", []string{
`dex2oatd`,
`prebuilt_sdklib`,
- // This should be sdklib.stubs but is switched to the prebuilt because it is preferred.
- `prebuilt_sdklib.stubs`,
`sdklib.impl`,
+ `sdklib.stubs`,
`sdklib.stubs.source`,
`sdklib.xml`,
})
diff --git a/java/sdk_library.go b/java/sdk_library.go
index 1fd109ab8..a5aa328d0 100644
--- a/java/sdk_library.go
+++ b/java/sdk_library.go
@@ -70,6 +70,12 @@ func (tag scopeDependencyTag) extractDepInfo(ctx android.ModuleContext, dep andr
}
}
+var _ android.ReplaceSourceWithPrebuilt = (*scopeDependencyTag)(nil)
+
+func (tag scopeDependencyTag) ReplaceSourceWithPrebuilt() bool {
+ return false
+}
+
// Provides information about an api scope, e.g. public, system, test.
type apiScope struct {
// The name of the api scope, e.g. public, system, test