Add support for the remote execution of metalava actions.

Bug: b/156613606
Test: built aosp crosshatch userdebug with RBE_METALAVA=1
Change-Id: I3d42d75b4522f99ff95ce8c997ead782e4322f6e
Merged-In: I3d42d75b4522f99ff95ce8c997ead782e4322f6e
This commit is contained in:
Ramy Medhat
2020-05-05 22:50:09 +00:00
parent 829b7135f3
commit 1fb3cd8496
3 changed files with 74 additions and 17 deletions

View File

@@ -24,6 +24,7 @@ import (
"android/soong/android"
"android/soong/java/config"
"android/soong/remoteexec"
)
func init() {
@@ -1401,7 +1402,31 @@ func metalavaCmd(ctx android.ModuleContext, rule *android.RuleBuilder, javaVersi
srcJarList android.Path, bootclasspath, classpath classpath, sourcepaths android.Paths) *android.RuleBuilderCommand {
// Metalava uses lots of memory, restrict the number of metalava jobs that can run in parallel.
rule.HighMem()
cmd := rule.Command().BuiltTool(ctx, "metalava").
cmd := rule.Command()
if ctx.Config().IsEnvTrue("RBE_METALAVA") {
rule.Remoteable(android.RemoteRuleSupports{RBE: true})
execStrategy := remoteexec.LocalExecStrategy
if v := ctx.Config().Getenv("RBE_METALAVA_EXEC_STRATEGY"); v != "" {
execStrategy = v
}
pool := "metalava"
if v := ctx.Config().Getenv("RBE_METALAVA_POOL"); v != "" {
pool = v
}
inputs := []string{android.PathForOutput(ctx, "host", ctx.Config().PrebuiltOS(), "framework", "metalava.jar").String()}
if v := ctx.Config().Getenv("RBE_METALAVA_INPUTS"); v != "" {
inputs = append(inputs, strings.Split(v, ",")...)
}
cmd.Text((&remoteexec.REParams{
Labels: map[string]string{"type": "compile", "lang": "java", "compiler": "metalava"},
ExecStrategy: execStrategy,
Inputs: inputs,
ToolchainInputs: []string{config.JavaCmd(ctx).String()},
Platform: map[string]string{remoteexec.PoolKey: pool},
}).NoVarTemplate(ctx.Config()))
}
cmd.BuiltTool(ctx, "metalava").
Flag(config.JavacVmFlags).
FlagWithArg("-encoding ", "UTF-8").
FlagWithArg("-source ", javaVersion.String()).