diff options
author | Dan Willemsen <dwillemsen@google.com> | 2016-09-28 16:21:00 -0700 |
---|---|---|
committer | Dan Willemsen <dwillemsen@google.com> | 2016-09-28 18:31:04 -0700 |
commit | 9c8681f4f98cf6174bd5ab04a57d8078d591534a (patch) | |
tree | 2223b091dbbaaf00e301d0cb969c1e01d00e8f44 /genrule | |
parent | 3f4539b03578dcfab37f6e615db062b3399793df (diff) | |
download | build_soong-9c8681f4f98cf6174bd5ab04a57d8078d591534a.tar.gz build_soong-9c8681f4f98cf6174bd5ab04a57d8078d591534a.tar.bz2 build_soong-9c8681f4f98cf6174bd5ab04a57d8078d591534a.zip |
Support multiple outputs for genrule
The underlying code to expose outputs to other modules has suppported
this already for gensrcs (which runs the command multiple times to
create multiple outputs). This allows a genrule to run a command once,
and output multiple files.
Bug: 31742855
Test: Add multi-output genrule; Inspect build.ninja
Change-Id: I72054cc39c0d0e3e44feebba72005e5af1a1709a
Diffstat (limited to 'genrule')
-rw-r--r-- | genrule/genrule.go | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/genrule/genrule.go b/genrule/genrule.go index a49a5dde..4a9b336d 100644 --- a/genrule/genrule.go +++ b/genrule/genrule.go @@ -85,7 +85,7 @@ type taskFunc func(ctx android.ModuleContext) []generateTask type generateTask struct { in android.Paths - out android.ModuleGenPath + out android.WritablePaths } func (g *generator) GeneratedSourceFiles() android.Paths { @@ -167,7 +167,7 @@ func (g *generator) GenerateAndroidBuildActions(ctx android.ModuleContext) { func (g *generator) generateSourceFile(ctx android.ModuleContext, task generateTask, tool string) { ctx.ModuleBuild(pctx, android.ModuleBuildParams{ Rule: g.rule, - Output: task.out, + Outputs: task.out, Inputs: task.in, Implicits: g.deps, Args: map[string]string{ @@ -175,7 +175,9 @@ func (g *generator) generateSourceFile(ctx android.ModuleContext, task generateT }, }) - g.outputFiles = append(g.outputFiles, task.out) + for _, outputFile := range task.out { + g.outputFiles = append(g.outputFiles, outputFile) + } } func generatorFactory(tasks taskFunc, props ...interface{}) (blueprint.Module, []interface{}) { @@ -197,7 +199,7 @@ func GenSrcsFactory() (blueprint.Module, []interface{}) { for _, in := range srcFiles { tasks = append(tasks, generateTask{ in: android.Paths{in}, - out: android.GenPathWithExt(ctx, in, properties.Output_extension), + out: android.WritablePaths{android.GenPathWithExt(ctx, in, properties.Output_extension)}, }) } return tasks @@ -218,10 +220,14 @@ func GenRuleFactory() (blueprint.Module, []interface{}) { properties := &genRuleProperties{} tasks := func(ctx android.ModuleContext) []generateTask { + outs := make(android.WritablePaths, len(properties.Out)) + for i, out := range properties.Out { + outs[i] = android.PathForModuleGen(ctx, out) + } return []generateTask{ { in: ctx.ExpandSources(properties.Srcs, nil), - out: android.PathForModuleGen(ctx, properties.Out), + out: outs, }, } } @@ -233,6 +239,6 @@ type genRuleProperties struct { // list of input files Srcs []string - // name of the output file that will be generated - Out string + // names of the output files that will be generated + Out []string } |