Enforce dependencies have right architecture
ctx.AddDependency will succeed if the named dependency only has a
single variant, even if that variant is the wrong architecture.
Use ctx.AddVariationDependency(nil, ...) instead, which requires
that all variations of the calling module match the dependency.
Bug: 112707915
Test: no change to out/soong/build.ninja
Test: using a device dependency in a host java module is an error
Change-Id: I70b661a57d4412eb63b8c9841febfb756e9e025d
diff --git a/java/aar.go b/java/aar.go
index 175e794..29f5597 100644
--- a/java/aar.go
+++ b/java/aar.go
@@ -156,7 +156,7 @@
if !ctx.Config().UnbundledBuild() {
sdkDep := decodeSdkDep(ctx, sdkContext)
if sdkDep.frameworkResModule != "" {
- ctx.AddDependency(ctx.Module(), frameworkResTag, sdkDep.frameworkResModule)
+ ctx.AddVariationDependencies(nil, frameworkResTag, sdkDep.frameworkResModule)
}
}
}
@@ -436,12 +436,12 @@
if !ctx.Config().UnbundledBuild() {
sdkDep := decodeSdkDep(ctx, sdkContext(a))
if sdkDep.useModule && sdkDep.frameworkResModule != "" {
- ctx.AddDependency(ctx.Module(), frameworkResTag, sdkDep.frameworkResModule)
+ ctx.AddVariationDependencies(nil, frameworkResTag, sdkDep.frameworkResModule)
}
}
- ctx.AddDependency(ctx.Module(), libTag, a.properties.Libs...)
- ctx.AddDependency(ctx.Module(), staticLibTag, a.properties.Static_libs...)
+ ctx.AddVariationDependencies(nil, libTag, a.properties.Libs...)
+ ctx.AddVariationDependencies(nil, staticLibTag, a.properties.Static_libs...)
}
// Unzip an AAR into its constituent files and directories. Any files in Outputs that don't exist in the AAR will be