Add support for remote-execution / caching of turbine actions
Test: Ran a sample turbine action with: RBE_TURBINE_EXEC_STRATEGY="remote" RBE_TURBINE="true" ... use_rbe m out/soong/.intermediates/external/protobuf/libprotobuf-java-micro/android_common/turbine/libprotobuf-java-micro.jar and checked in reproxy_log.txt that remote-metadata had status SUCCESS. Bug: b/156765475 Change-Id: I85c334e6998c6dd2a68460b3580d50fffd900e6f
This commit is contained in:
@@ -116,10 +116,10 @@ var (
|
|||||||
},
|
},
|
||||||
"abis", "allow-prereleased", "screen-densities", "sdk-version", "stem")
|
"abis", "allow-prereleased", "screen-densities", "sdk-version", "stem")
|
||||||
|
|
||||||
turbine = pctx.AndroidStaticRule("turbine",
|
turbine, turbineRE = remoteexec.StaticRules(pctx, "turbine",
|
||||||
blueprint.RuleParams{
|
blueprint.RuleParams{
|
||||||
Command: `rm -rf "$outDir" && mkdir -p "$outDir" && ` +
|
Command: `rm -rf "$outDir" && mkdir -p "$outDir" && ` +
|
||||||
`${config.JavaCmd} ${config.JavaVmFlags} -jar ${config.TurbineJar} --output $out.tmp ` +
|
`$reTemplate${config.JavaCmd} ${config.JavaVmFlags} -jar ${config.TurbineJar} --output $out.tmp ` +
|
||||||
`--temp_dir "$outDir" --sources @$out.rsp --source_jars $srcJars ` +
|
`--temp_dir "$outDir" --sources @$out.rsp --source_jars $srcJars ` +
|
||||||
`--javacopts ${config.CommonJdkFlags} ` +
|
`--javacopts ${config.CommonJdkFlags} ` +
|
||||||
`$javacFlags -source $javaVersion -target $javaVersion -- $bootClasspath $classpath && ` +
|
`$javacFlags -source $javaVersion -target $javaVersion -- $bootClasspath $classpath && ` +
|
||||||
@@ -134,7 +134,15 @@ var (
|
|||||||
RspfileContent: "$in",
|
RspfileContent: "$in",
|
||||||
Restat: true,
|
Restat: true,
|
||||||
},
|
},
|
||||||
"javacFlags", "bootClasspath", "classpath", "srcJars", "outDir", "javaVersion")
|
&remoteexec.REParams{Labels: map[string]string{"type": "tool", "name": "turbine"},
|
||||||
|
ExecStrategy: "${config.RETurbineExecStrategy}",
|
||||||
|
Inputs: []string{"${config.TurbineJar}", "${out}.rsp", "$implicits"},
|
||||||
|
RSPFile: "${out}.rsp",
|
||||||
|
OutputFiles: []string{"$out.tmp"},
|
||||||
|
OutputDirectories: []string{"$outDir"},
|
||||||
|
ToolchainInputs: []string{"${config.JavaCmd}"},
|
||||||
|
Platform: map[string]string{remoteexec.PoolKey: "${config.REJavaPool}"},
|
||||||
|
}, []string{"javacFlags", "bootClasspath", "classpath", "srcJars", "outDir", "javaVersion"}, []string{"implicits"})
|
||||||
|
|
||||||
jar = pctx.AndroidStaticRule("jar",
|
jar = pctx.AndroidStaticRule("jar",
|
||||||
blueprint.RuleParams{
|
blueprint.RuleParams{
|
||||||
@@ -346,20 +354,26 @@ func TransformJavaToHeaderClasses(ctx android.ModuleContext, outputFile android.
|
|||||||
deps = append(deps, classpath...)
|
deps = append(deps, classpath...)
|
||||||
deps = append(deps, flags.processorPath...)
|
deps = append(deps, flags.processorPath...)
|
||||||
|
|
||||||
ctx.Build(pctx, android.BuildParams{
|
rule := turbine
|
||||||
Rule: turbine,
|
args := map[string]string{
|
||||||
Description: "turbine",
|
|
||||||
Output: outputFile,
|
|
||||||
Inputs: srcFiles,
|
|
||||||
Implicits: deps,
|
|
||||||
Args: map[string]string{
|
|
||||||
"javacFlags": flags.javacFlags,
|
"javacFlags": flags.javacFlags,
|
||||||
"bootClasspath": bootClasspath,
|
"bootClasspath": bootClasspath,
|
||||||
"srcJars": strings.Join(srcJars.Strings(), " "),
|
"srcJars": strings.Join(srcJars.Strings(), " "),
|
||||||
"classpath": classpath.FormTurbineClassPath("--classpath "),
|
"classpath": classpath.FormTurbineClassPath("--classpath "),
|
||||||
"outDir": android.PathForModuleOut(ctx, "turbine", "classes").String(),
|
"outDir": android.PathForModuleOut(ctx, "turbine", "classes").String(),
|
||||||
"javaVersion": flags.javaVersion.String(),
|
"javaVersion": flags.javaVersion.String(),
|
||||||
},
|
}
|
||||||
|
if ctx.Config().IsEnvTrue("RBE_TURBINE") {
|
||||||
|
rule = turbineRE
|
||||||
|
args["implicits"] = strings.Join(deps.Strings(), ",")
|
||||||
|
}
|
||||||
|
ctx.Build(pctx, android.BuildParams{
|
||||||
|
Rule: rule,
|
||||||
|
Description: "turbine",
|
||||||
|
Output: outputFile,
|
||||||
|
Inputs: srcFiles,
|
||||||
|
Implicits: deps,
|
||||||
|
Args: args,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -148,6 +148,7 @@ func init() {
|
|||||||
pctx.VariableFunc("REJavacExecStrategy", remoteexec.EnvOverrideFunc("RBE_JAVAC_EXEC_STRATEGY", remoteexec.LocalExecStrategy))
|
pctx.VariableFunc("REJavacExecStrategy", remoteexec.EnvOverrideFunc("RBE_JAVAC_EXEC_STRATEGY", remoteexec.LocalExecStrategy))
|
||||||
pctx.VariableFunc("RED8ExecStrategy", remoteexec.EnvOverrideFunc("RBE_D8_EXEC_STRATEGY", remoteexec.LocalExecStrategy))
|
pctx.VariableFunc("RED8ExecStrategy", remoteexec.EnvOverrideFunc("RBE_D8_EXEC_STRATEGY", remoteexec.LocalExecStrategy))
|
||||||
pctx.VariableFunc("RER8ExecStrategy", remoteexec.EnvOverrideFunc("RBE_R8_EXEC_STRATEGY", remoteexec.LocalExecStrategy))
|
pctx.VariableFunc("RER8ExecStrategy", remoteexec.EnvOverrideFunc("RBE_R8_EXEC_STRATEGY", remoteexec.LocalExecStrategy))
|
||||||
|
pctx.VariableFunc("RETurbineExecStrategy", remoteexec.EnvOverrideFunc("RBE_TURBINE_EXEC_STRATEGY", remoteexec.LocalExecStrategy))
|
||||||
|
|
||||||
pctx.HostJavaToolVariable("JacocoCLIJar", "jacoco-cli.jar")
|
pctx.HostJavaToolVariable("JacocoCLIJar", "jacoco-cli.jar")
|
||||||
|
|
||||||
|
@@ -75,6 +75,9 @@ type REParams struct {
|
|||||||
// OutputFiles is a list of output file paths or ninja variables as placeholders for rule
|
// OutputFiles is a list of output file paths or ninja variables as placeholders for rule
|
||||||
// outputs.
|
// outputs.
|
||||||
OutputFiles []string
|
OutputFiles []string
|
||||||
|
// OutputDirectories is a list of output directory paths or ninja variables as placeholders
|
||||||
|
// for rule outputs.
|
||||||
|
OutputDirectories []string
|
||||||
// ToolchainInputs is a list of paths or ninja variables pointing to the location of
|
// ToolchainInputs is a list of paths or ninja variables pointing to the location of
|
||||||
// toolchain binaries used by the rule.
|
// toolchain binaries used by the rule.
|
||||||
ToolchainInputs []string
|
ToolchainInputs []string
|
||||||
@@ -151,6 +154,10 @@ func (r *REParams) wrapperArgs() string {
|
|||||||
args += " --output_files=" + strings.Join(r.OutputFiles, ",")
|
args += " --output_files=" + strings.Join(r.OutputFiles, ",")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if len(r.OutputDirectories) > 0 {
|
||||||
|
args += " --output_directories=" + strings.Join(r.OutputDirectories, ",")
|
||||||
|
}
|
||||||
|
|
||||||
if len(r.ToolchainInputs) > 0 {
|
if len(r.ToolchainInputs) > 0 {
|
||||||
args += " --toolchain_inputs=" + strings.Join(r.ToolchainInputs, ",")
|
args += " --toolchain_inputs=" + strings.Join(r.ToolchainInputs, ",")
|
||||||
}
|
}
|
||||||
@@ -159,7 +166,9 @@ func (r *REParams) wrapperArgs() string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// StaticRules returns a pair of rules based on the given RuleParams, where the first rule is a
|
// StaticRules returns a pair of rules based on the given RuleParams, where the first rule is a
|
||||||
// locally executable rule and the second rule is a remotely executable rule.
|
// locally executable rule and the second rule is a remotely executable rule. commonArgs are args
|
||||||
|
// used for both the local and remotely executable rules. reArgs are used only for remote
|
||||||
|
// execution.
|
||||||
func StaticRules(ctx android.PackageContext, name string, ruleParams blueprint.RuleParams, reParams *REParams, commonArgs []string, reArgs []string) (blueprint.Rule, blueprint.Rule) {
|
func StaticRules(ctx android.PackageContext, name string, ruleParams blueprint.RuleParams, reParams *REParams, commonArgs []string, reArgs []string) (blueprint.Rule, blueprint.Rule) {
|
||||||
ruleParamsRE := ruleParams
|
ruleParamsRE := ruleParams
|
||||||
ruleParams.Command = strings.ReplaceAll(ruleParams.Command, "$reTemplate", "")
|
ruleParams.Command = strings.ReplaceAll(ruleParams.Command, "$reTemplate", "")
|
||||||
|
Reference in New Issue
Block a user