Make java_binary common variant a dependency
ctx.PrimaryModule() is wrong in the case of a java_binary that supports both host and device, use an explicit dependency instead. Once the dependency exists there is no need to manually request the jar be installed, it will automatically be installed by the host installation rules for dependencies. Test: TestBinary Change-Id: Iddeea2d08bc574c79d42139020558cd70d718ca1
This commit is contained in:
parent
de78d138a1
commit
c179ea6812
3 changed files with 21 additions and 12 deletions
|
@ -811,10 +811,16 @@ func osMutator(bpctx blueprint.BottomUpMutatorContext) {
|
|||
}
|
||||
}
|
||||
|
||||
// Identifies the dependency from CommonOS variant to the os specific variants.
|
||||
type commonOSTag struct{ blueprint.BaseDependencyTag }
|
||||
type archDepTag struct {
|
||||
blueprint.BaseDependencyTag
|
||||
name string
|
||||
}
|
||||
|
||||
var commonOsToOsSpecificVariantTag = commonOSTag{}
|
||||
// Identifies the dependency from CommonOS variant to the os specific variants.
|
||||
var commonOsToOsSpecificVariantTag = archDepTag{name: "common os to os specific"}
|
||||
|
||||
// Identifies the dependency from arch variant to the common variant for a "common_first" multilib.
|
||||
var firstArchToCommonArchDepTag = archDepTag{name: "first arch to common arch"}
|
||||
|
||||
// Get the OsType specific variants for the current CommonOS variant.
|
||||
//
|
||||
|
@ -831,7 +837,6 @@ func GetOsSpecificVariantsOfCommonOSVariant(mctx BaseModuleContext) []Module {
|
|||
}
|
||||
}
|
||||
})
|
||||
|
||||
return variants
|
||||
}
|
||||
|
||||
|
@ -955,6 +960,12 @@ func archMutator(bpctx blueprint.BottomUpMutatorContext) {
|
|||
addTargetProperties(m, targets[i], multiTargets, i == 0)
|
||||
m.base().setArchProperties(mctx)
|
||||
}
|
||||
|
||||
if multilib == "common_first" && len(modules) >= 2 {
|
||||
for i := range modules[1:] {
|
||||
mctx.AddInterVariantDependency(firstArchToCommonArchDepTag, modules[i+1], modules[0])
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func addTargetProperties(m Module, target Target, multiTargets []Target, primaryTarget bool) {
|
||||
|
|
|
@ -2472,12 +2472,11 @@ func (j *Binary) GenerateAndroidBuildActions(ctx android.ModuleContext) {
|
|||
j.wrapperFile = android.PathForSource(ctx, "build/soong/scripts/jar-wrapper.sh")
|
||||
}
|
||||
|
||||
// Depend on the installed jar so that the wrapper doesn't get executed by
|
||||
// another build rule before the jar has been installed.
|
||||
jarFile := ctx.PrimaryModule().(*Binary).installFile
|
||||
|
||||
// The host installation rules make the installed wrapper depend on all the dependencies
|
||||
// of the wrapper variant, which will include the common variant's jar file. This is
|
||||
// verified by TestBinary.
|
||||
j.binaryFile = ctx.InstallExecutable(android.PathForModuleInstall(ctx, "bin"),
|
||||
ctx.ModuleName(), j.wrapperFile, jarFile)
|
||||
ctx.ModuleName(), j.wrapperFile)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -467,9 +467,8 @@ func TestBinary(t *testing.T) {
|
|||
barWrapperDeps := barWrapper.Output("bar").Implicits.Strings()
|
||||
|
||||
// Test that the install binary wrapper depends on the installed jar file
|
||||
if len(barWrapperDeps) != 1 || barWrapperDeps[0] != barJar {
|
||||
t.Errorf("expected binary wrapper implicits [%q], got %v",
|
||||
barJar, barWrapperDeps)
|
||||
if g, w := barWrapperDeps, barJar; !android.InList(w, g) {
|
||||
t.Errorf("expected binary wrapper implicits to contain %q, got %q", w, g)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue