2015-01-23 23:15:10 +01:00
|
|
|
// Copyright 2014 Google Inc. All rights reserved.
|
|
|
|
//
|
|
|
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
// you may not use this file except in compliance with the License.
|
|
|
|
// You may obtain a copy of the License at
|
|
|
|
//
|
|
|
|
// http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
//
|
|
|
|
// Unless required by applicable law or agreed to in writing, software
|
|
|
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
// See the License for the specific language governing permissions and
|
|
|
|
// limitations under the License.
|
|
|
|
|
2014-05-28 01:34:41 +02:00
|
|
|
package bootstrap
|
|
|
|
|
|
|
|
var (
|
2014-06-12 00:51:08 +02:00
|
|
|
// These variables are the only configuration needed by the boostrap
|
2014-05-28 01:34:41 +02:00
|
|
|
// modules. They are always set to the variable name enclosed in "@@" so
|
|
|
|
// that their values can be easily replaced in the generated Ninja file.
|
2014-11-09 20:52:56 +01:00
|
|
|
srcDir = pctx.StaticVariable("srcDir", "@@SrcDir@@")
|
2015-07-14 03:11:49 +02:00
|
|
|
buildDir = pctx.StaticVariable("buildDir", "@@BuildDir@@")
|
2014-11-09 20:52:56 +01:00
|
|
|
goRoot = pctx.StaticVariable("goRoot", "@@GoRoot@@")
|
2015-08-02 00:07:27 +02:00
|
|
|
compileCmd = pctx.StaticVariable("compileCmd", "@@GoCompile@@")
|
|
|
|
linkCmd = pctx.StaticVariable("linkCmd", "@@GoLink@@")
|
2014-11-09 20:52:56 +01:00
|
|
|
bootstrapCmd = pctx.StaticVariable("bootstrapCmd", "@@Bootstrap@@")
|
|
|
|
bootstrapManifest = pctx.StaticVariable("bootstrapManifest",
|
2014-05-28 01:34:41 +02:00
|
|
|
"@@BootstrapManifest@@")
|
|
|
|
)
|
|
|
|
|
2015-06-25 04:21:21 +02:00
|
|
|
type ConfigInterface interface {
|
2014-05-28 01:34:41 +02:00
|
|
|
// GeneratingBootstrapper should return true if this build invocation is
|
|
|
|
// creating a build.ninja.in file to be used in a build bootstrapping
|
|
|
|
// sequence.
|
|
|
|
GeneratingBootstrapper() bool
|
2015-07-23 02:06:06 +02:00
|
|
|
// 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
|
2014-05-28 01:34:41 +02:00
|
|
|
}
|
2015-06-25 04:21:21 +02:00
|
|
|
|
2015-11-18 01:16:58 +01:00
|
|
|
type ConfigRemoveAbandonedFiles interface {
|
|
|
|
// RemoveAbandonedFiles should return true if files listed in the
|
|
|
|
// .ninja_log but not the output build.ninja file should be deleted.
|
|
|
|
RemoveAbandonedFiles() bool
|
|
|
|
}
|
|
|
|
|
Enhance bootstrap stage selection
This simplifies the bootstrap process while making it more flexible by
moving the stage selection into a go binary(choosestage). It will now be
possible to have more than two build stages.
Now each stage has a ninja template(main.ninja.in) and a timestamp
file(main.ninja.in.timestamp). The timestamp file may be updated by any
build stage that wishes to regenerate the ninja template. If the
choosestage binaries sees that the timestamp is newer than the template,
it will choose the prior stage.
The main stage no longer writes to the source tree to update the
build.ninja.in file. This was a problem for read-only source trees.
Instead, the choosestage binary first checks to see if that file is
newer than the last bootstrap.ninja.in, copies it in place, and starts
the boostrap stage.
The bootstrap stage regenerates it's own ninja template, but that
required a loop through the main stage to actually run it. The
choosestage binary now detects if the template has changed for the
current stage, and will restart the stage.
One change is that if dependencies do get messed up, instead of silently
failing, there's a higher chance that the bootstrap step will just
continue looping, doing nothing. This can happen if the main stage
has a dependency that triggers the bootstrap stage, but the bootstrap
stage doesn't see anything required to rebuild the main ninja file. A
side effect of this requirement is that changes to test code will now
rebuild the main ninja file.
Change-Id: I9965cfba79dc0dbbd3af05f5944f7653054455a2
2015-07-23 02:05:59 +02:00
|
|
|
type Stage int
|
|
|
|
|
|
|
|
const (
|
|
|
|
StageBootstrap Stage = iota
|
2015-07-23 02:06:06 +02:00
|
|
|
StagePrimary
|
Enhance bootstrap stage selection
This simplifies the bootstrap process while making it more flexible by
moving the stage selection into a go binary(choosestage). It will now be
possible to have more than two build stages.
Now each stage has a ninja template(main.ninja.in) and a timestamp
file(main.ninja.in.timestamp). The timestamp file may be updated by any
build stage that wishes to regenerate the ninja template. If the
choosestage binaries sees that the timestamp is newer than the template,
it will choose the prior stage.
The main stage no longer writes to the source tree to update the
build.ninja.in file. This was a problem for read-only source trees.
Instead, the choosestage binary first checks to see if that file is
newer than the last bootstrap.ninja.in, copies it in place, and starts
the boostrap stage.
The bootstrap stage regenerates it's own ninja template, but that
required a loop through the main stage to actually run it. The
choosestage binary now detects if the template has changed for the
current stage, and will restart the stage.
One change is that if dependencies do get messed up, instead of silently
failing, there's a higher chance that the bootstrap step will just
continue looping, doing nothing. This can happen if the main stage
has a dependency that triggers the bootstrap stage, but the bootstrap
stage doesn't see anything required to rebuild the main ninja file. A
side effect of this requirement is that changes to test code will now
rebuild the main ninja file.
Change-Id: I9965cfba79dc0dbbd3af05f5944f7653054455a2
2015-07-23 02:05:59 +02:00
|
|
|
StageMain
|
|
|
|
)
|
|
|
|
|
2015-06-25 04:21:21 +02:00
|
|
|
type Config struct {
|
Enhance bootstrap stage selection
This simplifies the bootstrap process while making it more flexible by
moving the stage selection into a go binary(choosestage). It will now be
possible to have more than two build stages.
Now each stage has a ninja template(main.ninja.in) and a timestamp
file(main.ninja.in.timestamp). The timestamp file may be updated by any
build stage that wishes to regenerate the ninja template. If the
choosestage binaries sees that the timestamp is newer than the template,
it will choose the prior stage.
The main stage no longer writes to the source tree to update the
build.ninja.in file. This was a problem for read-only source trees.
Instead, the choosestage binary first checks to see if that file is
newer than the last bootstrap.ninja.in, copies it in place, and starts
the boostrap stage.
The bootstrap stage regenerates it's own ninja template, but that
required a loop through the main stage to actually run it. The
choosestage binary now detects if the template has changed for the
current stage, and will restart the stage.
One change is that if dependencies do get messed up, instead of silently
failing, there's a higher chance that the bootstrap step will just
continue looping, doing nothing. This can happen if the main stage
has a dependency that triggers the bootstrap stage, but the bootstrap
stage doesn't see anything required to rebuild the main ninja file. A
side effect of this requirement is that changes to test code will now
rebuild the main ninja file.
Change-Id: I9965cfba79dc0dbbd3af05f5944f7653054455a2
2015-07-23 02:05:59 +02:00
|
|
|
stage Stage
|
2015-06-25 04:21:21 +02:00
|
|
|
|
|
|
|
topLevelBlueprintsFile string
|
2015-06-24 02:21:00 +02:00
|
|
|
|
|
|
|
runGoTests bool
|
2015-06-25 04:21:21 +02:00
|
|
|
}
|