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/sdk_library.go b/java/sdk_library.go
index 525652a..d588801 100644
--- a/java/sdk_library.go
+++ b/java/sdk_library.go
@@ -156,14 +156,14 @@
func (module *sdkLibrary) DepsMutator(ctx android.BottomUpMutatorContext) {
// Add dependencies to the stubs library
- ctx.AddDependency(ctx.Module(), publicApiStubsTag, module.stubsName(apiScopePublic))
- ctx.AddDependency(ctx.Module(), systemApiStubsTag, module.stubsName(apiScopeSystem))
- ctx.AddDependency(ctx.Module(), testApiStubsTag, module.stubsName(apiScopeTest))
- ctx.AddDependency(ctx.Module(), implLibTag, module.implName())
+ ctx.AddVariationDependencies(nil, publicApiStubsTag, module.stubsName(apiScopePublic))
+ ctx.AddVariationDependencies(nil, systemApiStubsTag, module.stubsName(apiScopeSystem))
+ ctx.AddVariationDependencies(nil, testApiStubsTag, module.stubsName(apiScopeTest))
+ ctx.AddVariationDependencies(nil, implLibTag, module.implName())
- ctx.AddDependency(ctx.Module(), publicApiFileTag, module.docsName(apiScopePublic))
- ctx.AddDependency(ctx.Module(), systemApiFileTag, module.docsName(apiScopeSystem))
- ctx.AddDependency(ctx.Module(), testApiFileTag, module.docsName(apiScopeTest))
+ ctx.AddVariationDependencies(nil, publicApiFileTag, module.docsName(apiScopePublic))
+ ctx.AddVariationDependencies(nil, systemApiFileTag, module.docsName(apiScopeSystem))
+ ctx.AddVariationDependencies(nil, testApiFileTag, module.docsName(apiScopeTest))
}
func (module *sdkLibrary) GenerateAndroidBuildActions(ctx android.ModuleContext) {