Simplify bootstrapping

Follow changes from https://github.com/google/blueprint/pull/121

Change-Id: Icc5003f6e8592a667e1ce5e58361c03997078763
diff --git a/build.ninja.in b/build.ninja.in
index 0122a20..ec1bc0d 100644
--- a/build.ninja.in
+++ b/build.ninja.in
@@ -15,10 +15,6 @@
 
 g.bootstrap.bootstrapCmd = @@Bootstrap@@
 
-g.bootstrap.bootstrapManifest = @@BootstrapManifest@@
-
-g.bootstrap.chooseStageCmd = ${g.bootstrap.buildDir}/.bootstrap/bin/choosestage
-
 g.bootstrap.compileCmd = @@GoCompile@@
 
 g.bootstrap.goRoot = @@GoRoot@@
@@ -38,10 +34,6 @@
     description = bootstrap ${in}
     generator = true
 
-rule g.bootstrap.chooseStage
-    command = ${g.bootstrap.chooseStageCmd} --current ${current} --bootstrap ${g.bootstrap.bootstrapManifest} -o ${out} ${in}
-    description = choosing next stage
-
 rule g.bootstrap.compile
     command = GOROOT='${g.bootstrap.goRoot}' ${g.bootstrap.compileCmd} -o ${out} -p ${pkgPath} -complete ${incFlags} -pack ${in}
     description = compile ${out}
@@ -421,30 +413,6 @@
         ${g.bootstrap.buildDir}/.bootstrap/blueprint-proptools/pkg/github.com/google/blueprint/proptools.a
 
 # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
-# Module:  choosestage
-# Variant:
-# Type:    bootstrap_core_go_binary
-# Factory: github.com/google/blueprint/bootstrap.newGoBinaryModuleFactory.func1
-# Defined: build/blueprint/Blueprints:145:1
-
-build ${g.bootstrap.buildDir}/.bootstrap/choosestage/obj/choosestage.a: $
-        g.bootstrap.compile $
-        ${g.bootstrap.srcDir}/build/blueprint/choosestage/choosestage.go | $
-        ${g.bootstrap.compileCmd}
-    pkgPath = choosestage
-default ${g.bootstrap.buildDir}/.bootstrap/choosestage/obj/choosestage.a
-
-build ${g.bootstrap.buildDir}/.bootstrap/choosestage/obj/a.out: $
-        g.bootstrap.link $
-        ${g.bootstrap.buildDir}/.bootstrap/choosestage/obj/choosestage.a | $
-        ${g.bootstrap.linkCmd}
-default ${g.bootstrap.buildDir}/.bootstrap/choosestage/obj/a.out
-
-build ${g.bootstrap.BinDir}/choosestage: g.bootstrap.cp $
-        ${g.bootstrap.buildDir}/.bootstrap/choosestage/obj/a.out
-default ${g.bootstrap.BinDir}/choosestage
-
-# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
 # Module:  gotestmain
 # Variant:
 # Type:    bootstrap_core_go_binary
@@ -529,53 +497,37 @@
 # Factory:   github.com/google/blueprint/bootstrap.newSingletonFactory.func1
 
 rule s.bootstrap.primarybp
-    command = ${g.bootstrap.BinDir}/minibp --build-primary ${runTests} -m ${g.bootstrap.bootstrapManifest} --timestamp ${timestamp} --timestampdep ${timestampdep} -b ${g.bootstrap.buildDir} -d ${outfile}.d -o ${outfile} ${in}
+    command = ${g.bootstrap.BinDir}/minibp --build-primary ${runTests} -b ${g.bootstrap.buildDir} -d ${outfile}.d -o ${outfile} ${in}
     depfile = ${outfile}.d
     description = minibp ${outfile}
 
 rule s.bootstrap.minibp
-    command = ${g.bootstrap.BinDir}/minibp ${runTests} -m ${g.bootstrap.bootstrapManifest} -b ${g.bootstrap.buildDir} -d ${out}.d -o ${out} ${in}
+    command = ${g.bootstrap.BinDir}/minibp ${runTests} -b ${g.bootstrap.buildDir} -d ${out}.d -o ${out} ${in}
     depfile = ${out}.d
     description = minibp ${out}
-    generator = true
+    restat = true
 
