Use three stage builds
This splits the current bootstrap stage into two stages: A bootstrap stage, which like today, a reference is checked into the tree. It just builds the "core" blueprint binaries -- minibp, gotestmain, and choosestage. Just enough to build the next stage's ninja file. A primary builder stage. This builds the primary builder, the main ninja file, and any other bootstrap binaries (bpfmt, etc). The main advantage here is that the checked in file really only contains references to blueprint -- not the primary builder. This will allow us to make the primary builder more dynamic, by loading more module types that may or may not exist in all trees. It's even possible to reuse the build.ninja.in in the blueprint repo directly now. We don't currently do that, since we still want to turn on tests. Change-Id: I18683891ed7348b0d7af93084e3a68a04fbd5dbc
This commit is contained in:
parent
91a657e219
commit
efd2de734d
16 changed files with 243 additions and 112 deletions
|
@ -98,7 +98,7 @@ bootstrap_go_package(
|
|||
],
|
||||
)
|
||||
|
||||
bootstrap_go_binary(
|
||||
bootstrap_core_go_binary(
|
||||
name = "minibp",
|
||||
deps = [
|
||||
"blueprint",
|
||||
|
@ -119,12 +119,12 @@ bootstrap_go_binary(
|
|||
srcs = ["bpmodify/bpmodify.go"],
|
||||
)
|
||||
|
||||
bootstrap_go_binary(
|
||||
bootstrap_core_go_binary(
|
||||
name = "gotestmain",
|
||||
srcs = ["gotestmain/gotestmain.go"],
|
||||
)
|
||||
|
||||
bootstrap_go_binary(
|
||||
bootstrap_core_go_binary(
|
||||
name = "choosestage",
|
||||
srcs = ["choosestage/choosestage.go"],
|
||||
)
|
||||
|
|
|
@ -24,6 +24,7 @@ import (
|
|||
)
|
||||
|
||||
const bootstrapDir = ".bootstrap"
|
||||
const miniBootstrapDir = ".minibootstrap"
|
||||
|
||||
var (
|
||||
pctx = blueprint.NewPackageContext("github.com/google/blueprint/bootstrap")
|
||||
|
@ -105,6 +106,23 @@ var (
|
|||
docsDir = filepath.Join(bootstrapDir, "docs")
|
||||
)
|
||||
|
||||
type bootstrapGoCore interface {
|
||||
BuildStage() Stage
|
||||
SetBuildStage(Stage)
|
||||
}
|
||||
|
||||
func propagateStageBootstrap(mctx blueprint.TopDownMutatorContext) {
|
||||
if mod, ok := mctx.Module().(bootstrapGoCore); !ok || mod.BuildStage() != StageBootstrap {
|
||||
return
|
||||
}
|
||||
|
||||
mctx.VisitDirectDeps(func (mod blueprint.Module) {
|
||||
if m, ok := mod.(bootstrapGoCore); ok {
|
||||
m.SetBuildStage(StageBootstrap)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
type goPackageProducer interface {
|
||||
GoPkgRoot() string
|
||||
GoPackageTarget() string
|
||||
|
@ -117,6 +135,7 @@ func isGoPackageProducer(module blueprint.Module) bool {
|
|||
|
||||
type goTestProducer interface {
|
||||
GoTestTarget() string
|
||||
BuildStage() Stage
|
||||
}
|
||||
|
||||
func isGoTestProducer(module blueprint.Module) bool {
|
||||
|
@ -155,6 +174,9 @@ type goPackage struct {
|
|||
|
||||
// The bootstrap Config
|
||||
config *Config
|
||||
|
||||
// The stage in which this module should be built
|
||||
buildStage Stage
|
||||
}
|
||||
|
||||
var _ goPackageProducer = (*goPackage)(nil)
|
||||
|
@ -180,6 +202,14 @@ func (g *goPackage) GoTestTarget() string {
|
|||
return g.testArchiveFile
|
||||
}
|
||||
|
||||
func (g *goPackage) BuildStage() Stage {
|
||||
return g.buildStage
|
||||
}
|
||||
|
||||
func (g *goPackage) SetBuildStage(buildStage Stage) {
|
||||
g.buildStage = buildStage
|
||||
}
|
||||
|
||||
func (g *goPackage) GenerateBuildActions(ctx blueprint.ModuleContext) {
|
||||
name := ctx.ModuleName()
|
||||
|
||||
|
@ -201,8 +231,7 @@ func (g *goPackage) GenerateBuildActions(ctx blueprint.ModuleContext) {
|
|||
// the circular dependence that occurs when the builder requires a new Ninja
|
||||
// file to be built, but building a new ninja file requires the builder to
|
||||
// be built.
|
||||
switch g.config.stage {
|
||||
case StageBootstrap:
|
||||
if g.config.stage == g.BuildStage() {
|
||||
var deps []string
|
||||
|
||||
if g.config.runGoTests {
|
||||
|
@ -213,7 +242,7 @@ func (g *goPackage) GenerateBuildActions(ctx blueprint.ModuleContext) {
|
|||
|
||||
buildGoPackage(ctx, g.pkgRoot, g.properties.PkgPath, g.archiveFile,
|
||||
g.properties.Srcs, deps)
|
||||
case StageMain:
|
||||
} else if g.config.stage != StageBootstrap {
|
||||
if len(g.properties.TestSrcs) > 0 && g.config.runGoTests {
|
||||
phonyGoTarget(ctx, g.testArchiveFile, g.properties.TestSrcs, nil)
|
||||
}
|
||||
|
@ -234,12 +263,16 @@ type goBinary struct {
|
|||
|
||||
// The bootstrap Config
|
||||
config *Config
|
||||
|
||||
// The stage in which this module should be built
|
||||
buildStage Stage
|
||||
}
|
||||
|
||||
func newGoBinaryModuleFactory(config *Config) func() (blueprint.Module, []interface{}) {
|
||||
func newGoBinaryModuleFactory(config *Config, buildStage Stage) func() (blueprint.Module, []interface{}) {
|
||||
return func() (blueprint.Module, []interface{}) {
|
||||
module := &goBinary{
|
||||
config: config,
|
||||
config: config,
|
||||
buildStage: buildStage,
|
||||
}
|
||||
return module, []interface{}{&module.properties}
|
||||
}
|
||||
|
@ -249,6 +282,14 @@ func (g *goBinary) GoTestTarget() string {
|
|||
return g.testArchiveFile
|
||||
}
|
||||
|
||||
func (g *goBinary) BuildStage() Stage {
|
||||
return g.buildStage
|
||||
}
|
||||
|
||||
func (g *goBinary) SetBuildStage(buildStage Stage) {
|
||||
g.buildStage = buildStage
|
||||
}
|
||||
|
||||
func (g *goBinary) GenerateBuildActions(ctx blueprint.ModuleContext) {
|
||||
var (
|
||||
name = ctx.ModuleName()
|
||||
|
@ -267,8 +308,7 @@ func (g *goBinary) GenerateBuildActions(ctx blueprint.ModuleContext) {
|
|||
// the circular dependence that occurs when the builder requires a new Ninja
|
||||
// file to be built, but building a new ninja file requires the builder to
|
||||
// be built.
|
||||
switch g.config.stage {
|
||||
case StageBootstrap:
|
||||
if g.config.stage == g.BuildStage() {
|
||||
var deps []string
|
||||
|
||||
if g.config.runGoTests {
|
||||
|
@ -304,7 +344,7 @@ func (g *goBinary) GenerateBuildActions(ctx blueprint.ModuleContext) {
|
|||
Outputs: []string{binaryFile},
|
||||
Inputs: []string{aoutFile},
|
||||
})
|
||||
case StageMain:
|
||||
} else if g.config.stage != StageBootstrap {
|
||||
if len(g.properties.TestSrcs) > 0 && g.config.runGoTests {
|
||||
phonyGoTarget(ctx, g.testArchiveFile, g.properties.TestSrcs, nil)
|
||||
}
|
||||
|
@ -483,13 +523,21 @@ func (s *singleton) GenerateBuildActions(ctx blueprint.SingletonContext) {
|
|||
// creating the binary that we'll use to generate the non-bootstrap
|
||||
// build.ninja file.
|
||||
var primaryBuilders []*goBinary
|
||||
// rebootstrapDeps contains modules that will be built in StageBootstrap
|
||||
var rebootstrapDeps []string
|
||||
// primaryRebootstrapDeps contains modules that will be built in StagePrimary
|
||||
var primaryRebootstrapDeps []string
|
||||
ctx.VisitAllModulesIf(isBootstrapBinaryModule,
|
||||
func(module blueprint.Module) {
|
||||
binaryModule := module.(*goBinary)
|
||||
binaryModuleName := ctx.ModuleName(binaryModule)
|
||||
binaryModulePath := filepath.Join(BinDir, binaryModuleName)
|
||||
rebootstrapDeps = append(rebootstrapDeps, binaryModulePath)
|
||||
|
||||
if binaryModule.BuildStage() == StageBootstrap {
|
||||
rebootstrapDeps = append(rebootstrapDeps, binaryModulePath)
|
||||
} else {
|
||||
primaryRebootstrapDeps = append(primaryRebootstrapDeps, binaryModulePath)
|
||||
}
|
||||
if binaryModule.properties.PrimaryBuilder {
|
||||
primaryBuilders = append(primaryBuilders, binaryModule)
|
||||
}
|
||||
|
@ -527,14 +575,18 @@ func (s *singleton) GenerateBuildActions(ctx blueprint.SingletonContext) {
|
|||
filepath.Base(s.config.topLevelBlueprintsFile))
|
||||
|
||||
rebootstrapDeps = append(rebootstrapDeps, topLevelBlueprints)
|
||||
primaryRebootstrapDeps = append(primaryRebootstrapDeps, topLevelBlueprints)
|
||||
|
||||
mainNinjaFile := filepath.Join(bootstrapDir, "main.ninja.in")
|
||||
mainNinjaTimestampFile := mainNinjaFile + ".timestamp"
|
||||
mainNinjaTimestampDepFile := mainNinjaTimestampFile + ".d"
|
||||
primaryBuilderNinjaFile := filepath.Join(bootstrapDir, "primary.ninja.in")
|
||||
primaryBuilderNinjaTimestampFile := primaryBuilderNinjaFile + ".timestamp"
|
||||
primaryBuilderNinjaTimestampDepFile := primaryBuilderNinjaTimestampFile + ".d"
|
||||
bootstrapNinjaFile := filepath.Join(bootstrapDir, "bootstrap.ninja.in")
|
||||
docsFile := filepath.Join(docsDir, primaryBuilderName+".html")
|
||||
|
||||
rebootstrapDeps = append(rebootstrapDeps, docsFile)
|
||||
primaryRebootstrapDeps = append(primaryRebootstrapDeps, docsFile)
|
||||
|
||||
// If the tests change, be sure to re-run them. These need to be
|
||||
// dependencies for the ninja file so that it's updated after these
|
||||
|
@ -545,7 +597,11 @@ func (s *singleton) GenerateBuildActions(ctx blueprint.SingletonContext) {
|
|||
testModule := module.(goTestProducer)
|
||||
target := testModule.GoTestTarget()
|
||||
if target != "" {
|
||||
rebootstrapDeps = append(rebootstrapDeps, target)
|
||||
if testModule.BuildStage() == StageBootstrap {
|
||||
rebootstrapDeps = append(rebootstrapDeps, target)
|
||||
} else {
|
||||
primaryRebootstrapDeps = append(primaryRebootstrapDeps, target)
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
|
@ -554,9 +610,40 @@ func (s *singleton) GenerateBuildActions(ctx blueprint.SingletonContext) {
|
|||
// We're generating a bootstrapper Ninja file, so we need to set things
|
||||
// up to rebuild the build.ninja file using the primary builder.
|
||||
|
||||
// BuildDir must be different between bootstrap and the main build,
|
||||
// otherwise the cleanup process will remove files from the other build.
|
||||
ctx.SetBuildDir(pctx, bootstrapDir)
|
||||
// BuildDir must be different between the three stages, otherwise the
|
||||
// cleanup process will remove files from the other builds.
|
||||
ctx.SetBuildDir(pctx, miniBootstrapDir)
|
||||
|
||||
// Generate the Ninja file to build the primary builder. Save the
|
||||
// timestamps and deps, so that we can come back to this stage if
|
||||
// it needs to be regenerated.
|
||||
primarybp := ctx.Rule(pctx, "primarybp",
|
||||
blueprint.RuleParams{
|
||||
Command: fmt.Sprintf("%s --build-primary $runTests -m $bootstrapManifest "+
|
||||
"--timestamp $timestamp --timestampdep $timestampdep "+
|
||||
"-d $outfile.d -o $outfile $in", minibpFile),
|
||||
Description: "minibp $outfile",
|
||||
Depfile: "$outfile.d",
|
||||
},
|
||||
"runTests", "timestamp", "timestampdep", "outfile")
|
||||
|
||||
args := map[string]string{
|
||||
"outfile": primaryBuilderNinjaFile,
|
||||
"timestamp": primaryBuilderNinjaTimestampFile,
|
||||
"timestampdep": primaryBuilderNinjaTimestampDepFile,
|
||||
}
|
||||
|
||||
if s.config.runGoTests {
|
||||
args["runTests"] = "-t"
|
||||
}
|
||||
|
||||
ctx.Build(pctx, blueprint.BuildParams{
|
||||
Rule: primarybp,
|
||||
Outputs: []string{primaryBuilderNinjaFile, primaryBuilderNinjaTimestampFile},
|
||||
Inputs: []string{topLevelBlueprints},
|
||||
Implicits: rebootstrapDeps,
|
||||
Args: args,
|
||||
})
|
||||
|
||||
// Rebuild the bootstrap Ninja file using the minibp that we just built.
|
||||
// If this produces a difference, choosestage will retrigger this stage.
|
||||
|
@ -570,7 +657,7 @@ func (s *singleton) GenerateBuildActions(ctx blueprint.SingletonContext) {
|
|||
},
|
||||
"runTests")
|
||||
|
||||
args := map[string]string{}
|
||||
args = map[string]string{}
|
||||
|
||||
if s.config.runGoTests {
|
||||
args["runTests"] = "-t"
|
||||
|
@ -588,6 +675,34 @@ func (s *singleton) GenerateBuildActions(ctx blueprint.SingletonContext) {
|
|||
Args: args,
|
||||
})
|
||||
|
||||
// When the current build.ninja file is a bootstrapper, we always want
|
||||
// to have it replace itself with a non-bootstrapper build.ninja. To
|
||||
// accomplish that we depend on a file that should never exist and
|
||||
// "build" it using Ninja's built-in phony rule.
|
||||
notAFile := filepath.Join(bootstrapDir, "notAFile")
|
||||
ctx.Build(pctx, blueprint.BuildParams{
|
||||
Rule: blueprint.Phony,
|
||||
Outputs: []string{notAFile},
|
||||
})
|
||||
|
||||
ctx.Build(pctx, blueprint.BuildParams{
|
||||
Rule: chooseStage,
|
||||
Outputs: []string{filepath.Join(bootstrapDir, "build.ninja.in")},
|
||||
Inputs: []string{bootstrapNinjaFile, primaryBuilderNinjaFile},
|
||||
Implicits: []string{"$chooseStageCmd", "$bootstrapManifest", notAFile},
|
||||
Args: map[string]string{
|
||||
"current": bootstrapNinjaFile,
|
||||
},
|
||||
})
|
||||
|
||||
case StagePrimary:
|
||||
// We're generating a bootstrapper Ninja file, so we need to set things
|
||||
// up to rebuild the build.ninja file using the primary builder.
|
||||
|
||||
// BuildDir must be different between the three stages, otherwise the
|
||||
// cleanup process will remove files from the other builds.
|
||||
ctx.SetBuildDir(pctx, bootstrapDir)
|
||||
|
||||
// We generate the depfile here that includes the dependencies for all
|
||||
// the Blueprints files that contribute to generating the big build
|
||||
// manifest (build.ninja file). This depfile will be used by the non-
|
||||
|
@ -608,7 +723,7 @@ func (s *singleton) GenerateBuildActions(ctx blueprint.SingletonContext) {
|
|||
Rule: bigbp,
|
||||
Outputs: []string{mainNinjaFile, mainNinjaTimestampFile},
|
||||
Inputs: []string{topLevelBlueprints},
|
||||
Implicits: rebootstrapDeps,
|
||||
Implicits: primaryRebootstrapDeps,
|
||||
Args: map[string]string{
|
||||
"timestamp": mainNinjaTimestampFile,
|
||||
"timestampdep": mainNinjaTimestampDepFile,
|
||||
|
@ -634,6 +749,20 @@ func (s *singleton) GenerateBuildActions(ctx blueprint.SingletonContext) {
|
|||
Implicits: []string{primaryBuilderFile},
|
||||
})
|
||||
|
||||
// Detect whether we need to rebuild the primary stage by going back to
|
||||
// the bootstrapper. If this is newer than the primaryBuilderNinjaFile,
|
||||
// then chooseStage will trigger a rebuild of primaryBuilderNinjaFile by
|
||||
// returning to the bootstrap stage.
|
||||
ctx.Build(pctx, blueprint.BuildParams{
|
||||
Rule: touch,
|
||||
Outputs: []string{primaryBuilderNinjaTimestampFile},
|
||||
Implicits: rebootstrapDeps,
|
||||
Args: map[string]string{
|
||||
"depfile": primaryBuilderNinjaTimestampDepFile,
|
||||
"generator": "true",
|
||||
},
|
||||
})
|
||||
|
||||
// When the current build.ninja file is a bootstrapper, we always want
|
||||
// to have it replace itself with a non-bootstrapper build.ninja. To
|
||||
// accomplish that we depend on a file that should never exist and
|
||||
|
@ -647,13 +776,20 @@ func (s *singleton) GenerateBuildActions(ctx blueprint.SingletonContext) {
|
|||
ctx.Build(pctx, blueprint.BuildParams{
|
||||
Rule: chooseStage,
|
||||
Outputs: []string{filepath.Join(bootstrapDir, "build.ninja.in")},
|
||||
Inputs: []string{bootstrapNinjaFile, mainNinjaFile},
|
||||
Implicits: []string{"$chooseStageCmd", "$bootstrapManifest", notAFile},
|
||||
Inputs: []string{bootstrapNinjaFile, primaryBuilderNinjaFile, mainNinjaFile},
|
||||
Implicits: []string{"$chooseStageCmd", "$bootstrapManifest", notAFile, primaryBuilderNinjaTimestampFile},
|
||||
Args: map[string]string{
|
||||
"current": bootstrapNinjaFile,
|
||||
"current": primaryBuilderNinjaFile,
|
||||
},
|
||||
})
|
||||
|
||||
// Create this phony rule so that upgrades don't delete these during
|
||||
// cleanup
|
||||
ctx.Build(pctx, blueprint.BuildParams{
|
||||
Rule: blueprint.Phony,
|
||||
Outputs: []string{bootstrapNinjaFile},
|
||||
})
|
||||
|
||||
case StageMain:
|
||||
// We're generating a non-bootstrapper Ninja file, so we need to set it
|
||||
// up to re-bootstrap if necessary. We do this by making build.ninja.in
|
||||
|
@ -667,8 +803,18 @@ func (s *singleton) GenerateBuildActions(ctx blueprint.SingletonContext) {
|
|||
// that Ninja file.
|
||||
ctx.Build(pctx, blueprint.BuildParams{
|
||||
Rule: touch,
|
||||
Outputs: []string{mainNinjaTimestampFile},
|
||||
Outputs: []string{primaryBuilderNinjaTimestampFile},
|
||||
Implicits: rebootstrapDeps,
|
||||
Args: map[string]string{
|
||||
"depfile": primaryBuilderNinjaTimestampDepFile,
|
||||
"generator": "true",
|
||||
},
|
||||
})
|
||||
|
||||
ctx.Build(pctx, blueprint.BuildParams{
|
||||
Rule: touch,
|
||||
Outputs: []string{mainNinjaTimestampFile},
|
||||
Implicits: primaryRebootstrapDeps,
|
||||
Args: map[string]string{
|
||||
"depfile": mainNinjaTimestampDepFile,
|
||||
"generator": "true",
|
||||
|
@ -678,8 +824,8 @@ func (s *singleton) GenerateBuildActions(ctx blueprint.SingletonContext) {
|
|||
ctx.Build(pctx, blueprint.BuildParams{
|
||||
Rule: chooseStage,
|
||||
Outputs: []string{filepath.Join(bootstrapDir, "build.ninja.in")},
|
||||
Inputs: []string{bootstrapNinjaFile, mainNinjaFile},
|
||||
Implicits: []string{"$chooseStageCmd", "$bootstrapManifest", mainNinjaTimestampFile},
|
||||
Inputs: []string{bootstrapNinjaFile, primaryBuilderNinjaFile, mainNinjaFile},
|
||||
Implicits: []string{"$chooseStageCmd", "$bootstrapManifest", primaryBuilderNinjaTimestampFile, mainNinjaTimestampFile},
|
||||
Args: map[string]string{
|
||||
"current": mainNinjaFile,
|
||||
"generator": "true",
|
||||
|
|
|
@ -33,7 +33,10 @@ func removeAbandonedFiles(ctx *blueprint.Context, config *Config,
|
|||
srcDir, manifestFile string) error {
|
||||
|
||||
buildDir := "."
|
||||
if config.stage == StageBootstrap {
|
||||
switch config.stage {
|
||||
case StageBootstrap:
|
||||
buildDir = miniBootstrapDir
|
||||
case StagePrimary:
|
||||
buildDir = bootstrapDir
|
||||
}
|
||||
|
||||
|
|
|
@ -76,6 +76,9 @@ func Main(ctx *blueprint.Context, config interface{}, extraNinjaFileDeps ...stri
|
|||
if c.GeneratingBootstrapper() {
|
||||
stage = StageBootstrap
|
||||
}
|
||||
if c.GeneratingPrimaryBuilder() {
|
||||
stage = StagePrimary
|
||||
}
|
||||
}
|
||||
|
||||
bootstrapConfig := &Config{
|
||||
|
@ -85,7 +88,9 @@ func Main(ctx *blueprint.Context, config interface{}, extraNinjaFileDeps ...stri
|
|||
}
|
||||
|
||||
ctx.RegisterModuleType("bootstrap_go_package", newGoPackageModuleFactory(bootstrapConfig))
|
||||
ctx.RegisterModuleType("bootstrap_go_binary", newGoBinaryModuleFactory(bootstrapConfig))
|
||||
ctx.RegisterModuleType("bootstrap_core_go_binary", newGoBinaryModuleFactory(bootstrapConfig, StageBootstrap))
|
||||
ctx.RegisterModuleType("bootstrap_go_binary", newGoBinaryModuleFactory(bootstrapConfig, StagePrimary))
|
||||
ctx.RegisterTopDownMutator("bootstrap_stage", propagateStageBootstrap)
|
||||
ctx.RegisterSingletonType("bootstrap", newSingletonFactory(bootstrapConfig))
|
||||
|
||||
deps, errs := ctx.ParseBlueprintsFiles(bootstrapConfig.topLevelBlueprintsFile)
|
||||
|
|
|
@ -36,12 +36,16 @@ type ConfigInterface interface {
|
|||
// creating a build.ninja.in file to be used in a build bootstrapping
|
||||
// sequence.
|
||||
GeneratingBootstrapper() bool
|
||||
// GeneratingPrimaryBuilder should return true if this build invocation is
|
||||
// creating a build.ninja.in file to be used to build the primary builder
|
||||
GeneratingPrimaryBuilder() bool
|
||||
}
|
||||
|
||||
type Stage int
|
||||
|
||||
const (
|
||||
StageBootstrap Stage = iota
|
||||
StagePrimary
|
||||
StageMain
|
||||
)
|
||||
|
||||
|
|
|
@ -21,15 +21,24 @@ import (
|
|||
)
|
||||
|
||||
var runAsPrimaryBuilder bool
|
||||
var buildPrimaryBuilder bool
|
||||
|
||||
func init() {
|
||||
flag.BoolVar(&runAsPrimaryBuilder, "p", false, "run as a primary builder")
|
||||
flag.BoolVar(&buildPrimaryBuilder, "build-primary", false, "build the primary builder")
|
||||
}
|
||||
|
||||
type Config bool
|
||||
type Config struct {
|
||||
generatingBootstrapper bool
|
||||
generatingPrimaryBuilder bool
|
||||
}
|
||||
|
||||
func (c Config) GeneratingBootstrapper() bool {
|
||||
return bool(c)
|
||||
return c.generatingBootstrapper
|
||||
}
|
||||
|
||||
func (c Config) GeneratingPrimaryBuilder() bool {
|
||||
return c.generatingPrimaryBuilder
|
||||
}
|
||||
|
||||
func main() {
|
||||
|
@ -40,7 +49,10 @@ func main() {
|
|||
ctx.SetIgnoreUnknownModuleTypes(true)
|
||||
}
|
||||
|
||||
config := Config(!runAsPrimaryBuilder)
|
||||
config := Config{
|
||||
generatingBootstrapper: !runAsPrimaryBuilder && !buildPrimaryBuilder,
|
||||
generatingPrimaryBuilder: !runAsPrimaryBuilder && buildPrimaryBuilder,
|
||||
}
|
||||
|
||||
bootstrap.Main(ctx, config)
|
||||
}
|
||||
|
|
111
build.ninja.in
111
build.ninja.in
|
@ -31,7 +31,7 @@ g.bootstrap.linkCmd = ${g.bootstrap.goToolDir}/${g.bootstrap.goChar}l
|
|||
|
||||
g.bootstrap.srcDir = @@SrcDir@@
|
||||
|
||||
builddir = .bootstrap
|
||||
builddir = .minibootstrap
|
||||
|
||||
rule g.bootstrap.bootstrap
|
||||
command = ${g.bootstrap.bootstrapCmd} -i ${in}
|
||||
|
@ -58,7 +58,7 @@ rule g.bootstrap.link
|
|||
# Module: blueprint
|
||||
# Variant:
|
||||
# Type: bootstrap_go_package
|
||||
# Factory: github.com/google/blueprint/bootstrap.func·001
|
||||
# Factory: github.com/google/blueprint/bootstrap.func·002
|
||||
# Defined: Blueprints:1:1
|
||||
|
||||
build .bootstrap/blueprint/pkg/github.com/google/blueprint.a: g.bootstrap.gc $
|
||||
|
@ -81,7 +81,7 @@ default .bootstrap/blueprint/pkg/github.com/google/blueprint.a
|
|||
# Module: blueprint-bootstrap
|
||||
# Variant:
|
||||
# Type: bootstrap_go_package
|
||||
# Factory: github.com/google/blueprint/bootstrap.func·001
|
||||
# Factory: github.com/google/blueprint/bootstrap.func·002
|
||||
# Defined: Blueprints:70:1
|
||||
|
||||
build $
|
||||
|
@ -107,7 +107,7 @@ default $
|
|||
# Module: blueprint-bootstrap-bpdoc
|
||||
# Variant:
|
||||
# Type: bootstrap_go_package
|
||||
# Factory: github.com/google/blueprint/bootstrap.func·001
|
||||
# Factory: github.com/google/blueprint/bootstrap.func·002
|
||||
# Defined: Blueprints:89:1
|
||||
|
||||
build $
|
||||
|
@ -127,7 +127,7 @@ default $
|
|||
# Module: blueprint-deptools
|
||||
# Variant:
|
||||
# Type: bootstrap_go_package
|
||||
# Factory: github.com/google/blueprint/bootstrap.func·001
|
||||
# Factory: github.com/google/blueprint/bootstrap.func·002
|
||||
# Defined: Blueprints:46:1
|
||||
|
||||
build .bootstrap/blueprint-deptools/pkg/github.com/google/blueprint/deptools.a $
|
||||
|
@ -141,7 +141,7 @@ default $
|
|||
# Module: blueprint-parser
|
||||
# Variant:
|
||||
# Type: bootstrap_go_package
|
||||
# Factory: github.com/google/blueprint/bootstrap.func·001
|
||||
# Factory: github.com/google/blueprint/bootstrap.func·002
|
||||
# Defined: Blueprints:31:1
|
||||
|
||||
build .bootstrap/blueprint-parser/pkg/github.com/google/blueprint/parser.a: $
|
||||
|
@ -156,7 +156,7 @@ default .bootstrap/blueprint-parser/pkg/github.com/google/blueprint/parser.a
|
|||
# Module: blueprint-pathtools
|
||||
# Variant:
|
||||
# Type: bootstrap_go_package
|
||||
# Factory: github.com/google/blueprint/bootstrap.func·001
|
||||
# Factory: github.com/google/blueprint/bootstrap.func·002
|
||||
# Defined: Blueprints:52:1
|
||||
|
||||
build $
|
||||
|
@ -171,7 +171,7 @@ default $
|
|||
# Module: blueprint-proptools
|
||||
# Variant:
|
||||
# Type: bootstrap_go_package
|
||||
# Factory: github.com/google/blueprint/bootstrap.func·001
|
||||
# Factory: github.com/google/blueprint/bootstrap.func·002
|
||||
# Defined: Blueprints:64:1
|
||||
|
||||
build $
|
||||
|
@ -182,55 +182,11 @@ build $
|
|||
default $
|
||||
.bootstrap/blueprint-proptools/pkg/github.com/google/blueprint/proptools.a
|
||||
|
||||
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
|
||||
# Module: bpfmt
|
||||
# Variant:
|
||||
# Type: bootstrap_go_binary
|
||||
# Factory: github.com/google/blueprint/bootstrap.func·002
|
||||
# Defined: Blueprints:110:1
|
||||
|
||||
build .bootstrap/bpfmt/obj/bpfmt.a: g.bootstrap.gc $
|
||||
${g.bootstrap.srcDir}/bpfmt/bpfmt.go | ${g.bootstrap.gcCmd} $
|
||||
.bootstrap/blueprint-parser/pkg/github.com/google/blueprint/parser.a
|
||||
incFlags = -I .bootstrap/blueprint-parser/pkg
|
||||
pkgPath = bpfmt
|
||||
default .bootstrap/bpfmt/obj/bpfmt.a
|
||||
|
||||
build .bootstrap/bpfmt/obj/a.out: g.bootstrap.link $
|
||||
.bootstrap/bpfmt/obj/bpfmt.a | ${g.bootstrap.linkCmd}
|
||||
libDirFlags = -L .bootstrap/blueprint-parser/pkg
|
||||
default .bootstrap/bpfmt/obj/a.out
|
||||
|
||||
build .bootstrap/bin/bpfmt: g.bootstrap.cp .bootstrap/bpfmt/obj/a.out
|
||||
default .bootstrap/bin/bpfmt
|
||||
|
||||
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
|
||||
# Module: bpmodify
|
||||
# Variant:
|
||||
# Type: bootstrap_go_binary
|
||||
# Factory: github.com/google/blueprint/bootstrap.func·002
|
||||
# Defined: Blueprints:116:1
|
||||
|
||||
build .bootstrap/bpmodify/obj/bpmodify.a: g.bootstrap.gc $
|
||||
${g.bootstrap.srcDir}/bpmodify/bpmodify.go | ${g.bootstrap.gcCmd} $
|
||||
.bootstrap/blueprint-parser/pkg/github.com/google/blueprint/parser.a
|
||||
incFlags = -I .bootstrap/blueprint-parser/pkg
|
||||
pkgPath = bpmodify
|
||||
default .bootstrap/bpmodify/obj/bpmodify.a
|
||||
|
||||
build .bootstrap/bpmodify/obj/a.out: g.bootstrap.link $
|
||||
.bootstrap/bpmodify/obj/bpmodify.a | ${g.bootstrap.linkCmd}
|
||||
libDirFlags = -L .bootstrap/blueprint-parser/pkg
|
||||
default .bootstrap/bpmodify/obj/a.out
|
||||
|
||||
build .bootstrap/bin/bpmodify: g.bootstrap.cp .bootstrap/bpmodify/obj/a.out
|
||||
default .bootstrap/bin/bpmodify
|
||||
|
||||
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
|
||||
# Module: choosestage
|
||||
# Variant:
|
||||
# Type: bootstrap_go_binary
|
||||
# Factory: github.com/google/blueprint/bootstrap.func·002
|
||||
# Type: bootstrap_core_go_binary
|
||||
# Factory: github.com/google/blueprint/bootstrap.func·003
|
||||
# Defined: Blueprints:127:1
|
||||
|
||||
build .bootstrap/choosestage/obj/choosestage.a: g.bootstrap.gc $
|
||||
|
@ -249,8 +205,8 @@ default .bootstrap/bin/choosestage
|
|||
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
|
||||
# Module: gotestmain
|
||||
# Variant:
|
||||
# Type: bootstrap_go_binary
|
||||
# Factory: github.com/google/blueprint/bootstrap.func·002
|
||||
# Type: bootstrap_core_go_binary
|
||||
# Factory: github.com/google/blueprint/bootstrap.func·003
|
||||
# Defined: Blueprints:122:1
|
||||
|
||||
build .bootstrap/gotestmain/obj/gotestmain.a: g.bootstrap.gc $
|
||||
|
@ -268,8 +224,8 @@ default .bootstrap/bin/gotestmain
|
|||
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
|
||||
# Module: minibp
|
||||
# Variant:
|
||||
# Type: bootstrap_go_binary
|
||||
# Factory: github.com/google/blueprint/bootstrap.func·002
|
||||
# Type: bootstrap_core_go_binary
|
||||
# Factory: github.com/google/blueprint/bootstrap.func·003
|
||||
# Defined: Blueprints:101:1
|
||||
|
||||
build .bootstrap/minibp/obj/minibp.a: g.bootstrap.gc $
|
||||
|
@ -295,7 +251,12 @@ default .bootstrap/bin/minibp
|
|||
|
||||
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
|
||||
# Singleton: bootstrap
|
||||
# Factory: github.com/google/blueprint/bootstrap.func·007
|
||||
# Factory: github.com/google/blueprint/bootstrap.func·008
|
||||
|
||||
rule s.bootstrap.primarybp
|
||||
command = .bootstrap/bin/minibp --build-primary ${runTests} -m ${g.bootstrap.bootstrapManifest} --timestamp ${timestamp} --timestampdep ${timestampdep} -d ${outfile}.d -o ${outfile} ${in}
|
||||
depfile = ${outfile}.d
|
||||
description = minibp ${outfile}
|
||||
|
||||
rule s.bootstrap.minibp
|
||||
command = .bootstrap/bin/minibp ${runTests} -m ${g.bootstrap.bootstrapManifest} -d ${out}.d -o ${out} ${in}
|
||||
|
@ -303,37 +264,23 @@ rule s.bootstrap.minibp
|
|||
description = minibp ${out}
|
||||
generator = true
|
||||
|
||||
rule s.bootstrap.bigbp
|
||||
command = .bootstrap/bin/minibp -p -m ${g.bootstrap.bootstrapManifest} --timestamp ${timestamp} --timestampdep ${timestampdep} -d ${outfile}.d -o ${outfile} ${in}
|
||||
depfile = ${outfile}.d
|
||||
description = minibp ${outfile}
|
||||
|
||||
rule s.bootstrap.bigbpDocs
|
||||
command = .bootstrap/bin/minibp -p --docs ${out} ${g.bootstrap.srcDir}/Blueprints
|
||||
description = minibp docs ${out}
|
||||
build .bootstrap/primary.ninja.in .bootstrap/primary.ninja.in.timestamp: $
|
||||
s.bootstrap.primarybp ${g.bootstrap.srcDir}/Blueprints | $
|
||||
.bootstrap/bin/choosestage .bootstrap/bin/gotestmain $
|
||||
.bootstrap/bin/minibp ${g.bootstrap.srcDir}/Blueprints
|
||||
outfile = .bootstrap/primary.ninja.in
|
||||
timestamp = .bootstrap/primary.ninja.in.timestamp
|
||||
timestampdep = .bootstrap/primary.ninja.in.timestamp.d
|
||||
default .bootstrap/primary.ninja.in .bootstrap/primary.ninja.in.timestamp
|
||||
|
||||
build .bootstrap/bootstrap.ninja.in: s.bootstrap.minibp $
|
||||
${g.bootstrap.srcDir}/Blueprints | ${g.bootstrap.bootstrapManifest} $
|
||||
.bootstrap/bin/minibp
|
||||
default .bootstrap/bootstrap.ninja.in
|
||||
build .bootstrap/main.ninja.in .bootstrap/main.ninja.in.timestamp: $
|
||||
s.bootstrap.bigbp ${g.bootstrap.srcDir}/Blueprints | $
|
||||
.bootstrap/bin/bpfmt .bootstrap/bin/bpmodify $
|
||||
.bootstrap/bin/choosestage .bootstrap/bin/gotestmain $
|
||||
.bootstrap/bin/minibp ${g.bootstrap.srcDir}/Blueprints $
|
||||
.bootstrap/docs/minibp.html
|
||||
outfile = .bootstrap/main.ninja.in
|
||||
timestamp = .bootstrap/main.ninja.in.timestamp
|
||||
timestampdep = .bootstrap/main.ninja.in.timestamp.d
|
||||
default .bootstrap/main.ninja.in .bootstrap/main.ninja.in.timestamp
|
||||
|
||||
build .bootstrap/docs/minibp.html: s.bootstrap.bigbpDocs | $
|
||||
.bootstrap/bin/minibp
|
||||
default .bootstrap/docs/minibp.html
|
||||
build .bootstrap/notAFile: phony
|
||||
default .bootstrap/notAFile
|
||||
build .bootstrap/build.ninja.in: g.bootstrap.chooseStage $
|
||||
.bootstrap/bootstrap.ninja.in .bootstrap/main.ninja.in | $
|
||||
.bootstrap/bootstrap.ninja.in .bootstrap/primary.ninja.in | $
|
||||
${g.bootstrap.chooseStageCmd} ${g.bootstrap.bootstrapManifest} $
|
||||
.bootstrap/notAFile
|
||||
current = .bootstrap/bootstrap.ninja.in
|
||||
|
|
|
@ -1,2 +1,3 @@
|
|||
Choosing bootstrap.ninja.in for next stage
|
||||
Choosing primary.ninja.in for next stage
|
||||
Choosing main.ninja.in for next stage
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
Newer source version of build.ninja.in. Copying to bootstrap.ninja.in
|
||||
Choosing bootstrap.ninja.in for next stage
|
||||
Choosing primary.ninja.in for next stage
|
||||
Choosing main.ninja.in for next stage
|
||||
|
|
2
tests/expected_primary
Normal file
2
tests/expected_primary
Normal file
|
@ -0,0 +1,2 @@
|
|||
Choosing primary.ninja.in for next stage
|
||||
Choosing main.ninja.in for next stage
|
|
@ -1,2 +1,3 @@
|
|||
Choosing bootstrap.ninja.in for next stage
|
||||
Choosing primary.ninja.in for next stage
|
||||
Choosing main.ninja.in for next stage
|
||||
|
|
|
@ -2,4 +2,5 @@ Newer source version of src.build.ninja.in. Copying to bootstrap.ninja.in
|
|||
Choosing bootstrap.ninja.in for next stage
|
||||
Stage bootstrap.ninja.in has changed, restarting
|
||||
Choosing bootstrap.ninja.in for next stage
|
||||
Choosing primary.ninja.in for next stage
|
||||
Choosing main.ninja.in for next stage
|
||||
|
|
|
@ -1 +1,2 @@
|
|||
Choosing primary.ninja.in for next stage
|
||||
Choosing main.ninja.in for next stage
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
Stage bootstrap.ninja.in has changed, restarting
|
||||
Choosing bootstrap.ninja.in for next stage
|
||||
Choosing primary.ninja.in for next stage
|
||||
Choosing main.ninja.in for next stage
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
Stage bootstrap.ninja.in has changed, restarting
|
||||
Choosing bootstrap.ninja.in for next stage
|
||||
Choosing primary.ninja.in for next stage
|
||||
Choosing main.ninja.in for next stage
|
||||
|
|
|
@ -42,6 +42,11 @@ sleep 2
|
|||
touch ../Blueprints
|
||||
testcase all
|
||||
|
||||
# This test affects only the primary bootstrap stage
|
||||
sleep 2
|
||||
touch ../bpmodify/bpmodify.go
|
||||
testcase primary
|
||||
|
||||
# This test affects nothing, nothing should be done
|
||||
sleep 2
|
||||
testcase none
|
||||
|
|
Loading…
Reference in a new issue