aboutsummaryrefslogtreecommitdiffstats
path: root/genrule
diff options
context:
space:
mode:
authorColin Cross <ccross@android.com>2016-11-21 17:23:08 -0800
committerColin Cross <ccross@android.com>2016-11-22 15:41:09 -0800
commit33bfb0a36a80fe50510539066d607f9395c8454d (patch)
treec5d0f0bbeb20c3e5877135bb6b812f5f9a6d1531 /genrule
parent2ee10a0659406495e118c17ed20a7c4064a9da7a (diff)
downloadbuild_soong-33bfb0a36a80fe50510539066d607f9395c8454d.tar.gz
build_soong-33bfb0a36a80fe50510539066d607f9395c8454d.tar.bz2
build_soong-33bfb0a36a80fe50510539066d607f9395c8454d.zip
genrule: support deps files
If a genrule sets deps_file: true, use a file in the gen directory as a GCC-style deps file. Test: m -j libLLVMObject Change-Id: Id410165847e4eaea1853a392512e38787c431523
Diffstat (limited to 'genrule')
-rw-r--r--genrule/genrule.go28
1 files changed, 24 insertions, 4 deletions
diff --git a/genrule/genrule.go b/genrule/genrule.go
index 498858d2..b1ce8046 100644
--- a/genrule/genrule.go
+++ b/genrule/genrule.go
@@ -47,6 +47,7 @@ type generatorProperties struct {
// $(location <label>): the path to the tool or tool_file with name <label>
// $(in): one or more input files
// $(out): a single output file
+ // $(deps): a file to which dependencies will be written, if the depfile property is set to true
// $(genDir): the sandbox directory for this tool; contains $(out)
// $$: a literal $
//
@@ -55,6 +56,9 @@ type generatorProperties struct {
// change.
Cmd string
+ // Enable reading a file containing dependencies in gcc format after the command completes
+ Depfile bool
+
// name of the modules (if any) that produces the host executable. Leave empty for
// prebuilts or scripts that do not need a module to build them.
Tools []string
@@ -156,6 +160,11 @@ func (g *generator) GenerateAndroidBuildActions(ctx android.ModuleContext) {
return "${in}", nil
case "out":
return "${out}", nil
+ case "depfile":
+ if !g.properties.Depfile {
+ return "", fmt.Errorf("$(depfile) used without depfile property")
+ }
+ return "${depfile}", nil
case "genDir":
return g.genPath.String(), nil
default:
@@ -175,9 +184,15 @@ func (g *generator) GenerateAndroidBuildActions(ctx android.ModuleContext) {
ctx.PropertyErrorf("cmd", "%s", err.Error())
}
- g.rule = ctx.Rule(pctx, "generator", blueprint.RuleParams{
+ ruleParams := blueprint.RuleParams{
Command: cmd,
- })
+ }
+ var args []string
+ if g.properties.Depfile {
+ ruleParams.Deps = blueprint.DepsGCC
+ args = append(args, "depfile")
+ }
+ g.rule = ctx.Rule(pctx, "generator", ruleParams, args...)
for _, task := range g.tasks(ctx) {
g.generateSourceFile(ctx, task)
@@ -185,12 +200,17 @@ func (g *generator) GenerateAndroidBuildActions(ctx android.ModuleContext) {
}
func (g *generator) generateSourceFile(ctx android.ModuleContext, task generateTask) {
- ctx.ModuleBuild(pctx, android.ModuleBuildParams{
+ params := android.ModuleBuildParams{
Rule: g.rule,
Outputs: task.out,
Inputs: task.in,
Implicits: g.deps,
- })
+ }
+ if g.properties.Depfile {
+ depfile := android.GenPathWithExt(ctx, "", task.out[0], task.out[0].Ext()+".d")
+ params.Depfile = depfile
+ }
+ ctx.ModuleBuild(pctx, params)
for _, outputFile := range task.out {
g.outputFiles = append(g.outputFiles, outputFile)