Add a testdata property in goPackage and goBinary

Some go tests depend on testData, but do not declare it explicitly. In
preparation for the stricter sandboxing constratints imposed by Bazel,
introduce this property.

This will be a no-op in Soong for now. But bp2build will convert it into
`data` property of go_test

Test: go build ./blueprint/bootstrap
Bug: 288491147
Change-Id: I0e1e7941db1efe6f1488936d9bae7e8d295b88ba
This commit is contained in:
Spandan Das 2023-06-22 23:51:22 +00:00
parent 4e84d6b010
commit 6a3475adf5

View file

@ -208,6 +208,7 @@ type GoPackage struct {
PkgPath string PkgPath string
Srcs []string Srcs []string
TestSrcs []string TestSrcs []string
TestData []string
PluginFor []string PluginFor []string
Darwin struct { Darwin struct {
@ -368,6 +369,10 @@ func (g *GoPackage) Deps() []string {
return g.properties.Deps return g.properties.Deps
} }
func (g *GoPackage) TestData() []string {
return g.properties.TestData
}
// A GoBinary is a module for building executable binaries from Go sources. // A GoBinary is a module for building executable binaries from Go sources.
type GoBinary struct { type GoBinary struct {
blueprint.SimpleName blueprint.SimpleName
@ -375,6 +380,7 @@ type GoBinary struct {
Deps []string Deps []string
Srcs []string Srcs []string
TestSrcs []string TestSrcs []string
TestData []string
PrimaryBuilder bool PrimaryBuilder bool
Default bool Default bool
@ -440,6 +446,10 @@ func (g *GoBinary) Deps() []string {
return g.properties.Deps return g.properties.Deps
} }
func (g *GoBinary) TestData() []string {
return g.properties.TestData
}
func (g *GoBinary) GenerateBuildActions(ctx blueprint.ModuleContext) { func (g *GoBinary) GenerateBuildActions(ctx blueprint.ModuleContext) {
// Allow the primary builder to create multiple variants. Any variants after the first // Allow the primary builder to create multiple variants. Any variants after the first
// will copy outputs from the first. // will copy outputs from the first.