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
diff --git a/Blueprints b/Blueprints
index 3845ad0..173017a 100644
--- a/Blueprints
+++ b/Blueprints
@@ -98,7 +98,7 @@
],
)
-bootstrap_go_binary(
+bootstrap_core_go_binary(
name = "minibp",
deps = [
"blueprint",
@@ -119,12 +119,12 @@
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"],
)
diff --git a/bootstrap/bootstrap.go b/bootstrap/bootstrap.go
index 3023b08..7ed2a44 100644
--- a/bootstrap/bootstrap.go
+++ b/bootstrap/bootstrap.go
@@ -24,6 +24,7 @@
)
const bootstrapDir = ".bootstrap"
+const miniBootstrapDir = ".minibootstrap"
var (
pctx = blueprint.NewPackageContext("github.com/google/blueprint/bootstrap")
@@ -105,6 +106,23 @@
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 @@
type goTestProducer interface {
GoTestTarget() string
+ BuildStage() Stage
}
func isGoTestProducer(module blueprint.Module) bool {
@@ -155,6 +174,9 @@
// The bootstrap Config
config *Config
+
+ // The stage in which this module should be built
+ buildStage Stage
}
var _ goPackageProducer = (*goPackage)(nil)
@@ -180,6 +202,14 @@
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 @@
// 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 @@
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 @@
// 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 @@
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 @@
// 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 @@
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 @@
// 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 @@
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 @@
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 @@
// 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 @@
},
"runTests")
- args := map[string]string{}
+ args = map[string]string{}
if s.config.runGoTests {
args["runTests"] = "-t"
@@ -588,6 +675,34 @@
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 @@
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 @@
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 @@
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,9 +803,19 @@
// 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 @@
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",
diff --git a/bootstrap/cleanup.go b/bootstrap/cleanup.go
index ba9fd48..dd698f4 100644
--- a/bootstrap/cleanup.go
+++ b/bootstrap/cleanup.go
@@ -33,7 +33,10 @@
srcDir, manifestFile string) error {
buildDir := "."
- if config.stage == StageBootstrap {
+ switch config.stage {
+ case StageBootstrap:
+ buildDir = miniBootstrapDir
+ case StagePrimary:
buildDir = bootstrapDir
}
diff --git a/bootstrap/command.go b/bootstrap/command.go
index 4fb9c51..33c4227 100644
--- a/bootstrap/command.go
+++ b/bootstrap/command.go
@@ -76,6 +76,9 @@
if c.GeneratingBootstrapper() {
stage = StageBootstrap
}
+ if c.GeneratingPrimaryBuilder() {
+ stage = StagePrimary
+ }
}
bootstrapConfig := &Config{
@@ -85,7 +88,9 @@
}
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)
diff --git a/bootstrap/config.go b/bootstrap/config.go
index ab3b160..b236cc7 100644
--- a/bootstrap/config.go
+++ b/bootstrap/config.go
@@ -36,12 +36,16 @@
// 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
)
diff --git a/bootstrap/minibp/main.go b/bootstrap/minibp/main.go
index ad36c29..4e25bc8 100644
--- a/bootstrap/minibp/main.go
+++ b/bootstrap/minibp/main.go
@@ -21,15 +21,24 @@
)
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 @@
ctx.SetIgnoreUnknownModuleTypes(true)
}
- config := Config(!runAsPrimaryBuilder)
+ config := Config{
+ generatingBootstrapper: !runAsPrimaryBuilder && !buildPrimaryBuilder,
+ generatingPrimaryBuilder: !runAsPrimaryBuilder && buildPrimaryBuilder,
+ }
bootstrap.Main(ctx, config)
}
diff --git a/build.ninja.in b/build.ninja.in
index 183e954..a5a353a 100644
--- a/build.ninja.in
+++ b/build.ninja.in
@@ -31,7 +31,7 @@
g.bootstrap.srcDir = @@SrcDir@@
-builddir = .bootstrap
+builddir = .minibootstrap
rule g.bootstrap.bootstrap
command = ${g.bootstrap.bootstrapCmd} -i ${in}
@@ -58,7 +58,7 @@
# 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 @@
# 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 @@
# 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 @@
# 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 @@
# 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 @@
# 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 @@
# 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 $
@@ -183,54 +183,10 @@
.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 @@
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# 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 @@
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# 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 @@
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# 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 @@
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
diff --git a/tests/expected_all b/tests/expected_all
index a92f0b3..b16fc78 100644
--- a/tests/expected_all
+++ b/tests/expected_all
@@ -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
diff --git a/tests/expected_manifest b/tests/expected_manifest
index ab67d4b..3970edb 100644
--- a/tests/expected_manifest
+++ b/tests/expected_manifest
@@ -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
diff --git a/tests/expected_primary b/tests/expected_primary
new file mode 100644
index 0000000..43f2d35
--- /dev/null
+++ b/tests/expected_primary
@@ -0,0 +1,2 @@
+Choosing primary.ninja.in for next stage
+Choosing main.ninja.in for next stage
diff --git a/tests/expected_rebuild_test b/tests/expected_rebuild_test
index a92f0b3..b16fc78 100644
--- a/tests/expected_rebuild_test
+++ b/tests/expected_rebuild_test
@@ -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
diff --git a/tests/expected_regen b/tests/expected_regen
index 4f7adaa..e2e10b8 100644
--- a/tests/expected_regen
+++ b/tests/expected_regen
@@ -2,4 +2,5 @@
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
diff --git a/tests/expected_start b/tests/expected_start
index dc55ac3..43f2d35 100644
--- a/tests/expected_start
+++ b/tests/expected_start
@@ -1 +1,2 @@
+Choosing primary.ninja.in for next stage
Choosing main.ninja.in for next stage
diff --git a/tests/expected_start2 b/tests/expected_start2
index d0b3900..4c339e2 100644
--- a/tests/expected_start2
+++ b/tests/expected_start2
@@ -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
diff --git a/tests/expected_start_add_tests b/tests/expected_start_add_tests
index d0b3900..4c339e2 100644
--- a/tests/expected_start_add_tests
+++ b/tests/expected_start_add_tests
@@ -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
diff --git a/tests/test.sh b/tests/test.sh
index 08caa64..e27ae97 100755
--- a/tests/test.sh
+++ b/tests/test.sh
@@ -42,6 +42,11 @@
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