[DO NOT MERGE] Add support for experimentally enabling RBE support on specific rules.
This CL adds RBE support to javac, r8, and d8 rules which is only
enabled if respective environment variables are set.
Test: an aosp_crosshatch build with and without the new variables.
Bug: b/166182389
Change-Id: Ic82f3627944f6a5ee7b9f3228170c2709b1bfcb8
Merged-In: Ic82f3627944f6a5ee7b9f3228170c2709b1bfcb8
diff --git a/java/builder.go b/java/builder.go
index a8e54cc..e5ac7b0 100644
--- a/java/builder.go
+++ b/java/builder.go
@@ -38,7 +38,7 @@
// this, all java rules write into separate directories and then are combined into a .jar file
// (if the rule produces .class files) or a .srcjar file (if the rule produces .java files).
// .srcjar files are unzipped into a temporary directory when compiled with javac.
- javac = pctx.AndroidRemoteStaticRule("javac", android.SUPPORTS_GOMA,
+ javac = pctx.AndroidRemoteStaticRule("javac", android.RemoteRuleSupports{Goma: true, RBE: true, RBEFlag: android.RBE_JAVAC},
blueprint.RuleParams{
Command: `rm -rf "$outDir" "$annoDir" "$srcJarDir" && mkdir -p "$outDir" "$annoDir" "$srcJarDir" && ` +
`${config.ZipSyncCmd} -d $srcJarDir -l $srcJarDir/list -f "*.java" $srcJars && ` +
diff --git a/java/config/config.go b/java/config/config.go
index f6688a2..f76a393 100644
--- a/java/config/config.go
+++ b/java/config/config.go
@@ -129,6 +129,20 @@
return ""
})
+ pctx.VariableFunc("R8Wrapper", func(ctx android.PackageVarContext) string {
+ if override := ctx.Config().Getenv("R8_WRAPPER"); override != "" {
+ return override + " "
+ }
+ return ""
+ })
+
+ pctx.VariableFunc("D8Wrapper", func(ctx android.PackageVarContext) string {
+ if override := ctx.Config().Getenv("D8_WRAPPER"); override != "" {
+ return override + " "
+ }
+ return ""
+ })
+
pctx.HostJavaToolVariable("JacocoCLIJar", "jacoco-cli.jar")
hostBinToolVariableWithPrebuilt := func(name, prebuiltDir, tool string) {
diff --git a/java/dex.go b/java/dex.go
index c8a4fa8..86a28fc 100644
--- a/java/dex.go
+++ b/java/dex.go
@@ -22,10 +22,10 @@
"android/soong/android"
)
-var d8 = pctx.AndroidStaticRule("d8",
+var d8 = pctx.AndroidRemoteStaticRule("d8", android.RemoteRuleSupports{RBE: true, RBEFlag: android.RBE_D8},
blueprint.RuleParams{
Command: `rm -rf "$outDir" && mkdir -p "$outDir" && ` +
- `${config.D8Cmd} ${config.DexFlags} --output $outDir $d8Flags $in && ` +
+ `${config.D8Wrapper}${config.D8Cmd} ${config.DexFlags} --output $outDir $d8Flags $in && ` +
`${config.SoongZipCmd} $zipFlags -o $outDir/classes.dex.jar -C $outDir -f "$outDir/classes*.dex" && ` +
`${config.MergeZipsCmd} -D -stripFile "**/*.class" $out $outDir/classes.dex.jar $in`,
CommandDeps: []string{
@@ -36,11 +36,11 @@
},
"outDir", "d8Flags", "zipFlags")
-var r8 = pctx.AndroidStaticRule("r8",
+var r8 = pctx.AndroidRemoteStaticRule("r8", android.RemoteRuleSupports{RBE: true, RBEFlag: android.RBE_R8},
blueprint.RuleParams{
Command: `rm -rf "$outDir" && mkdir -p "$outDir" && ` +
`rm -f "$outDict" && ` +
- `${config.R8Cmd} ${config.DexFlags} -injars $in --output $outDir ` +
+ `${config.R8Wrapper}${config.R8Cmd} ${config.DexFlags} -injars $in --output $outDir ` +
`--force-proguard-compatibility ` +
`--no-data-resources ` +
`-printmapping $outDict ` +
diff --git a/java/kotlin.go b/java/kotlin.go
index 7256030..58dc64c 100644
--- a/java/kotlin.go
+++ b/java/kotlin.go
@@ -25,7 +25,7 @@
"github.com/google/blueprint"
)
-var kotlinc = pctx.AndroidRemoteStaticRule("kotlinc", android.SUPPORTS_GOMA,
+var kotlinc = pctx.AndroidRemoteStaticRule("kotlinc", android.RemoteRuleSupports{Goma: true},
blueprint.RuleParams{
Command: `rm -rf "$classesDir" "$srcJarDir" "$kotlinBuildFile" && mkdir -p "$classesDir" "$srcJarDir" && ` +
`${config.ZipSyncCmd} -d $srcJarDir -l $srcJarDir/list -f "*.java" $srcJars && ` +
@@ -74,7 +74,7 @@
})
}
-var kapt = pctx.AndroidRemoteStaticRule("kapt", android.SUPPORTS_GOMA,
+var kapt = pctx.AndroidRemoteStaticRule("kapt", android.RemoteRuleSupports{Goma: true},
blueprint.RuleParams{
Command: `rm -rf "$srcJarDir" "$kotlinBuildFile" "$kaptDir" && mkdir -p "$srcJarDir" "$kaptDir" && ` +
`${config.ZipSyncCmd} -d $srcJarDir -l $srcJarDir/list -f "*.java" $srcJars && ` +