Clean up unnecessary dependencies

Other than cleaning up the code, the only change in behavior is to run
the docs build in parallel with the primary builder, saving about a
second on a Soong bootstrap (10s -> 9s).

Change-Id: Iaff51d6d1a37af842f294f12db11d5774d48d440
This commit is contained in:
Dan Willemsen 2016-11-01 22:44:25 -07:00
parent b6d88a4f0a
commit 460c80eb12
3 changed files with 16 additions and 54 deletions

View file

@ -53,10 +53,10 @@ else
fi
# Build minibp and the primary build.ninja
"${NINJA}" -w dupbuild=err -f "${BUILDDIR}/.minibootstrap/build.ninja" "${BUILDDIR}/.bootstrap/build.ninja"
"${NINJA}" -w dupbuild=err -f "${BUILDDIR}/.minibootstrap/build.ninja"
# Build the primary builder and the main build.ninja
"${NINJA}" -w dupbuild=err -f "${BUILDDIR}/.bootstrap/build.ninja" "${BUILDDIR}/build.ninja"
"${NINJA}" -w dupbuild=err -f "${BUILDDIR}/.bootstrap/build.ninja"
# SKIP_NINJA can be used by wrappers that wish to run ninja themselves.
if [ -z "$SKIP_NINJA" ]; then

View file

@ -596,10 +596,6 @@ 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
// bootstrapDeps contains modules that will be built in StageBootstrap
var bootstrapDeps []string
// primaryBootstrapDeps contains modules that will be built in StagePrimary
var primaryBootstrapDeps []string
// blueprintTools contains blueprint go binaries that will be built in StageMain
var blueprintTools []string
ctx.VisitAllModulesIf(isBootstrapBinaryModule,
@ -608,12 +604,7 @@ func (s *singleton) GenerateBuildActions(ctx blueprint.SingletonContext) {
binaryModuleName := ctx.ModuleName(binaryModule)
installPath := filepath.Join(binaryModule.InstallPath(), binaryModuleName)
switch binaryModule.BuildStage() {
case StageBootstrap:
bootstrapDeps = append(bootstrapDeps, installPath)
case StagePrimary:
primaryBootstrapDeps = append(primaryBootstrapDeps, installPath)
case StageMain:
if binaryModule.BuildStage() == StageMain {
blueprintTools = append(blueprintTools, installPath)
}
if binaryModule.properties.PrimaryBuilder {
@ -653,35 +644,12 @@ func (s *singleton) GenerateBuildActions(ctx blueprint.SingletonContext) {
topLevelBlueprints := filepath.Join("$srcDir",
filepath.Base(s.config.topLevelBlueprintsFile))
bootstrapDeps = append(bootstrapDeps, topLevelBlueprints)
mainNinjaFile := filepath.Join("$buildDir", "build.ninja")
primaryBuilderNinjaFile := filepath.Join(bootstrapDir, "build.ninja")
bootstrapNinjaFileTemplate := filepath.Join(miniBootstrapDir, "build.ninja.in")
bootstrapNinjaFile := filepath.Join(miniBootstrapDir, "build.ninja")
docsFile := filepath.Join(docsDir, primaryBuilderName+".html")
primaryBootstrapDeps = append(primaryBootstrapDeps, 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
// run.
ctx.VisitAllModulesIf(isGoTestProducer,
func(module blueprint.Module) {
testModule := module.(goTestProducer)
target := testModule.GoTestTarget()
if target != "" {
switch testModule.BuildStage() {
case StageBootstrap:
bootstrapDeps = append(bootstrapDeps, target)
case StagePrimary:
primaryBootstrapDeps = append(primaryBootstrapDeps, target)
case StageMain:
blueprintTools = append(blueprintTools, target)
}
}
})
switch s.config.stage {
case StageBootstrap:
// We're generating a bootstrapper Ninja file, so we need to set things
@ -693,10 +661,9 @@ func (s *singleton) GenerateBuildActions(ctx blueprint.SingletonContext) {
// Generate the Ninja file to build the primary builder.
ctx.Build(pctx, blueprint.BuildParams{
Rule: generateBuildNinja,
Outputs: []string{primaryBuilderNinjaFile},
Inputs: []string{topLevelBlueprints},
Implicits: bootstrapDeps,
Rule: generateBuildNinja,
Outputs: []string{primaryBuilderNinjaFile},
Inputs: []string{topLevelBlueprints},
Args: map[string]string{
"builder": minibpFile,
"extra": "--build-primary" + extraTestFlags,
@ -730,10 +697,9 @@ func (s *singleton) GenerateBuildActions(ctx blueprint.SingletonContext) {
// Add a way to rebuild the primary build.ninja so that globs works
ctx.Build(pctx, blueprint.BuildParams{
Rule: generateBuildNinja,
Outputs: []string{primaryBuilderNinjaFile},
Inputs: []string{topLevelBlueprints},
Implicits: bootstrapDeps,
Rule: generateBuildNinja,
Outputs: []string{primaryBuilderNinjaFile},
Inputs: []string{topLevelBlueprints},
Args: map[string]string{
"builder": minibpFile,
"extra": "--build-primary" + extraTestFlags,
@ -743,10 +709,9 @@ func (s *singleton) GenerateBuildActions(ctx blueprint.SingletonContext) {
// Build the main build.ninja
ctx.Build(pctx, blueprint.BuildParams{
Rule: generateBuildNinja,
Outputs: []string{mainNinjaFile},
Inputs: []string{topLevelBlueprints},
Implicits: primaryBootstrapDeps,
Rule: generateBuildNinja,
Outputs: []string{mainNinjaFile},
Inputs: []string{topLevelBlueprints},
Args: map[string]string{
"builder": primaryBuilderFile,
"extra": primaryBuilderExtraFlags,
@ -777,10 +742,9 @@ func (s *singleton) GenerateBuildActions(ctx blueprint.SingletonContext) {
// Add a way to rebuild the main build.ninja in case it creates rules that
// it will depend on itself. (In Android, globs with soong_glob)
ctx.Build(pctx, blueprint.BuildParams{
Rule: generateBuildNinja,
Outputs: []string{mainNinjaFile},
Inputs: []string{topLevelBlueprints},
Implicits: primaryBootstrapDeps,
Rule: generateBuildNinja,
Outputs: []string{mainNinjaFile},
Inputs: []string{topLevelBlueprints},
Args: map[string]string{
"builder": primaryBuilderFile,
"extra": primaryBuilderExtraFlags,

View file

@ -270,9 +270,7 @@ default ${g.bootstrap.BinDir}/minibp
# Factory: github.com/google/blueprint/bootstrap.newSingletonFactory.func1
build ${g.bootstrap.buildDir}/.bootstrap/build.ninja: g.bootstrap.build.ninja $
${g.bootstrap.srcDir}/Blueprints | ${builder} $
${g.bootstrap.BinDir}/gotestmain ${g.bootstrap.BinDir}/gotestrunner $
${g.bootstrap.BinDir}/minibp ${g.bootstrap.srcDir}/Blueprints
${g.bootstrap.srcDir}/Blueprints | ${builder}
builder = ${g.bootstrap.BinDir}/minibp
extra = --build-primary
default ${g.bootstrap.buildDir}/.bootstrap/build.ninja