Allow genrules to reference generated sources
Call ExtractSourceDeps on genrule srcs properties. Bug: 34283327 Test: no change to build.ninja Change-Id: I934a418f32d4c94400728579543ca5c910bf7dfc
This commit is contained in:
parent
8cc714313c
commit
708c424c57
|
@ -68,6 +68,9 @@ type generatorProperties struct {
|
||||||
|
|
||||||
// List of directories to export generated headers from
|
// List of directories to export generated headers from
|
||||||
Export_include_dirs []string
|
Export_include_dirs []string
|
||||||
|
|
||||||
|
// list of input files
|
||||||
|
Srcs []string
|
||||||
}
|
}
|
||||||
|
|
||||||
type generator struct {
|
type generator struct {
|
||||||
|
@ -85,7 +88,7 @@ type generator struct {
|
||||||
outputFiles android.Paths
|
outputFiles android.Paths
|
||||||
}
|
}
|
||||||
|
|
||||||
type taskFunc func(ctx android.ModuleContext) []generateTask
|
type taskFunc func(ctx android.ModuleContext, srcFiles android.Paths) []generateTask
|
||||||
|
|
||||||
type generateTask struct {
|
type generateTask struct {
|
||||||
in android.Paths
|
in android.Paths
|
||||||
|
@ -105,6 +108,7 @@ func (g *generator) GeneratedHeaderDirs() android.Paths {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *generator) DepsMutator(ctx android.BottomUpMutatorContext) {
|
func (g *generator) DepsMutator(ctx android.BottomUpMutatorContext) {
|
||||||
|
android.ExtractSourcesDeps(ctx, g.properties.Srcs)
|
||||||
if g, ok := ctx.Module().(*generator); ok {
|
if g, ok := ctx.Module().(*generator); ok {
|
||||||
if len(g.properties.Tools) > 0 {
|
if len(g.properties.Tools) > 0 {
|
||||||
ctx.AddFarVariationDependencies([]blueprint.Variation{
|
ctx.AddFarVariationDependencies([]blueprint.Variation{
|
||||||
|
@ -208,7 +212,8 @@ func (g *generator) GenerateAndroidBuildActions(ctx android.ModuleContext) {
|
||||||
}
|
}
|
||||||
g.rule = ctx.Rule(pctx, "generator", ruleParams, args...)
|
g.rule = ctx.Rule(pctx, "generator", ruleParams, args...)
|
||||||
|
|
||||||
for _, task := range g.tasks(ctx) {
|
srcFiles := ctx.ExpandSources(g.properties.Srcs, nil)
|
||||||
|
for _, task := range g.tasks(ctx, srcFiles) {
|
||||||
g.generateSourceFile(ctx, task)
|
g.generateSourceFile(ctx, task)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -244,8 +249,7 @@ func generatorFactory(tasks taskFunc, props ...interface{}) (blueprint.Module, [
|
||||||
func GenSrcsFactory() (blueprint.Module, []interface{}) {
|
func GenSrcsFactory() (blueprint.Module, []interface{}) {
|
||||||
properties := &genSrcsProperties{}
|
properties := &genSrcsProperties{}
|
||||||
|
|
||||||
tasks := func(ctx android.ModuleContext) []generateTask {
|
tasks := func(ctx android.ModuleContext, srcFiles android.Paths) []generateTask {
|
||||||
srcFiles := ctx.ExpandSources(properties.Srcs, nil)
|
|
||||||
tasks := make([]generateTask, 0, len(srcFiles))
|
tasks := make([]generateTask, 0, len(srcFiles))
|
||||||
for _, in := range srcFiles {
|
for _, in := range srcFiles {
|
||||||
tasks = append(tasks, generateTask{
|
tasks = append(tasks, generateTask{
|
||||||
|
@ -260,9 +264,6 @@ func GenSrcsFactory() (blueprint.Module, []interface{}) {
|
||||||
}
|
}
|
||||||
|
|
||||||
type genSrcsProperties struct {
|
type genSrcsProperties struct {
|
||||||
// list of input files
|
|
||||||
Srcs []string
|
|
||||||
|
|
||||||
// extension that will be substituted for each output file
|
// extension that will be substituted for each output file
|
||||||
Output_extension string
|
Output_extension string
|
||||||
}
|
}
|
||||||
|
@ -270,14 +271,14 @@ type genSrcsProperties struct {
|
||||||
func GenRuleFactory() (blueprint.Module, []interface{}) {
|
func GenRuleFactory() (blueprint.Module, []interface{}) {
|
||||||
properties := &genRuleProperties{}
|
properties := &genRuleProperties{}
|
||||||
|
|
||||||
tasks := func(ctx android.ModuleContext) []generateTask {
|
tasks := func(ctx android.ModuleContext, srcFiles android.Paths) []generateTask {
|
||||||
outs := make(android.WritablePaths, len(properties.Out))
|
outs := make(android.WritablePaths, len(properties.Out))
|
||||||
for i, out := range properties.Out {
|
for i, out := range properties.Out {
|
||||||
outs[i] = android.PathForModuleGen(ctx, out)
|
outs[i] = android.PathForModuleGen(ctx, out)
|
||||||
}
|
}
|
||||||
return []generateTask{
|
return []generateTask{
|
||||||
{
|
{
|
||||||
in: ctx.ExpandSources(properties.Srcs, nil),
|
in: srcFiles,
|
||||||
out: outs,
|
out: outs,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
@ -287,9 +288,6 @@ func GenRuleFactory() (blueprint.Module, []interface{}) {
|
||||||
}
|
}
|
||||||
|
|
||||||
type genRuleProperties struct {
|
type genRuleProperties struct {
|
||||||
// list of input files
|
|
||||||
Srcs []string
|
|
||||||
|
|
||||||
// names of the output files that will be generated
|
// names of the output files that will be generated
|
||||||
Out []string
|
Out []string
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue