Add support for the remote execution of metalava actions.

Test: built aosp crosshatch userdebug with RBE_METALAVA=1
Change-Id: I3d42d75b4522f99ff95ce8c997ead782e4322f6e
This commit is contained in:
Ramy Medhat
2020-04-30 03:08:37 -04:00
parent b407131a0e
commit 427683cad7
3 changed files with 73 additions and 16 deletions

View File

@@ -82,17 +82,31 @@ type REParams struct {
func init() {
pctx.VariableFunc("Wrapper", func(ctx android.PackageVarContext) string {
if override := ctx.Config().Getenv("RBE_WRAPPER"); override != "" {
return override
}
return DefaultWrapperPath
return wrapper(ctx.Config())
})
}
// Generate the remote execution wrapper template to be added as a prefix to the rule's command.
func (r *REParams) Template() string {
template := "${remoteexec.Wrapper}"
func wrapper(cfg android.Config) string {
if override := cfg.Getenv("RBE_WRAPPER"); override != "" {
return override
}
return DefaultWrapperPath
}
// Template generates the remote execution wrapper template to be added as a prefix to the rule's
// command.
func (r *REParams) Template() string {
return "${remoteexec.Wrapper}" + r.wrapperArgs()
}
// NoVarTemplate generate the remote execution wrapper template without variables, to be used in
// RuleBuilder.
func (r *REParams) NoVarTemplate(cfg android.Config) string {
return wrapper(cfg) + r.wrapperArgs()
}
func (r *REParams) wrapperArgs() string {
args := ""
var kvs []string
labels := r.Labels
if len(labels) == 0 {
@@ -102,7 +116,7 @@ func (r *REParams) Template() string {
kvs = append(kvs, k+"="+v)
}
sort.Strings(kvs)
template += " --labels=" + strings.Join(kvs, ",")
args += " --labels=" + strings.Join(kvs, ",")
var platform []string
for k, v := range r.Platform {
@@ -116,32 +130,32 @@ func (r *REParams) Template() string {
}
if platform != nil {
sort.Strings(platform)
template += " --platform=\"" + strings.Join(platform, ",") + "\""
args += " --platform=\"" + strings.Join(platform, ",") + "\""
}
strategy := r.ExecStrategy
if strategy == "" {
strategy = defaultExecStrategy
}
template += " --exec_strategy=" + strategy
args += " --exec_strategy=" + strategy
if len(r.Inputs) > 0 {
template += " --inputs=" + strings.Join(r.Inputs, ",")
args += " --inputs=" + strings.Join(r.Inputs, ",")
}
if r.RSPFile != "" {
template += " --input_list_paths=" + r.RSPFile
args += " --input_list_paths=" + r.RSPFile
}
if len(r.OutputFiles) > 0 {
template += " --output_files=" + strings.Join(r.OutputFiles, ",")
args += " --output_files=" + strings.Join(r.OutputFiles, ",")
}
if len(r.ToolchainInputs) > 0 {
template += " --toolchain_inputs=" + strings.Join(r.ToolchainInputs, ",")
args += " --toolchain_inputs=" + strings.Join(r.ToolchainInputs, ",")
}
return template + " -- "
return args + " -- "
}
// StaticRules returns a pair of rules based on the given RuleParams, where the first rule is a