Enable goma in soong

When the UseGoma flag is set, put all rules except the C compilation
rule in an externally defined local_pool, which will have been created
by kati.  The gomacc wrapper will already be in the CC_WRAPPER
environment variable.

Bug: 31142427
Change-Id: I699d4edff2e302eee398dad8692ceb14721a628c
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() {