Merge "genrule: support deps files"
This commit is contained in:
@@ -34,6 +34,8 @@ var (
|
|||||||
|
|
||||||
type ModuleBuildParams struct {
|
type ModuleBuildParams struct {
|
||||||
Rule blueprint.Rule
|
Rule blueprint.Rule
|
||||||
|
Deps blueprint.Deps
|
||||||
|
Depfile WritablePath
|
||||||
Output WritablePath
|
Output WritablePath
|
||||||
Outputs WritablePaths
|
Outputs WritablePaths
|
||||||
ImplicitOutput WritablePath
|
ImplicitOutput WritablePath
|
||||||
@@ -521,6 +523,7 @@ func (a *androidModuleContext) Build(pctx blueprint.PackageContext, params bluep
|
|||||||
func (a *androidModuleContext) ModuleBuild(pctx blueprint.PackageContext, params ModuleBuildParams) {
|
func (a *androidModuleContext) ModuleBuild(pctx blueprint.PackageContext, params ModuleBuildParams) {
|
||||||
bparams := blueprint.BuildParams{
|
bparams := blueprint.BuildParams{
|
||||||
Rule: params.Rule,
|
Rule: params.Rule,
|
||||||
|
Deps: params.Deps,
|
||||||
Outputs: params.Outputs.Strings(),
|
Outputs: params.Outputs.Strings(),
|
||||||
ImplicitOutputs: params.ImplicitOutputs.Strings(),
|
ImplicitOutputs: params.ImplicitOutputs.Strings(),
|
||||||
Inputs: params.Inputs.Strings(),
|
Inputs: params.Inputs.Strings(),
|
||||||
@@ -530,6 +533,9 @@ func (a *androidModuleContext) ModuleBuild(pctx blueprint.PackageContext, params
|
|||||||
Optional: !params.Default,
|
Optional: !params.Default,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if params.Depfile != nil {
|
||||||
|
bparams.Depfile = params.Depfile.String()
|
||||||
|
}
|
||||||
if params.Output != nil {
|
if params.Output != nil {
|
||||||
bparams.Outputs = append(bparams.Outputs, params.Output.String())
|
bparams.Outputs = append(bparams.Outputs, params.Output.String())
|
||||||
}
|
}
|
||||||
|
@@ -47,6 +47,7 @@ type generatorProperties struct {
|
|||||||
// $(location <label>): the path to the tool or tool_file with name <label>
|
// $(location <label>): the path to the tool or tool_file with name <label>
|
||||||
// $(in): one or more input files
|
// $(in): one or more input files
|
||||||
// $(out): a single output file
|
// $(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)
|
// $(genDir): the sandbox directory for this tool; contains $(out)
|
||||||
// $$: a literal $
|
// $$: a literal $
|
||||||
//
|
//
|
||||||
@@ -55,6 +56,9 @@ type generatorProperties struct {
|
|||||||
// change.
|
// change.
|
||||||
Cmd string
|
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
|
// 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.
|
// prebuilts or scripts that do not need a module to build them.
|
||||||
Tools []string
|
Tools []string
|
||||||
@@ -156,6 +160,11 @@ func (g *generator) GenerateAndroidBuildActions(ctx android.ModuleContext) {
|
|||||||
return "${in}", nil
|
return "${in}", nil
|
||||||
case "out":
|
case "out":
|
||||||
return "${out}", nil
|
return "${out}", nil
|
||||||
|
case "depfile":
|
||||||
|
if !g.properties.Depfile {
|
||||||
|
return "", fmt.Errorf("$(depfile) used without depfile property")
|
||||||
|
}
|
||||||
|
return "${depfile}", nil
|
||||||
case "genDir":
|
case "genDir":
|
||||||
return g.genPath.String(), nil
|
return g.genPath.String(), nil
|
||||||
default:
|
default:
|
||||||
@@ -175,9 +184,15 @@ func (g *generator) GenerateAndroidBuildActions(ctx android.ModuleContext) {
|
|||||||
ctx.PropertyErrorf("cmd", "%s", err.Error())
|
ctx.PropertyErrorf("cmd", "%s", err.Error())
|
||||||
}
|
}
|
||||||
|
|
||||||
g.rule = ctx.Rule(pctx, "generator", blueprint.RuleParams{
|
ruleParams := blueprint.RuleParams{
|
||||||
Command: cmd,
|
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) {
|
for _, task := range g.tasks(ctx) {
|
||||||
g.generateSourceFile(ctx, task)
|
g.generateSourceFile(ctx, task)
|
||||||
@@ -185,12 +200,17 @@ func (g *generator) GenerateAndroidBuildActions(ctx android.ModuleContext) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (g *generator) generateSourceFile(ctx android.ModuleContext, task generateTask) {
|
func (g *generator) generateSourceFile(ctx android.ModuleContext, task generateTask) {
|
||||||
ctx.ModuleBuild(pctx, android.ModuleBuildParams{
|
params := android.ModuleBuildParams{
|
||||||
Rule: g.rule,
|
Rule: g.rule,
|
||||||
Outputs: task.out,
|
Outputs: task.out,
|
||||||
Inputs: task.in,
|
Inputs: task.in,
|
||||||
Implicits: g.deps,
|
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 {
|
for _, outputFile := range task.out {
|
||||||
g.outputFiles = append(g.outputFiles, outputFile)
|
g.outputFiles = append(g.outputFiles, outputFile)
|
||||||
|
Reference in New Issue
Block a user