Merge "Prevent defaults modules from expanding path property dependencies" into main am: 2d08b2abff
Original change: https://android-review.googlesource.com/c/platform/build/soong/+/2933573 Change-Id: I969cc97bca99f0a289ede44a2653ab05e25c788e Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
@@ -16,10 +16,13 @@ package android
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
"github.com/google/blueprint"
|
||||||
)
|
)
|
||||||
|
|
||||||
type defaultsTestProperties struct {
|
type defaultsTestProperties struct {
|
||||||
Foo []string
|
Foo []string
|
||||||
|
Path_prop []string `android:"path"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type defaultsTestModule struct {
|
type defaultsTestModule struct {
|
||||||
@@ -130,3 +133,40 @@ func TestDefaultsAllowMissingDependencies(t *testing.T) {
|
|||||||
// TODO: missing transitive defaults is currently not handled
|
// TODO: missing transitive defaults is currently not handled
|
||||||
_ = missingTransitiveDefaults
|
_ = missingTransitiveDefaults
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestDefaultsPathProperties(t *testing.T) {
|
||||||
|
bp := `
|
||||||
|
defaults {
|
||||||
|
name: "defaults",
|
||||||
|
path_prop: [":gen"],
|
||||||
|
}
|
||||||
|
|
||||||
|
test {
|
||||||
|
name: "foo",
|
||||||
|
defaults: ["defaults"],
|
||||||
|
}
|
||||||
|
|
||||||
|
test {
|
||||||
|
name: "gen",
|
||||||
|
}
|
||||||
|
`
|
||||||
|
|
||||||
|
result := GroupFixturePreparers(
|
||||||
|
prepareForDefaultsTest,
|
||||||
|
FixtureWithRootAndroidBp(bp),
|
||||||
|
).RunTest(t)
|
||||||
|
|
||||||
|
collectDeps := func(m Module) []string {
|
||||||
|
var deps []string
|
||||||
|
result.VisitDirectDeps(m, func(dep blueprint.Module) {
|
||||||
|
deps = append(deps, result.ModuleName(dep))
|
||||||
|
})
|
||||||
|
return deps
|
||||||
|
}
|
||||||
|
|
||||||
|
foo := result.Module("foo", "")
|
||||||
|
defaults := result.Module("defaults", "")
|
||||||
|
|
||||||
|
AssertStringListContains(t, "foo should depend on gen", collectDeps(foo), "gen")
|
||||||
|
AssertStringListDoesNotContain(t, "defaults should not depend on gen", collectDeps(defaults), "gen")
|
||||||
|
}
|
||||||
|
@@ -33,6 +33,11 @@ func registerPathDepsMutator(ctx RegisterMutatorsContext) {
|
|||||||
// The pathDepsMutator automatically adds dependencies on any module that is listed with the
|
// The pathDepsMutator automatically adds dependencies on any module that is listed with the
|
||||||
// ":module" module reference syntax in a property that is tagged with `android:"path"`.
|
// ":module" module reference syntax in a property that is tagged with `android:"path"`.
|
||||||
func pathDepsMutator(ctx BottomUpMutatorContext) {
|
func pathDepsMutator(ctx BottomUpMutatorContext) {
|
||||||
|
if _, ok := ctx.Module().(DefaultsModule); ok {
|
||||||
|
// Defaults modules shouldn't have dependencies added for path properties, they have already been
|
||||||
|
// squashed into the real modules.
|
||||||
|
return
|
||||||
|
}
|
||||||
props := ctx.Module().base().GetProperties()
|
props := ctx.Module().base().GetProperties()
|
||||||
addPathDepsForProps(ctx, props)
|
addPathDepsForProps(ctx, props)
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user