Loading genrule/genrule.go +41 −22 Original line number Diff line number Diff line Loading @@ -153,6 +153,8 @@ type generateTask struct { depFile android.WritablePath copyTo android.WritablePaths genDir android.WritablePath extraTools android.Paths // dependencies on tools used by the generator cmd string shard int shards int Loading Loading @@ -434,6 +436,7 @@ func (g *Module) GenerateAndroidBuildActions(ctx android.ModuleContext) { cmd.ImplicitOutputs(task.out) cmd.Implicits(task.in) cmd.Implicits(g.deps) cmd.Implicits(task.extraTools) if Bool(g.properties.Depfile) { cmd.ImplicitDepFile(task.depFile) } Loading Loading @@ -584,8 +587,8 @@ func NewGenSrcs() *Module { for i, shard := range shards { var commands []string var outFiles android.WritablePaths var commandDepFiles []string var copyTo android.WritablePaths var depFile android.WritablePath // When sharding is enabled (i.e. len(shards) > 1), the sbox rules for each // shard will be write to their own directories and then be merged together Loading @@ -598,7 +601,7 @@ func NewGenSrcs() *Module { genDir := android.PathForModuleGen(ctx, genSubDir) for j, in := range shard { for _, in := range shard { outFile := android.GenPathWithExt(ctx, finalSubDir, in, String(properties.Output_extension)) // If sharding is enabled, then outFile is the path to the output file in Loading @@ -610,10 +613,6 @@ func NewGenSrcs() *Module { outFile = shardFile } if j == 0 { depFile = outFile.ReplaceExtension(ctx, "d") } outFiles = append(outFiles, outFile) // pre-expand the command line to replace $in and $out with references to Loading @@ -624,6 +623,12 @@ func NewGenSrcs() *Module { return in.String(), nil case "out": return android.SboxPathForOutput(outFile, genDir), nil case "depfile": // Generate a depfile for each output file. Store the list for // later in order to combine them all into a single depfile. depFile := android.SboxPathForOutput(outFile.ReplaceExtension(ctx, "d"), genDir) commandDepFiles = append(commandDepFiles, depFile) return depFile, nil default: return "$(" + name + ")", nil } Loading @@ -638,15 +643,29 @@ func NewGenSrcs() *Module { } fullCommand := strings.Join(commands, " && ") var outputDepfile android.WritablePath var extraTools android.Paths if len(commandDepFiles) > 0 { // Each command wrote to a depfile, but ninja can only handle one // depfile per rule. Use the dep_fixer tool at the end of the // command to combine all the depfiles into a single output depfile. outputDepfile = android.PathForModuleGen(ctx, genSubDir, "gensrcs.d") depFixerTool := ctx.Config().HostToolPath(ctx, "dep_fixer") fullCommand += fmt.Sprintf(" && %s -o $(depfile) %s", depFixerTool.String(), strings.Join(commandDepFiles, " ")) extraTools = append(extraTools, depFixerTool) } generateTasks = append(generateTasks, generateTask{ in: shard, out: outFiles, depFile: depFile, depFile: outputDepfile, copyTo: copyTo, genDir: genDir, cmd: fullCommand, shard: i, shards: len(shards), extraTools: extraTools, }) } Loading Loading
genrule/genrule.go +41 −22 Original line number Diff line number Diff line Loading @@ -153,6 +153,8 @@ type generateTask struct { depFile android.WritablePath copyTo android.WritablePaths genDir android.WritablePath extraTools android.Paths // dependencies on tools used by the generator cmd string shard int shards int Loading Loading @@ -434,6 +436,7 @@ func (g *Module) GenerateAndroidBuildActions(ctx android.ModuleContext) { cmd.ImplicitOutputs(task.out) cmd.Implicits(task.in) cmd.Implicits(g.deps) cmd.Implicits(task.extraTools) if Bool(g.properties.Depfile) { cmd.ImplicitDepFile(task.depFile) } Loading Loading @@ -584,8 +587,8 @@ func NewGenSrcs() *Module { for i, shard := range shards { var commands []string var outFiles android.WritablePaths var commandDepFiles []string var copyTo android.WritablePaths var depFile android.WritablePath // When sharding is enabled (i.e. len(shards) > 1), the sbox rules for each // shard will be write to their own directories and then be merged together Loading @@ -598,7 +601,7 @@ func NewGenSrcs() *Module { genDir := android.PathForModuleGen(ctx, genSubDir) for j, in := range shard { for _, in := range shard { outFile := android.GenPathWithExt(ctx, finalSubDir, in, String(properties.Output_extension)) // If sharding is enabled, then outFile is the path to the output file in Loading @@ -610,10 +613,6 @@ func NewGenSrcs() *Module { outFile = shardFile } if j == 0 { depFile = outFile.ReplaceExtension(ctx, "d") } outFiles = append(outFiles, outFile) // pre-expand the command line to replace $in and $out with references to Loading @@ -624,6 +623,12 @@ func NewGenSrcs() *Module { return in.String(), nil case "out": return android.SboxPathForOutput(outFile, genDir), nil case "depfile": // Generate a depfile for each output file. Store the list for // later in order to combine them all into a single depfile. depFile := android.SboxPathForOutput(outFile.ReplaceExtension(ctx, "d"), genDir) commandDepFiles = append(commandDepFiles, depFile) return depFile, nil default: return "$(" + name + ")", nil } Loading @@ -638,15 +643,29 @@ func NewGenSrcs() *Module { } fullCommand := strings.Join(commands, " && ") var outputDepfile android.WritablePath var extraTools android.Paths if len(commandDepFiles) > 0 { // Each command wrote to a depfile, but ninja can only handle one // depfile per rule. Use the dep_fixer tool at the end of the // command to combine all the depfiles into a single output depfile. outputDepfile = android.PathForModuleGen(ctx, genSubDir, "gensrcs.d") depFixerTool := ctx.Config().HostToolPath(ctx, "dep_fixer") fullCommand += fmt.Sprintf(" && %s -o $(depfile) %s", depFixerTool.String(), strings.Join(commandDepFiles, " ")) extraTools = append(extraTools, depFixerTool) } generateTasks = append(generateTasks, generateTask{ in: shard, out: outFiles, depFile: depFile, depFile: outputDepfile, copyTo: copyTo, genDir: genDir, cmd: fullCommand, shard: i, shards: len(shards), extraTools: extraTools, }) } Loading