Merge "Remove the extraNinjaFileDeps arg of RunBlueprint."

This commit is contained in:
Lukács T. Berki 2021-04-19 06:46:52 +00:00 committed by Gerrit Code Review
commit d04dcc89f4

View file

@ -76,7 +76,7 @@ func init() {
flag.BoolVar(&CmdlineArgs.EmptyNinjaFile, "empty-ninja-file", false, "write out a 0-byte ninja file") flag.BoolVar(&CmdlineArgs.EmptyNinjaFile, "empty-ninja-file", false, "write out a 0-byte ninja file")
} }
func Main(ctx *blueprint.Context, config interface{}, generatingPrimaryBuilder bool, extraNinjaFileDeps ...string) { func Main(ctx *blueprint.Context, config interface{}, generatingPrimaryBuilder bool) {
if !flag.Parsed() { if !flag.Parsed() {
flag.Parse() flag.Parse()
} }
@ -87,8 +87,8 @@ func Main(ctx *blueprint.Context, config interface{}, generatingPrimaryBuilder b
CmdlineArgs.TopFile = flag.Arg(0) CmdlineArgs.TopFile = flag.Arg(0)
CmdlineArgs.GeneratingPrimaryBuilder = generatingPrimaryBuilder CmdlineArgs.GeneratingPrimaryBuilder = generatingPrimaryBuilder
deps := RunBlueprint(CmdlineArgs, ctx, config, extraNinjaFileDeps...) ninjaDeps := RunBlueprint(CmdlineArgs, ctx, config)
err := deptools.WriteDepFile(CmdlineArgs.DepFile, CmdlineArgs.OutFile, deps) err := deptools.WriteDepFile(CmdlineArgs.DepFile, CmdlineArgs.OutFile, ninjaDeps)
if err != nil { if err != nil {
fatalf("Cannot write depfile '%s': %s", CmdlineArgs.DepFile, err) fatalf("Cannot write depfile '%s': %s", CmdlineArgs.DepFile, err)
} }
@ -133,7 +133,11 @@ func writeEmptyGlobFile(path string) {
} }
} }
} }
func RunBlueprint(args Args, ctx *blueprint.Context, config interface{}, extraNinjaFileDeps ...string) []string {
// Returns the list of dependencies the emitted Ninja files has. These can be
// written to the .d file for the output so that it is correctly rebuilt when
// needed in case Blueprint is itself invoked from Ninja
func RunBlueprint(args Args, ctx *blueprint.Context, config interface{}) []string {
runtime.GOMAXPROCS(runtime.NumCPU()) runtime.GOMAXPROCS(runtime.NumCPU())
if args.NoGC { if args.NoGC {
@ -164,9 +168,11 @@ func RunBlueprint(args Args, ctx *blueprint.Context, config interface{}, extraNi
srcDir := filepath.Dir(args.TopFile) srcDir := filepath.Dir(args.TopFile)
ninjaDeps := make([]string, 0)
if args.ModuleListFile != "" { if args.ModuleListFile != "" {
ctx.SetModuleListFile(args.ModuleListFile) ctx.SetModuleListFile(args.ModuleListFile)
extraNinjaFileDeps = append(extraNinjaFileDeps, args.ModuleListFile) ninjaDeps = append(ninjaDeps, args.ModuleListFile)
} else { } else {
fatalf("-l <moduleListFile> is required and must be nonempty") fatalf("-l <moduleListFile> is required and must be nonempty")
} }
@ -220,19 +226,19 @@ func RunBlueprint(args Args, ctx *blueprint.Context, config interface{}, extraNi
ctx.RegisterSingletonType("glob", globSingletonFactory(ctx)) ctx.RegisterSingletonType("glob", globSingletonFactory(ctx))
deps, errs := ctx.ParseFileList(filepath.Dir(args.TopFile), filesToParse, config) blueprintFiles, errs := ctx.ParseFileList(filepath.Dir(args.TopFile), filesToParse, config)
if len(errs) > 0 { if len(errs) > 0 {
fatalErrors(errs) fatalErrors(errs)
} }
// Add extra ninja file dependencies // Add extra ninja file dependencies
deps = append(deps, extraNinjaFileDeps...) ninjaDeps = append(ninjaDeps, blueprintFiles...)
extraDeps, errs := ctx.ResolveDependencies(config) extraDeps, errs := ctx.ResolveDependencies(config)
if len(errs) > 0 { if len(errs) > 0 {
fatalErrors(errs) fatalErrors(errs)
} }
deps = append(deps, extraDeps...) ninjaDeps = append(ninjaDeps, extraDeps...)
if args.DocFile != "" { if args.DocFile != "" {
err := writeDocs(ctx, config, absolutePath(args.DocFile)) err := writeDocs(ctx, config, absolutePath(args.DocFile))
@ -244,7 +250,7 @@ func RunBlueprint(args Args, ctx *blueprint.Context, config interface{}, extraNi
if c, ok := config.(ConfigStopBefore); ok { if c, ok := config.(ConfigStopBefore); ok {
if c.StopBefore() == StopBeforePrepareBuildActions { if c.StopBefore() == StopBeforePrepareBuildActions {
return deps return ninjaDeps
} }
} }
@ -252,11 +258,11 @@ func RunBlueprint(args Args, ctx *blueprint.Context, config interface{}, extraNi
if len(errs) > 0 { if len(errs) > 0 {
fatalErrors(errs) fatalErrors(errs)
} }
deps = append(deps, extraDeps...) ninjaDeps = append(ninjaDeps, extraDeps...)
if c, ok := config.(ConfigStopBefore); ok { if c, ok := config.(ConfigStopBefore); ok {
if c.StopBefore() == StopBeforeWriteNinja { if c.StopBefore() == StopBeforeWriteNinja {
return deps return ninjaDeps
} }
} }
@ -330,7 +336,7 @@ func RunBlueprint(args Args, ctx *blueprint.Context, config interface{}, extraNi
pprof.WriteHeapProfile(f) pprof.WriteHeapProfile(f)
} }
return deps return ninjaDeps
} }
func fatalf(format string, args ...interface{}) { func fatalf(format string, args ...interface{}) {