Make genrule's srcs property configurable

This allows using select statements with it.

Bug: 354824866
Test: m
Change-Id: If1d71ac177618ad3eb628cdec57469886ee27c88
This commit is contained in:
Inseob Kim 2024-07-23 14:03:40 +09:00 committed by Bartłomiej Rudecki
parent 7889cf45fa
commit 989266aaff
Signed by: przekichane
GPG key ID: 751F23C6F014EF76
2 changed files with 6 additions and 4 deletions

View file

@ -139,7 +139,8 @@ type generatorProperties struct {
Export_include_dirs []string
// list of input files
Srcs []string `android:"path,arch_variant"`
Srcs proptools.Configurable[[]string] `android:"path,arch_variant"`
ResolvedSrcs []string `blueprint:"mutated"`
// input files to exclude
Exclude_srcs []string `android:"path,arch_variant"`
@ -396,7 +397,8 @@ func (g *Module) generateCommonBuildActions(ctx android.ModuleContext) {
}
return srcFiles
}
srcFiles := addLabelsForInputs("srcs", g.properties.Srcs, g.properties.Exclude_srcs)
g.properties.ResolvedSrcs = g.properties.Srcs.GetOrDefault(g.ConfigurableEvaluator(ctx), nil)
srcFiles := addLabelsForInputs("srcs", g.properties.ResolvedSrcs, g.properties.Exclude_srcs)
android.SetProvider(ctx, blueprint.SrcsFileProviderKey, blueprint.SrcsFileProviderData{SrcPaths: srcFiles.Strings()})
var copyFrom android.Paths
@ -590,7 +592,7 @@ func (g *Module) GenerateAndroidBuildActions(ctx android.ModuleContext) {
// Collect information for opening IDE project files in java/jdeps.go.
func (g *Module) IDEInfo(dpInfo *android.IdeInfo) {
dpInfo.Srcs = append(dpInfo.Srcs, g.Srcs().Strings()...)
for _, src := range g.properties.Srcs {
for _, src := range g.properties.ResolvedSrcs {
if strings.HasPrefix(src, ":") {
src = strings.Trim(src, ":")
dpInfo.Deps = append(dpInfo.Deps, src)

View file

@ -694,7 +694,7 @@ func TestGenruleDefaults(t *testing.T) {
android.AssertStringEquals(t, "cmd", expectedCmd, gen.rawCommands[0])
expectedSrcs := []string{"in1"}
android.AssertDeepEquals(t, "srcs", expectedSrcs, gen.properties.Srcs)
android.AssertDeepEquals(t, "srcs", expectedSrcs, gen.properties.ResolvedSrcs)
}
func TestGenruleAllowMissingDependencies(t *testing.T) {