diff options
Diffstat (limited to 'bootstrap/command.go')
-rw-r--r-- | bootstrap/command.go | 30 |
1 files changed, 16 insertions, 14 deletions
diff --git a/bootstrap/command.go b/bootstrap/command.go index 05a3e9d..354a692 100644 --- a/bootstrap/command.go +++ b/bootstrap/command.go @@ -36,12 +36,6 @@ var ( cpuprofile string ) -// topLevelBlueprintsFile is set by Main as a way to pass this information on to -// the bootstrap build manifest generators. This information was not passed via -// the config object so as to allow the caller of Main to use whatever Config -// object it wants. -var topLevelBlueprintsFile string - func init() { flag.StringVar(&outFile, "o", "build.ninja.in", "the Ninja file to output") flag.StringVar(&depFile, "d", "", "the dependency file to output") @@ -67,17 +61,25 @@ func Main(ctx *blueprint.Context, config interface{}, extraNinjaFileDeps ...stri defer pprof.StopCPUProfile() } - ctx.RegisterModuleType("bootstrap_go_package", newGoPackageModule) - ctx.RegisterModuleType("bootstrap_go_binary", newGoBinaryModule) - ctx.RegisterSingletonType("bootstrap", newSingleton) - if flag.NArg() != 1 { fatalf("no Blueprints file specified") } - topLevelBlueprintsFile = flag.Arg(0) + generatingBootstrapper := false + if c, ok := config.(ConfigInterface); ok { + generatingBootstrapper = c.GeneratingBootstrapper() + } + + bootstrapConfig := &Config{ + generatingBootstrapper: generatingBootstrapper, + topLevelBlueprintsFile: flag.Arg(0), + } + + ctx.RegisterModuleType("bootstrap_go_package", newGoPackageModuleFactory(bootstrapConfig)) + ctx.RegisterModuleType("bootstrap_go_binary", newGoBinaryModuleFactory(bootstrapConfig)) + ctx.RegisterSingletonType("bootstrap", newSingletonFactory(bootstrapConfig)) - deps, errs := ctx.ParseBlueprintsFiles(topLevelBlueprintsFile) + deps, errs := ctx.ParseBlueprintsFiles(bootstrapConfig.topLevelBlueprintsFile) if len(errs) > 0 { fatalErrors(errs) } @@ -142,8 +144,8 @@ func Main(ctx *blueprint.Context, config interface{}, extraNinjaFileDeps ...stri } } - srcDir := filepath.Dir(topLevelBlueprintsFile) - err = removeAbandonedFiles(ctx, config, srcDir, manifestFile) + srcDir := filepath.Dir(bootstrapConfig.topLevelBlueprintsFile) + err = removeAbandonedFiles(ctx, bootstrapConfig, srcDir, manifestFile) if err != nil { fatalf("error removing abandoned files: %s", err) } |