Parse genrule's cmd property

am: 3f4539b035

Change-Id: I3abea62996d38febc44d9afc0719705de0a54469
This commit is contained in:
Dan Willemsen
2016-09-29 05:42:35 +00:00
committed by android-build-merger

View File

@@ -15,6 +15,8 @@
package genrule package genrule
import ( import (
"os"
"github.com/google/blueprint" "github.com/google/blueprint"
"android/soong" "android/soong"
@@ -52,6 +54,7 @@ type generatorProperties struct {
// $in: one or more input files // $in: one or more input files
// $out: a single output file // $out: a single output file
// $srcDir: the root directory of the source tree // $srcDir: the root directory of the source tree
// $genDir: the sandbox directory for this tool; contains $out
// The host bin directory will be in the path // The host bin directory will be in the path
Cmd string Cmd string
@@ -109,8 +112,30 @@ func (g *generator) GenerateAndroidBuildActions(ctx android.ModuleContext) {
return return
} }
g.genPath = android.PathForModuleGen(ctx, "")
cmd := os.Expand(g.properties.Cmd, func(name string) string {
switch name {
case "$":
return "$$"
case "tool":
return "${tool}"
case "in":
return "${in}"
case "out":
return "${out}"
case "srcDir":
return "${srcDir}"
case "genDir":
return g.genPath.String()
default:
ctx.PropertyErrorf("cmd", "unknown variable '%s'", name)
}
return ""
})
g.rule = ctx.Rule(pctx, "generator", blueprint.RuleParams{ g.rule = ctx.Rule(pctx, "generator", blueprint.RuleParams{
Command: "PATH=$$PATH:$hostBin " + g.properties.Cmd, Command: "PATH=$$PATH:$hostBin " + cmd,
}, "tool") }, "tool")
var tool string var tool string
@@ -134,8 +159,6 @@ func (g *generator) GenerateAndroidBuildActions(ctx android.ModuleContext) {
}) })
} }
g.genPath = android.PathForModuleGen(ctx, "")
for _, task := range g.tasks(ctx) { for _, task := range g.tasks(ctx) {
g.generateSourceFile(ctx, task, tool) g.generateSourceFile(ctx, task, tool)
} }