-build ${g.bootstrap.buildDir}/.bootstrap/primary.ninja.in $
-        ${g.bootstrap.buildDir}/.bootstrap/primary.ninja.in.timestamp: $
-        s.bootstrap.primarybp ${g.bootstrap.srcDir}/Android.bp | $
-        ${g.bootstrap.BinDir}/choosestage ${g.bootstrap.BinDir}/gotestmain $
+build ${g.bootstrap.buildDir}/.bootstrap/build.ninja: s.bootstrap.primarybp $
+        ${g.bootstrap.srcDir}/Android.bp | ${g.bootstrap.BinDir}/gotestmain $
         ${g.bootstrap.BinDir}/gotestrunner ${g.bootstrap.BinDir}/minibp $
         ${g.bootstrap.srcDir}/Android.bp $
         ${g.bootstrap.buildDir}/.bootstrap/blueprint/test/github.com/google/blueprint.a $
         ${g.bootstrap.buildDir}/.bootstrap/blueprint-parser/test/github.com/google/blueprint/parser.a $
         ${g.bootstrap.buildDir}/.bootstrap/blueprint-pathtools/test/github.com/google/blueprint/pathtools.a $
         ${g.bootstrap.buildDir}/.bootstrap/blueprint-proptools/test/github.com/google/blueprint/proptools.a
-    outfile = ${g.bootstrap.buildDir}/.bootstrap/primary.ninja.in
+    outfile = ${g.bootstrap.buildDir}/.bootstrap/build.ninja
     runTests = -t
-    timestamp = ${g.bootstrap.buildDir}/.bootstrap/primary.ninja.in.timestamp
-    timestampdep = ${g.bootstrap.buildDir}/.bootstrap/primary.ninja.in.timestamp.d
-default ${g.bootstrap.buildDir}/.bootstrap/primary.ninja.in $
-        ${g.bootstrap.buildDir}/.bootstrap/primary.ninja.in.timestamp
+default ${g.bootstrap.buildDir}/.bootstrap/build.ninja
 
-build ${g.bootstrap.buildDir}/.bootstrap/bootstrap.ninja.in: $
+build ${g.bootstrap.buildDir}/.minibootstrap/build.ninja.in: $
         s.bootstrap.minibp ${g.bootstrap.srcDir}/Android.bp | $
-        ${g.bootstrap.bootstrapManifest} ${g.bootstrap.BinDir}/minibp
+        ${g.bootstrap.BinDir}/minibp
     runTests = -t
-default ${g.bootstrap.buildDir}/.bootstrap/bootstrap.ninja.in
+default ${g.bootstrap.buildDir}/.minibootstrap/build.ninja.in
 
-build ${g.bootstrap.buildDir}/.bootstrap/notAFile: phony
-default ${g.bootstrap.buildDir}/.bootstrap/notAFile
-
-build ${g.bootstrap.buildDir}/.bootstrap/build.ninja.in: $
-        g.bootstrap.chooseStage $
-        ${g.bootstrap.buildDir}/.bootstrap/bootstrap.ninja.in $
-        ${g.bootstrap.buildDir}/.bootstrap/primary.ninja.in | $
-        ${g.bootstrap.chooseStageCmd} ${g.bootstrap.bootstrapManifest} $
-        ${g.bootstrap.buildDir}/.bootstrap/notAFile
-    current = ${g.bootstrap.buildDir}/.bootstrap/bootstrap.ninja.in
-default ${g.bootstrap.buildDir}/.bootstrap/build.ninja.in
-
-build ${g.bootstrap.buildDir}/build.ninja: g.bootstrap.bootstrap $
-        ${g.bootstrap.buildDir}/.bootstrap/build.ninja.in | $
+build ${g.bootstrap.buildDir}/.minibootstrap/build.ninja: $
+        g.bootstrap.bootstrap $
+        ${g.bootstrap.buildDir}/.minibootstrap/build.ninja.in | $
         ${g.bootstrap.bootstrapCmd}
-default ${g.bootstrap.buildDir}/build.ninja
+default ${g.bootstrap.buildDir}/.minibootstrap/build.ninja
 
diff --git a/soong.bash b/soong.bash
index 6684681..1dbf4e4 100755
--- a/soong.bash
+++ b/soong.bash
@@ -20,9 +20,6 @@
 # $BOOTSTRAP are correct
 cd ${SRCDIR_FROM_BUILDDIR}
 
-# Run the blueprint wrapper
-BUILDDIR="${BUILDDIR}" SKIP_NINJA=true build/blueprint/blueprint.bash
-
 # Ninja can't depend on environment variables, so do a manual comparison
 # of the relevant environment variables from the last build using the
 # soong_env tool and trigger a build manifest regeneration if necessary
@@ -40,4 +37,4 @@
     fi
 fi
 
-"prebuilts/build-tools/${PREBUILTOS}/bin/ninja" -f "${BUILDDIR}/build.ninja" -w dupbuild=err "$@"
+BUILDDIR="${BUILDDIR}" NINJA="prebuilts/build-tools/${PREBUILTOS}/bin/ninja" build/blueprint/blueprint.bash "$@"