Merge "[mips] Disable compact branch generation"
diff --git a/android/config.go b/android/config.go
index 21a7233..b29012c 100644
--- a/android/config.go
+++ b/android/config.go
@@ -337,10 +337,6 @@
 	return Bool(c.ProductVariables.DevicePrefer32BitExecutables)
 }
 
-func (c *config) HostPrefer32BitExecutables() bool {
-	return Bool(c.ProductVariables.HostPrefer32BitExecutables)
-}
-
 func (c *config) SkipDeviceInstall() bool {
 	return c.EmbeddedInMake() || Bool(c.Mega_device)
 }
@@ -369,6 +365,10 @@
 	return false
 }
 
+func (c *config) UseGoma() bool {
+	return Bool(c.ProductVariables.UseGoma)
+}
+
 func (c *config) LibartImgHostBaseAddress() string {
 	return "0x60000000"
 }
diff --git a/android/defs.go b/android/defs.go
index 9c6527d..6e28de7 100644
--- a/android/defs.go
+++ b/android/defs.go
@@ -28,7 +28,7 @@
 	// A phony rule that is not the built-in Ninja phony rule.  The built-in
 	// phony rule has special behavior that is sometimes not desired.  See the
 	// Ninja docs for more details.
-	Phony = pctx.StaticRule("Phony",
+	Phony = pctx.AndroidStaticRule("Phony",
 		blueprint.RuleParams{
 			Command:     "# phony $out",
 			Description: "phony $out",
@@ -37,7 +37,7 @@
 	// GeneratedFile is a rule for indicating that a given file was generated
 	// while running soong.  This allows the file to be cleaned up if it ever
 	// stops being generated by soong.
-	GeneratedFile = pctx.StaticRule("GeneratedFile",
+	GeneratedFile = pctx.AndroidStaticRule("GeneratedFile",
 		blueprint.RuleParams{
 			Command:     "# generated $out",
 			Description: "generated $out",
@@ -45,7 +45,7 @@
 		})
 
 	// A copy rule.
-	Cp = pctx.StaticRule("Cp",
+	Cp = pctx.AndroidStaticRule("Cp",
 		blueprint.RuleParams{
 			Command:     "cp $cpPreserveSymlinks $cpFlags $in $out",
 			Description: "cp $out",
@@ -53,26 +53,29 @@
 		"cpFlags")
 
 	// A timestamp touch rule.
-	Touch = pctx.StaticRule("Touch",
+	Touch = pctx.AndroidStaticRule("Touch",
 		blueprint.RuleParams{
 			Command:     "touch $out",
 			Description: "touch $out",
 		})
 
 	// A symlink rule.
-	Symlink = pctx.StaticRule("Symlink",
+	Symlink = pctx.AndroidStaticRule("Symlink",
 		blueprint.RuleParams{
 			Command:     "ln -f -s $fromPath $out",
 			Description: "symlink $out",
 		},
 		"fromPath")
 
-	ErrorRule = pctx.StaticRule("Error",
+	ErrorRule = pctx.AndroidStaticRule("Error",
 		blueprint.RuleParams{
 			Command:     `echo "$error" && false`,
 			Description: "error building $out",
 		},
 		"error")
+
+	// Used only when USE_GOMA=true is set, to restrict non-goma jobs to the local parallelism value
+	localPool = blueprint.NewBuiltinPool("local_pool")
 )
 
 func init() {
diff --git a/android/glob.go b/android/glob.go
index 34b3de4..0457cbc 100644
--- a/android/glob.go
+++ b/android/glob.go
@@ -43,7 +43,7 @@
 
 	// globRule rule traverses directories to produce a list of files that match $glob
 	// and writes it to $out if it has changed, and writes the directories to $out.d
-	globRule = pctx.StaticRule("globRule",
+	globRule = pctx.AndroidStaticRule("globRule",
 		blueprint.RuleParams{
 			Command:     fmt.Sprintf(`%s -o $out $excludes "$glob"`, globCmd),
 			CommandDeps: []string{globCmd},
diff --git a/android/package_ctx.go b/android/package_ctx.go
index 56ba2d8..ee826c8 100644
--- a/android/package_ctx.go
+++ b/android/package_ctx.go
@@ -131,3 +131,35 @@
 		return JoinWithPrefix(paths.Strings(), prefix), nil
 	})
 }
+
+type RuleParams struct {
+	blueprint.RuleParams
+	GomaSupported bool
+}
+
+// AndroidStaticRule wraps blueprint.StaticRule and provides a default Pool if none is specified
+func (p AndroidPackageContext) AndroidStaticRule(name string, params blueprint.RuleParams,
+	argNames ...string) blueprint.Rule {
+	return p.AndroidRuleFunc(name, func(interface{}) (blueprint.RuleParams, error) {
+		return params, nil
+	}, argNames...)
+}
+
+// AndroidGomaStaticRule wraps blueprint.StaticRule but uses goma's parallelism if goma is enabled
+func (p AndroidPackageContext) AndroidGomaStaticRule(name string, params blueprint.RuleParams,
+	argNames ...string) blueprint.Rule {
+	return p.StaticRule(name, params, argNames...)
+}
+
+func (p AndroidPackageContext) AndroidRuleFunc(name string,
+	f func(interface{}) (blueprint.RuleParams, error), argNames ...string) blueprint.Rule {
+	return p.PackageContext.RuleFunc(name, func(config interface{}) (blueprint.RuleParams, error) {
+		params, err := f(config)
+		if config.(Config).UseGoma() && params.Pool == nil {
+			// When USE_GOMA=true is set and the rule is not supported by goma, restrict jobs to the
+			// local parallelism value
+			params.Pool = localPool
+		}
+		return params, err
+	}, argNames...)
+}
diff --git a/android/variable.go b/android/variable.go
index be2407d..b99e485 100644
--- a/android/variable.go
+++ b/android/variable.go
@@ -101,6 +101,7 @@
 	Cpusets                    *bool `json:",omitempty"`
 	Schedboost                 *bool `json:",omitempty"`
 	Binder32bit                *bool `json:",omitempty"`
+	UseGoma                    *bool `json:",omitempty"`
 
 	DevicePrefer32BitExecutables *bool `json:",omitempty"`
 	HostPrefer32BitExecutables   *bool `json:",omitempty"`
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/cc/binary.go b/cc/binary.go
index 38fc938..b6d66dd 100644
--- a/cc/binary.go
+++ b/cc/binary.go
@@ -168,13 +168,11 @@
 		if binary.Properties.Stem == "" && binary.Properties.Suffix == "" {
 			ctx.PropertyErrorf("symlink_preferred_arch", "must also specify stem or suffix")
 		}
-		var prefer bool
-		if ctx.Host() {
-			prefer = ctx.AConfig().HostPrefer32BitExecutables()
-		} else {
-			prefer = ctx.AConfig().DevicePrefer32BitExecutables()
+		prefer32 := false
+		if ctx.Device() {
+			prefer32 = ctx.AConfig().DevicePrefer32BitExecutables()
 		}
-		if ctx.PrimaryArch() != prefer {
+		if ctx.PrimaryArch() != prefer32 {
 			binary.baseInstaller.Properties.Symlinks = append(binary.baseInstaller.Properties.Symlinks,
 				ctx.ModuleName())
 		}
diff --git a/cc/builder.go b/cc/builder.go
index b84c928..a84ba08 100644
--- a/cc/builder.go
+++ b/cc/builder.go
@@ -39,17 +39,17 @@
 var (
 	pctx = android.NewPackageContext("android/soong/cc")
 
-	cc = pctx.StaticRule("cc",
+	cc = pctx.AndroidGomaStaticRule("cc",
 		blueprint.RuleParams{
 			Depfile:     "${out}.d",
 			Deps:        blueprint.DepsGCC,
-			Command:     "$relPwd $ccCmd -c $cFlags -MD -MF ${out}.d -o $out $in",
+			Command:     "$relPwd ${config.CcWrapper}$ccCmd -c $cFlags -MD -MF ${out}.d -o $out $in",
 			CommandDeps: []string{"$ccCmd"},
 			Description: "cc $out",
 		},
 		"ccCmd", "cFlags")
 
-	ld = pctx.StaticRule("ld",
+	ld = pctx.AndroidStaticRule("ld",
 		blueprint.RuleParams{
 			Command: "$ldCmd ${crtBegin} @${out}.rsp " +
 				"${libFlags} ${crtEnd} -o ${out} ${ldFlags}",
@@ -60,7 +60,7 @@
 		},
 		"ldCmd", "crtBegin", "libFlags", "crtEnd", "ldFlags")
 
-	partialLd = pctx.StaticRule("partialLd",
+	partialLd = pctx.AndroidStaticRule("partialLd",
 		blueprint.RuleParams{
 			Command:     "$ldCmd -nostdlib -Wl,-r ${in} -o ${out} ${ldFlags}",
 			CommandDeps: []string{"$ldCmd"},
@@ -68,7 +68,7 @@
 		},
 		"ldCmd", "ldFlags")
 
-	ar = pctx.StaticRule("ar",
+	ar = pctx.AndroidStaticRule("ar",
 		blueprint.RuleParams{
 			Command:        "rm -f ${out} && $arCmd $arFlags $out @${out}.rsp",
 			CommandDeps:    []string{"$arCmd"},
@@ -78,7 +78,7 @@
 		},
 		"arCmd", "arFlags")
 
-	darwinAr = pctx.StaticRule("darwinAr",
+	darwinAr = pctx.AndroidStaticRule("darwinAr",
 		blueprint.RuleParams{
 			Command:     "rm -f ${out} && ${config.MacArPath} $arFlags $out $in",
 			CommandDeps: []string{"${config.MacArPath}"},
@@ -86,7 +86,7 @@
 		},
 		"arFlags")
 
-	darwinAppendAr = pctx.StaticRule("darwinAppendAr",
+	darwinAppendAr = pctx.AndroidStaticRule("darwinAppendAr",
 		blueprint.RuleParams{
 			Command:     "cp -f ${inAr} ${out}.tmp && ${config.MacArPath} $arFlags ${out}.tmp $in && mv ${out}.tmp ${out}",
 			CommandDeps: []string{"${config.MacArPath}", "${inAr}"},
@@ -94,14 +94,14 @@
 		},
 		"arFlags", "inAr")
 
-	darwinStrip = pctx.StaticRule("darwinStrip",
+	darwinStrip = pctx.AndroidStaticRule("darwinStrip",
 		blueprint.RuleParams{
 			Command:     "${config.MacStripPath} -u -r -o $out $in",
 			CommandDeps: []string{"${config.MacStripPath}"},
 			Description: "strip $out",
 		})
 
-	prefixSymbols = pctx.StaticRule("prefixSymbols",
+	prefixSymbols = pctx.AndroidStaticRule("prefixSymbols",
 		blueprint.RuleParams{
 			Command:     "$objcopyCmd --prefix-symbols=${prefix} ${in} ${out}",
 			CommandDeps: []string{"$objcopyCmd"},
@@ -111,7 +111,7 @@
 
 	stripPath = pctx.SourcePathVariable("stripPath", "build/soong/scripts/strip.sh")
 
-	strip = pctx.StaticRule("strip",
+	strip = pctx.AndroidStaticRule("strip",
 		blueprint.RuleParams{
 			Depfile:     "${out}.d",
 			Deps:        blueprint.DepsGCC,
@@ -121,7 +121,7 @@
 		},
 		"args", "crossCompile")
 
-	emptyFile = pctx.StaticRule("emptyFile",
+	emptyFile = pctx.AndroidStaticRule("emptyFile",
 		blueprint.RuleParams{
 			Command:     "rm -f $out && touch $out",
 			Description: "empty file $out",
@@ -129,7 +129,7 @@
 
 	copyGccLibPath = pctx.SourcePathVariable("copyGccLibPath", "build/soong/scripts/copygcclib.sh")
 
-	copyGccLib = pctx.StaticRule("copyGccLib",
+	copyGccLib = pctx.AndroidStaticRule("copyGccLib",
 		blueprint.RuleParams{
 			Depfile:     "${out}.d",
 			Deps:        blueprint.DepsGCC,
diff --git a/cc/cc.go b/cc/cc.go
index 274f4fd..3c517ac 100644
--- a/cc/cc.go
+++ b/cc/cc.go
@@ -910,6 +910,7 @@
 		&StlProperties{},
 		&SanitizeProperties{},
 		&StripProperties{},
+		&InstallerProperties{},
 	)
 
 	_, props = android.InitAndroidArchModule(module, android.HostAndDeviceDefault,
diff --git a/cc/check.go b/cc/check.go
index 82d5a9f..bb2c9df 100644
--- a/cc/check.go
+++ b/cc/check.go
@@ -91,8 +91,8 @@
 		flag = strings.TrimSpace(flag)
 
 		// TODO: Probably should just redo this property to prefix -l in Soong
-		if !strings.HasPrefix(flag, "-l") {
-			ctx.PropertyErrorf(prop, "Invalid flag: `%s`, must start with `-l`", flag)
+		if !strings.HasPrefix(flag, "-l") && !strings.HasPrefix(flag, "-framework") {
+			ctx.PropertyErrorf(prop, "Invalid flag: `%s`, must start with `-l` or `-framework`", flag)
 		} else if !inList(flag, allowed_ldlibs) {
 			ctx.PropertyErrorf(prop, "Host library `%s` not available", flag)
 		}
diff --git a/cc/config/global.go b/cc/config/global.go
index 9d8a25d..f1989a2 100644
--- a/cc/config/global.go
+++ b/cc/config/global.go
@@ -127,6 +127,13 @@
 	pctx.StaticVariable("ClangBin", "${ClangPath}/bin")
 
 	pctx.StaticVariable("ClangAsanLibDir", "${ClangPath}/lib64/clang/3.8/lib/linux")
+
+	pctx.VariableFunc("CcWrapper", func(config interface{}) (string, error) {
+		if override := config.(android.Config).Getenv("CC_WRAPPER"); override != "" {
+			return override + " ", nil
+		}
+		return "", nil
+	})
 }
 
 var HostPrebuiltTag = pctx.VariableConfigMethod("HostPrebuiltTag", android.Config.PrebuiltOS)
diff --git a/cc/config/x86_darwin_host.go b/cc/config/x86_darwin_host.go
index e89fc9c..1a4972e 100644
--- a/cc/config/x86_darwin_host.go
+++ b/cc/config/x86_darwin_host.go
@@ -91,14 +91,14 @@
 		"10.11",
 	}
 
-	darwinAvailableLibraries = addPrefix([]string{
+	darwinAvailableLibraries = append(addPrefix([]string{
 		"c",
 		"dl",
 		"m",
 		"ncurses",
 		"pthread",
 		"z",
-	}, "-l")
+	}, "-l"), "-framework CoreFoundation")
 )
 
 const (
diff --git a/cc/gen.go b/cc/gen.go
index efcc478..c344cf6 100644
--- a/cc/gen.go
+++ b/cc/gen.go
@@ -31,7 +31,7 @@
 }
 
 var (
-	yacc = pctx.StaticRule("yacc",
+	yacc = pctx.AndroidStaticRule("yacc",
 		blueprint.RuleParams{
 			Command:     "BISON_PKGDATADIR=$yaccDataDir $yaccCmd -d $yaccFlags --defines=$hFile -o $cFile $in",
 			CommandDeps: []string{"$yaccCmd"},
@@ -39,7 +39,7 @@
 		},
 		"yaccFlags", "cFile", "hFile")
 
-	lex = pctx.StaticRule("lex",
+	lex = pctx.AndroidStaticRule("lex",
 		blueprint.RuleParams{
 			Command:     "$lexCmd -o$out $in",
 			CommandDeps: []string{"$lexCmd"},
diff --git a/cc/ndk_library.go b/cc/ndk_library.go
index b0fd398..37ce268 100644
--- a/cc/ndk_library.go
+++ b/cc/ndk_library.go
@@ -28,7 +28,7 @@
 var (
 	toolPath = pctx.SourcePathVariable("toolPath", "build/soong/cc/gen_stub_libs.py")
 
-	genStubSrc = pctx.StaticRule("genStubSrc",
+	genStubSrc = pctx.AndroidStaticRule("genStubSrc",
 		blueprint.RuleParams{
 			Command:     "$toolPath --arch $arch --api $apiLevel $in $out",
 			Description: "genStubSrc $out",
diff --git a/cc/test.go b/cc/test.go
index 27b45d7..5418ebf 100644
--- a/cc/test.go
+++ b/cc/test.go
@@ -259,7 +259,8 @@
 }
 
 func NewTestLibrary(hod android.HostOrDeviceSupported) *Module {
-	module, library := NewLibrary(android.HostAndDeviceSupported, false, true)
+	module, library := NewLibrary(android.HostAndDeviceSupported, true, true)
+	library.baseInstaller = NewTestInstaller()
 	test := &testLibrary{
 		testDecorator: testDecorator{
 			linker: library.baseLinker,
@@ -268,7 +269,6 @@
 	}
 	test.testDecorator.Properties.Gtest = true
 	module.linker = test
-	module.installer = nil
 	return module
 }
 
diff --git a/java/app_builder.go b/java/app_builder.go
index d8f2571..bbd3dac 100644
--- a/java/app_builder.go
+++ b/java/app_builder.go
@@ -27,7 +27,7 @@
 )
 
 var (
-	aaptCreateResourceJavaFile = pctx.StaticRule("aaptCreateResourceJavaFile",
+	aaptCreateResourceJavaFile = pctx.AndroidStaticRule("aaptCreateResourceJavaFile",
 		blueprint.RuleParams{
 			Command: `rm -rf "$javaDir" && mkdir -p "$javaDir" && ` +
 				`$aaptCmd package -m $aaptFlags -P $publicResourcesFile -G $proguardOptionsFile ` +
@@ -38,7 +38,7 @@
 		},
 		"aaptFlags", "publicResourcesFile", "proguardOptionsFile", "javaDir", "javaFileList")
 
-	aaptCreateAssetsPackage = pctx.StaticRule("aaptCreateAssetsPackage",
+	aaptCreateAssetsPackage = pctx.AndroidStaticRule("aaptCreateAssetsPackage",
 		blueprint.RuleParams{
 			Command:     `rm -f $out && $aaptCmd package $aaptFlags -F $out`,
 			CommandDeps: []string{"$aaptCmd"},
@@ -46,7 +46,7 @@
 		},
 		"aaptFlags", "publicResourcesFile", "proguardOptionsFile", "javaDir", "javaFileList")
 
-	aaptAddResources = pctx.StaticRule("aaptAddResources",
+	aaptAddResources = pctx.AndroidStaticRule("aaptAddResources",
 		blueprint.RuleParams{
 			// TODO: add-jni-shared-libs-to-package
 			Command:     `cp -f $in $out.tmp && $aaptCmd package -u $aaptFlags -F $out.tmp && mv $out.tmp $out`,
@@ -55,7 +55,7 @@
 		},
 		"aaptFlags")
 
-	signapk = pctx.StaticRule("signapk",
+	signapk = pctx.AndroidStaticRule("signapk",
 		blueprint.RuleParams{
 			Command:     `java -jar $signapkCmd $certificates $in $out`,
 			CommandDeps: []string{"$signapkCmd"},
@@ -63,7 +63,7 @@
 		},
 		"certificates")
 
-	androidManifestMerger = pctx.StaticRule("androidManifestMerger",
+	androidManifestMerger = pctx.AndroidStaticRule("androidManifestMerger",
 		blueprint.RuleParams{
 			Command: "java -classpath $androidManifestMergerCmd com.android.manifmerger.Main merge " +
 				"--main $in --libs $libsManifests --out $out",
diff --git a/java/builder.go b/java/builder.go
index f674f98..a9da0fc 100644
--- a/java/builder.go
+++ b/java/builder.go
@@ -37,7 +37,7 @@
 	// this, all java rules write into separate directories and then a post-processing step lists
 	// the files in the the directory into a list file that later rules depend on (and sometimes
 	// read from directly using @<listfile>)
-	javac = pctx.StaticRule("javac",
+	javac = pctx.AndroidStaticRule("javac",
 		blueprint.RuleParams{
 			Command: `rm -rf "$outDir" && mkdir -p "$outDir" && ` +
 				`$javacCmd -encoding UTF-8 $javacFlags $bootClasspath $classpath ` +
@@ -49,7 +49,7 @@
 		},
 		"javacCmd", "javacFlags", "bootClasspath", "classpath", "outDir")
 
-	jar = pctx.StaticRule("jar",
+	jar = pctx.AndroidStaticRule("jar",
 		blueprint.RuleParams{
 			Command:     `$jarCmd -o $out $jarArgs`,
 			CommandDeps: []string{"$jarCmd"},
@@ -57,7 +57,7 @@
 		},
 		"jarCmd", "jarArgs")
 
-	dx = pctx.StaticRule("dx",
+	dx = pctx.AndroidStaticRule("dx",
 		blueprint.RuleParams{
 			Command: `rm -rf "$outDir" && mkdir -p "$outDir" && ` +
 				`$dxCmd --dex --output=$outDir $dxFlags $in || ( rm -rf "$outDir"; exit 41 ) && ` +
@@ -67,7 +67,7 @@
 		},
 		"outDir", "dxFlags")
 
-	jarjar = pctx.StaticRule("jarjar",
+	jarjar = pctx.AndroidStaticRule("jarjar",
 		blueprint.RuleParams{
 			Command:     "java -jar $jarjarCmd process $rulesFile $in $out",
 			CommandDeps: []string{"$jarjarCmd", "$rulesFile"},
@@ -75,7 +75,7 @@
 		},
 		"rulesFile")
 
-	extractPrebuilt = pctx.StaticRule("extractPrebuilt",
+	extractPrebuilt = pctx.AndroidStaticRule("extractPrebuilt",
 		blueprint.RuleParams{
 			Command: `rm -rf $outDir && unzip -qo $in -d $outDir && ` +
 				`find $outDir -name "*.class" > $classFile && ` +
diff --git a/java/gen.go b/java/gen.go
index 57c4ba2..52a0c79 100644
--- a/java/gen.go
+++ b/java/gen.go
@@ -33,7 +33,7 @@
 }
 
 var (
-	aidl = pctx.StaticRule("aidl",
+	aidl = pctx.AndroidStaticRule("aidl",
 		blueprint.RuleParams{
 			Command:     "$aidlCmd -d$depFile $aidlFlags $in $out",
 			CommandDeps: []string{"$aidlCmd"},
@@ -41,14 +41,14 @@
 		},
 		"depFile", "aidlFlags")
 
-	logtags = pctx.StaticRule("logtags",
+	logtags = pctx.AndroidStaticRule("logtags",
 		blueprint.RuleParams{
 			Command:     "$logtagsCmd -o $out $in $allLogtagsFile",
 			CommandDeps: []string{"$logtagsCmd"},
 			Description: "logtags $out",
 		})
 
-	mergeLogtags = pctx.StaticRule("mergeLogtags",
+	mergeLogtags = pctx.AndroidStaticRule("mergeLogtags",
 		blueprint.RuleParams{
 			Command:     "$mergeLogtagsCmd -o $out $in",
 			CommandDeps: []string{"$mergeLogtagsCmd"},
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 "$@"