Move android package on top of remotexec
Remove the references to the android package in remotexec so that the android package can reference the remoteexec package. This will allow RuleBuilder to integrate directly with remoteexec. Bug: 182612695 Test: m checkbuild Change-Id: I15be5ef126d8aacbd605518638f341daf6f31bb3
This commit is contained in:
@@ -5,10 +5,6 @@ package {
|
||||
bootstrap_go_package {
|
||||
name: "soong-remoteexec",
|
||||
pkgPath: "android/soong/remoteexec",
|
||||
deps: [
|
||||
"blueprint",
|
||||
"soong-android",
|
||||
],
|
||||
srcs: [
|
||||
"remoteexec.go",
|
||||
],
|
||||
|
@@ -17,10 +17,6 @@ package remoteexec
|
||||
import (
|
||||
"sort"
|
||||
"strings"
|
||||
|
||||
"android/soong/android"
|
||||
|
||||
"github.com/google/blueprint"
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -56,7 +52,6 @@ const (
|
||||
var (
|
||||
defaultLabels = map[string]string{"type": "tool"}
|
||||
defaultExecStrategy = LocalExecStrategy
|
||||
pctx = android.NewPackageContext("android/soong/remoteexec")
|
||||
)
|
||||
|
||||
// REParams holds information pertinent to the remote execution of a rule.
|
||||
@@ -87,28 +82,18 @@ type REParams struct {
|
||||
}
|
||||
|
||||
func init() {
|
||||
pctx.VariableFunc("Wrapper", func(ctx android.PackageVarContext) string {
|
||||
return wrapper(ctx.Config())
|
||||
})
|
||||
}
|
||||
|
||||
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()
|
||||
return "${android.RBEWrapper}" + r.wrapperArgs()
|
||||
}
|
||||
|
||||
// NoVarTemplate generates 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) NoVarTemplate(wrapper string) string {
|
||||
return wrapper + r.wrapperArgs()
|
||||
}
|
||||
|
||||
func (r *REParams) wrapperArgs() string {
|
||||
@@ -171,43 +156,3 @@ func (r *REParams) wrapperArgs() string {
|
||||
|
||||
return args + " -- "
|
||||
}
|
||||
|
||||
// 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. 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) {
|
||||
ruleParamsRE := ruleParams
|
||||
ruleParams.Command = strings.ReplaceAll(ruleParams.Command, "$reTemplate", "")
|
||||
ruleParamsRE.Command = strings.ReplaceAll(ruleParamsRE.Command, "$reTemplate", reParams.Template())
|
||||
|
||||
return ctx.AndroidStaticRule(name, ruleParams, commonArgs...),
|
||||
ctx.AndroidRemoteStaticRule(name+"RE", android.RemoteRuleSupports{RBE: true}, ruleParamsRE, append(commonArgs, reArgs...)...)
|
||||
}
|
||||
|
||||
// MultiCommandStaticRules 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. This
|
||||
// function supports multiple remote execution wrappers placed in the template when commands are
|
||||
// chained together with &&. commonArgs are args used for both the local and remotely executable
|
||||
// rules. reArgs are args used only for remote execution.
|
||||
func MultiCommandStaticRules(ctx android.PackageContext, name string, ruleParams blueprint.RuleParams, reParams map[string]*REParams, commonArgs []string, reArgs []string) (blueprint.Rule, blueprint.Rule) {
|
||||
ruleParamsRE := ruleParams
|
||||
for k, v := range reParams {
|
||||
ruleParams.Command = strings.ReplaceAll(ruleParams.Command, k, "")
|
||||
ruleParamsRE.Command = strings.ReplaceAll(ruleParamsRE.Command, k, v.Template())
|
||||
}
|
||||
|
||||
return ctx.AndroidStaticRule(name, ruleParams, commonArgs...),
|
||||
ctx.AndroidRemoteStaticRule(name+"RE", android.RemoteRuleSupports{RBE: true}, ruleParamsRE, append(commonArgs, reArgs...)...)
|
||||
}
|
||||
|
||||
// EnvOverrideFunc retrieves a variable func that evaluates to the value of the given environment
|
||||
// variable if set, otherwise the given default.
|
||||
func EnvOverrideFunc(envVar, defaultVal string) func(ctx android.PackageVarContext) string {
|
||||
return func(ctx android.PackageVarContext) string {
|
||||
if override := ctx.Config().Getenv(envVar); override != "" {
|
||||
return override
|
||||
}
|
||||
return defaultVal
|
||||
}
|
||||
}
|
||||
|
@@ -17,8 +17,6 @@ package remoteexec
|
||||
import (
|
||||
"fmt"
|
||||
"testing"
|
||||
|
||||
"android/soong/android"
|
||||
)
|
||||
|
||||
func TestTemplate(t *testing.T) {
|
||||
@@ -38,7 +36,7 @@ func TestTemplate(t *testing.T) {
|
||||
PoolKey: "default",
|
||||
},
|
||||
},
|
||||
want: fmt.Sprintf("${remoteexec.Wrapper} --labels=compiler=clang,lang=cpp,type=compile --platform=\"Pool=default,container-image=%s\" --exec_strategy=local --inputs=$in --output_files=$out -- ", DefaultImage),
|
||||
want: fmt.Sprintf("${android.RBEWrapper} --labels=compiler=clang,lang=cpp,type=compile --platform=\"Pool=default,container-image=%s\" --exec_strategy=local --inputs=$in --output_files=$out -- ", DefaultImage),
|
||||
},
|
||||
{
|
||||
name: "all params",
|
||||
@@ -54,7 +52,7 @@ func TestTemplate(t *testing.T) {
|
||||
PoolKey: "default",
|
||||
},
|
||||
},
|
||||
want: fmt.Sprintf("${remoteexec.Wrapper} --labels=compiler=clang,lang=cpp,type=compile --platform=\"Pool=default,container-image=%s\" --exec_strategy=remote --inputs=$in --input_list_paths=$out.rsp --output_files=$out --toolchain_inputs=clang++ -- ", DefaultImage),
|
||||
want: fmt.Sprintf("${android.RBEWrapper} --labels=compiler=clang,lang=cpp,type=compile --platform=\"Pool=default,container-image=%s\" --exec_strategy=remote --inputs=$in --input_list_paths=$out.rsp --output_files=$out --toolchain_inputs=clang++ -- ", DefaultImage),
|
||||
},
|
||||
}
|
||||
for _, test := range tests {
|
||||
@@ -77,7 +75,7 @@ func TestNoVarTemplate(t *testing.T) {
|
||||
},
|
||||
}
|
||||
want := fmt.Sprintf("prebuilts/remoteexecution-client/live/rewrapper --labels=compiler=clang,lang=cpp,type=compile --platform=\"Pool=default,container-image=%s\" --exec_strategy=local --inputs=$in --output_files=$out -- ", DefaultImage)
|
||||
if got := params.NoVarTemplate(android.NullConfig("")); got != want {
|
||||
if got := params.NoVarTemplate(DefaultWrapperPath); got != want {
|
||||
t.Errorf("NoVarTemplate() returned\n%s\nwant\n%s", got, want)
|
||||
}
|
||||
}
|
||||
@@ -92,7 +90,7 @@ func TestTemplateDeterminism(t *testing.T) {
|
||||
PoolKey: "default",
|
||||
},
|
||||
}
|
||||
want := fmt.Sprintf("${remoteexec.Wrapper} --labels=compiler=clang,lang=cpp,type=compile --platform=\"Pool=default,container-image=%s\" --exec_strategy=local --inputs=$in --output_files=$out -- ", DefaultImage)
|
||||
want := fmt.Sprintf("${android.RBEWrapper} --labels=compiler=clang,lang=cpp,type=compile --platform=\"Pool=default,container-image=%s\" --exec_strategy=local --inputs=$in --output_files=$out -- ", DefaultImage)
|
||||
for i := 0; i < 1000; i++ {
|
||||
if got := r.Template(); got != want {
|
||||
t.Fatalf("Template() returned\n%s\nwant\n%s", got, want)
|
||||
|
Reference in New Issue
Block a user