Support per-module MakeVars

This allows setting per-module make variables earlier in the build,
particularly for prebuilt_build_tool users like LEX/M4/BISON. I moved
filegroup over because it's a simpler common interface, but it doesn't
strictly need it.

With this, the last user of the hardcoded cc.m4Cmd variable is gone.

Test: Inspect out/soong/make_vars-*.mk, out/soong/late-*.mk
Test: treehugger
Change-Id: I195b688131feac0c100c338a0749368aa5d50f4f
This commit is contained in:
Dan Willemsen
2020-07-17 19:28:53 -07:00
parent d2e291ae5c
commit 2019658b86
5 changed files with 103 additions and 55 deletions

View File

@@ -29,6 +29,10 @@ type prebuiltBuildToolProperties struct {
// Extra files that should trigger rules using this tool to rebuild
Deps []string `android:"path,arch_variant"`
// Create a make variable with the specified name that contains the path to
// this prebuilt built tool, relative to the root of the source tree.
Export_to_make_var *string
}
type prebuiltBuildTool struct {
@@ -81,6 +85,12 @@ func (t *prebuiltBuildTool) HostToolPath() OptionalPath {
return t.toolPath
}
func (t *prebuiltBuildTool) MakeVars(ctx MakeVarsModuleContext) {
if makeVar := String(t.properties.Export_to_make_var); makeVar != "" {
ctx.StrictRaw(makeVar, t.toolPath.String())
}
}
var _ HostToolProvider = &prebuiltBuildTool{}
// prebuilt_build_tool is to declare prebuilts to be used during the build, particularly for use