Partial bp2build conversion of blueprint_go_binary

This module type does not implement android.Module, and therefore we
cannot write a conventional bp2build converter for this module type.
Instead this has been special-cased inside bp2build/build_conversion.go.

There is one major deviation between Soong and Bazel's
go_binary/go_library. Soong
collects the deps in the transitve closure and puts them on compile/link
paths. Bazel OTOH, requires the direct imports to be listed in deps of the binary
explicitly (AFAIK). Since bp2build cannot determine the list of direct
imports from the list of transitive deps, put all the transitive deps in
`deps`

Test: unit tests
Test: TH
Bug: 284483729
Change-Id: I004aaf8607fef1697a0d9e7d018ad657b67778ac
This commit is contained in:
Spandan Das
2023-06-14 21:30:38 +00:00
parent ea2abba3a9
commit de623294fe
2 changed files with 102 additions and 3 deletions

View File

@@ -87,3 +87,40 @@ bootstrap_go_package {
)},
})
}
func TestConvertGoBinaryWithTransitiveDeps(t *testing.T) {
bp := `
blueprint_go_binary {
name: "foo",
srcs: ["main.go"],
deps: ["bar"],
}
`
depBp := `
bootstrap_go_package {
name: "bar",
deps: ["baz"],
}
bootstrap_go_package {
name: "baz",
}
`
t.Parallel()
runGoTests(t, Bp2buildTestCase{
Description: "Convert blueprint_go_binary to go_binary",
Blueprint: bp,
Filesystem: map[string]string{
"bar/Android.bp": depBp, // Put dep in Android.bp to reduce boilerplate in ExpectedBazelTargets
},
ExpectedBazelTargets: []string{makeBazelTargetHostOrDevice("go_binary", "foo",
AttrNameToString{
"deps": `[
"//bar:bar",
"//bar:baz",
]`,
"srcs": `[":main.go"]`,
},
android.HostSupported,
)},
})
}