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
This commit is contained in:
parent
b69575b1f6
commit
42d48b7b8b
7 changed files with 41 additions and 41 deletions
6
cc/cc.go
6
cc/cc.go
|
@ -1043,13 +1043,13 @@ func (c *Module) DepsMutator(actx android.BottomUpMutatorContext) {
|
|||
actx.AddDependency(c, depTag, gen)
|
||||
}
|
||||
|
||||
actx.AddDependency(c, objDepTag, deps.ObjFiles...)
|
||||
actx.AddVariationDependencies(nil, objDepTag, deps.ObjFiles...)
|
||||
|
||||
if deps.CrtBegin != "" {
|
||||
actx.AddDependency(c, crtBeginDepTag, deps.CrtBegin)
|
||||
actx.AddVariationDependencies(nil, crtBeginDepTag, deps.CrtBegin)
|
||||
}
|
||||
if deps.CrtEnd != "" {
|
||||
actx.AddDependency(c, crtEndDepTag, deps.CrtEnd)
|
||||
actx.AddVariationDependencies(nil, crtEndDepTag, deps.CrtEnd)
|
||||
}
|
||||
if deps.LinkerScript != "" {
|
||||
actx.AddDependency(c, linkerScriptDepTag, deps.LinkerScript)
|
||||
|
|
|
@ -156,7 +156,7 @@ func (a *aapt) deps(ctx android.BottomUpMutatorContext, sdkContext sdkContext) {
|
|||
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 @@ func (a *AARImport) DepsMutator(ctx android.BottomUpMutatorContext) {
|
|||
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
|
||||
|
|
|
@ -371,24 +371,24 @@ func (j *Javadoc) addDeps(ctx android.BottomUpMutatorContext) {
|
|||
if ctx.Device() {
|
||||
sdkDep := decodeSdkDep(ctx, sdkContext(j))
|
||||
if sdkDep.useDefaultLibs {
|
||||
ctx.AddDependency(ctx.Module(), bootClasspathTag, config.DefaultBootclasspathLibraries...)
|
||||
ctx.AddVariationDependencies(nil, bootClasspathTag, config.DefaultBootclasspathLibraries...)
|
||||
if ctx.Config().TargetOpenJDK9() {
|
||||
ctx.AddDependency(ctx.Module(), systemModulesTag, config.DefaultSystemModules)
|
||||
ctx.AddVariationDependencies(nil, systemModulesTag, config.DefaultSystemModules)
|
||||
}
|
||||
if !Bool(j.properties.No_framework_libs) {
|
||||
ctx.AddDependency(ctx.Module(), libTag, config.DefaultLibraries...)
|
||||
ctx.AddVariationDependencies(nil, libTag, config.DefaultLibraries...)
|
||||
}
|
||||
} else if sdkDep.useModule {
|
||||
if ctx.Config().TargetOpenJDK9() {
|
||||
ctx.AddDependency(ctx.Module(), systemModulesTag, sdkDep.systemModules)
|
||||
ctx.AddVariationDependencies(nil, systemModulesTag, sdkDep.systemModules)
|
||||
}
|
||||
ctx.AddDependency(ctx.Module(), bootClasspathTag, sdkDep.modules...)
|
||||
ctx.AddVariationDependencies(nil, bootClasspathTag, sdkDep.modules...)
|
||||
}
|
||||
}
|
||||
|
||||
ctx.AddDependency(ctx.Module(), libTag, j.properties.Libs...)
|
||||
ctx.AddVariationDependencies(nil, libTag, j.properties.Libs...)
|
||||
if j.properties.Srcs_lib != nil {
|
||||
ctx.AddDependency(ctx.Module(), srcsLibTag, *j.properties.Srcs_lib)
|
||||
ctx.AddVariationDependencies(nil, srcsLibTag, *j.properties.Srcs_lib)
|
||||
}
|
||||
|
||||
android.ExtractSourcesDeps(ctx, j.properties.Srcs)
|
||||
|
|
30
java/java.go
30
java/java.go
|
@ -552,41 +552,41 @@ func (j *Module) deps(ctx android.BottomUpMutatorContext) {
|
|||
if !Bool(j.properties.No_standard_libs) {
|
||||
sdkDep := decodeSdkDep(ctx, sdkContext(j))
|
||||
if sdkDep.useDefaultLibs {
|
||||
ctx.AddDependency(ctx.Module(), bootClasspathTag, config.DefaultBootclasspathLibraries...)
|
||||
ctx.AddVariationDependencies(nil, bootClasspathTag, config.DefaultBootclasspathLibraries...)
|
||||
if ctx.Config().TargetOpenJDK9() {
|
||||
ctx.AddDependency(ctx.Module(), systemModulesTag, config.DefaultSystemModules)
|
||||
ctx.AddVariationDependencies(nil, systemModulesTag, config.DefaultSystemModules)
|
||||
}
|
||||
if !Bool(j.properties.No_framework_libs) {
|
||||
ctx.AddDependency(ctx.Module(), libTag, config.DefaultLibraries...)
|
||||
ctx.AddVariationDependencies(nil, libTag, config.DefaultLibraries...)
|
||||
}
|
||||
} else if sdkDep.useModule {
|
||||
if ctx.Config().TargetOpenJDK9() {
|
||||
ctx.AddDependency(ctx.Module(), systemModulesTag, sdkDep.systemModules)
|
||||
ctx.AddVariationDependencies(nil, systemModulesTag, sdkDep.systemModules)
|
||||
}
|
||||
ctx.AddDependency(ctx.Module(), bootClasspathTag, sdkDep.modules...)
|
||||
ctx.AddVariationDependencies(nil, bootClasspathTag, sdkDep.modules...)
|
||||
if Bool(j.deviceProperties.Optimize.Enabled) {
|
||||
ctx.AddDependency(ctx.Module(), proguardRaiseTag, config.DefaultBootclasspathLibraries...)
|
||||
ctx.AddDependency(ctx.Module(), proguardRaiseTag, config.DefaultLibraries...)
|
||||
ctx.AddVariationDependencies(nil, proguardRaiseTag, config.DefaultBootclasspathLibraries...)
|
||||
ctx.AddVariationDependencies(nil, proguardRaiseTag, config.DefaultLibraries...)
|
||||
}
|
||||
}
|
||||
} else if j.deviceProperties.System_modules == nil {
|
||||
ctx.PropertyErrorf("no_standard_libs",
|
||||
"system_modules is required to be set when no_standard_libs is true, did you mean no_framework_libs?")
|
||||
} else if *j.deviceProperties.System_modules != "none" && ctx.Config().TargetOpenJDK9() {
|
||||
ctx.AddDependency(ctx.Module(), systemModulesTag, *j.deviceProperties.System_modules)
|
||||
ctx.AddVariationDependencies(nil, systemModulesTag, *j.deviceProperties.System_modules)
|
||||
}
|
||||
if ctx.ModuleName() == "framework" {
|
||||
ctx.AddDependency(ctx.Module(), frameworkResTag, "framework-res")
|
||||
ctx.AddVariationDependencies(nil, frameworkResTag, "framework-res")
|
||||
}
|
||||
if ctx.ModuleName() == "android_stubs_current" ||
|
||||
ctx.ModuleName() == "android_system_stubs_current" ||
|
||||
ctx.ModuleName() == "android_test_stubs_current" {
|
||||
ctx.AddDependency(ctx.Module(), frameworkApkTag, "framework-res")
|
||||
ctx.AddVariationDependencies(nil, frameworkApkTag, "framework-res")
|
||||
}
|
||||
}
|
||||
|
||||
ctx.AddDependency(ctx.Module(), libTag, j.properties.Libs...)
|
||||
ctx.AddDependency(ctx.Module(), staticLibTag, j.properties.Static_libs...)
|
||||
ctx.AddVariationDependencies(nil, libTag, j.properties.Libs...)
|
||||
ctx.AddVariationDependencies(nil, staticLibTag, j.properties.Static_libs...)
|
||||
ctx.AddFarVariationDependencies([]blueprint.Variation{
|
||||
{Mutator: "arch", Variation: ctx.Config().BuildOsCommonVariant},
|
||||
}, annoTag, j.properties.Annotation_processors...)
|
||||
|
@ -602,11 +602,11 @@ func (j *Module) deps(ctx android.BottomUpMutatorContext) {
|
|||
if j.hasSrcExt(".kt") {
|
||||
// TODO(ccross): move this to a mutator pass that can tell if generated sources contain
|
||||
// Kotlin files
|
||||
ctx.AddDependency(ctx.Module(), kotlinStdlibTag, "kotlin-stdlib")
|
||||
ctx.AddVariationDependencies(nil, kotlinStdlibTag, "kotlin-stdlib")
|
||||
}
|
||||
|
||||
if j.shouldInstrumentStatic(ctx) {
|
||||
ctx.AddDependency(ctx.Module(), staticLibTag, "jacocoagent")
|
||||
ctx.AddVariationDependencies(nil, staticLibTag, "jacocoagent")
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1619,7 +1619,7 @@ func (j *Import) Name() string {
|
|||
|
||||
func (j *Import) DepsMutator(ctx android.BottomUpMutatorContext) {
|
||||
android.ExtractSourcesDeps(ctx, j.properties.Jars)
|
||||
ctx.AddDependency(ctx.Module(), libTag, j.properties.Libs...)
|
||||
ctx.AddVariationDependencies(nil, libTag, j.properties.Libs...)
|
||||
}
|
||||
|
||||
func (j *Import) GenerateAndroidBuildActions(ctx android.ModuleContext) {
|
||||
|
|
|
@ -73,14 +73,14 @@ func genProto(ctx android.ModuleContext, protoFile android.Path, flags javaBuild
|
|||
func protoDeps(ctx android.BottomUpMutatorContext, p *android.ProtoProperties) {
|
||||
switch String(p.Proto.Type) {
|
||||
case "micro":
|
||||
ctx.AddDependency(ctx.Module(), staticLibTag, "libprotobuf-java-micro")
|
||||
ctx.AddVariationDependencies(nil, staticLibTag, "libprotobuf-java-micro")
|
||||
case "nano":
|
||||
ctx.AddDependency(ctx.Module(), staticLibTag, "libprotobuf-java-nano")
|
||||
ctx.AddVariationDependencies(nil, staticLibTag, "libprotobuf-java-nano")
|
||||
case "lite", "":
|
||||
ctx.AddDependency(ctx.Module(), staticLibTag, "libprotobuf-java-lite")
|
||||
ctx.AddVariationDependencies(nil, staticLibTag, "libprotobuf-java-lite")
|
||||
case "full":
|
||||
if ctx.Host() {
|
||||
ctx.AddDependency(ctx.Module(), staticLibTag, "libprotobuf-java-full")
|
||||
ctx.AddVariationDependencies(nil, staticLibTag, "libprotobuf-java-full")
|
||||
} else {
|
||||
ctx.PropertyErrorf("proto.type", "full java protos only supported on the host")
|
||||
}
|
||||
|
|
|
@ -156,14 +156,14 @@ type sdkLibrary struct {
|
|||
|
||||
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) {
|
||||
|
|
|
@ -123,7 +123,7 @@ func (system *SystemModules) GenerateAndroidBuildActions(ctx android.ModuleConte
|
|||
}
|
||||
|
||||
func (system *SystemModules) DepsMutator(ctx android.BottomUpMutatorContext) {
|
||||
ctx.AddDependency(ctx.Module(), libTag, system.properties.Libs...)
|
||||
ctx.AddVariationDependencies(nil, libTag, system.properties.Libs...)
|
||||
}
|
||||
|
||||
func (system *SystemModules) AndroidMk() android.AndroidMkData {
|
||||
|
|
Loading…
Reference in a new issue