From ac87c992bee5c4034fdd5ced05e3328f081a7132 Mon Sep 17 00:00:00 2001 From: Colin Cross Date: Fri, 8 Dec 2017 18:23:13 -0800 Subject: Allow globs in tool_files tool_files can be used to add dependencies on files used by tools, so let it support globs. Test: m checkbuild Change-Id: I1c1cb098190e1bb1c81292f6eb0c4ed0e240c1e1 --- genrule/genrule.go | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/genrule/genrule.go b/genrule/genrule.go index 651ec15d..98394100 100644 --- a/genrule/genrule.go +++ b/genrule/genrule.go @@ -131,6 +131,7 @@ func (g *Module) GeneratedHeaderDirs() android.Paths { func (g *Module) DepsMutator(ctx android.BottomUpMutatorContext) { android.ExtractSourcesDeps(ctx, g.properties.Srcs) + android.ExtractSourcesDeps(ctx, g.properties.Tool_files) if g, ok := ctx.Module().(*Module); ok { if len(g.properties.Tools) > 0 { ctx.AddFarVariationDependencies([]blueprint.Variation{ @@ -141,7 +142,8 @@ func (g *Module) DepsMutator(ctx android.BottomUpMutatorContext) { } func (g *Module) GenerateAndroidBuildActions(ctx android.ModuleContext) { - if len(g.properties.Tools) == 0 && len(g.properties.Tool_files) == 0 { + toolFiles := ctx.ExpandSources(g.properties.Tool_files, nil) + if len(g.properties.Tools) == 0 && len(toolFiles) == 0 { ctx.ModuleErrorf("at least one `tools` or `tool_files` is required") return } @@ -208,13 +210,12 @@ func (g *Module) GenerateAndroidBuildActions(ctx android.ModuleContext) { return } - for _, tool := range g.properties.Tool_files { - toolPath := android.PathForModuleSrc(ctx, tool) - g.deps = append(g.deps, toolPath) - if _, exists := tools[tool]; !exists { - tools[tool] = toolPath + for _, tool := range toolFiles { + g.deps = append(g.deps, tool) + if _, exists := tools[tool.Rel()]; !exists { + tools[tool.Rel()] = tool } else { - ctx.ModuleErrorf("multiple tools for %q, %q and %q", tool, tools[tool], toolPath.String()) + ctx.ModuleErrorf("multiple tools for %q, %q and %q", tool, tools[tool.Rel()], tool.Rel()) } } @@ -229,7 +230,7 @@ func (g *Module) GenerateAndroidBuildActions(ctx android.ModuleContext) { if len(g.properties.Tools) > 0 { return tools[g.properties.Tools[0]].String(), nil } else { - return tools[g.properties.Tool_files[0]].String(), nil + return tools[toolFiles[0].Rel()].String(), nil } case "in": return "${in}", nil -- cgit v1.2.3