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:
parent
ab020a7333
commit
77cdcfdeaf
15 changed files with 85 additions and 99 deletions
|
@ -13,6 +13,7 @@ bootstrap_go_package {
|
|||
"soong-android-soongconfig",
|
||||
"soong-bazel",
|
||||
"soong-cquery",
|
||||
"soong-remoteexec",
|
||||
"soong-shared",
|
||||
"soong-ui-metrics_proto",
|
||||
],
|
||||
|
|
|
@ -35,6 +35,7 @@ import (
|
|||
"github.com/google/blueprint/proptools"
|
||||
|
||||
"android/soong/android/soongconfig"
|
||||
"android/soong/remoteexec"
|
||||
)
|
||||
|
||||
// Bool re-exports proptools.Bool for the android package.
|
||||
|
@ -1754,3 +1755,7 @@ func (c *config) NonUpdatableBootJars() ConfiguredJarList {
|
|||
func (c *config) UpdatableBootJars() ConfiguredJarList {
|
||||
return c.productVariables.UpdatableBootJars
|
||||
}
|
||||
|
||||
func (c *config) RBEWrapper() string {
|
||||
return c.GetenvWithDefault("RBE_WRAPPER", remoteexec.DefaultWrapperPath)
|
||||
}
|
||||
|
|
|
@ -124,6 +124,10 @@ var (
|
|||
|
||||
func init() {
|
||||
pctx.Import("github.com/google/blueprint/bootstrap")
|
||||
|
||||
pctx.VariableFunc("RBEWrapper", func(ctx PackageVarContext) string {
|
||||
return ctx.Config().RBEWrapper()
|
||||
})
|
||||
}
|
||||
|
||||
var (
|
||||
|
|
|
@ -19,6 +19,8 @@ import (
|
|||
"strings"
|
||||
|
||||
"github.com/google/blueprint"
|
||||
|
||||
"android/soong/remoteexec"
|
||||
)
|
||||
|
||||
// PackageContext is a wrapper for blueprint.PackageContext that adds
|
||||
|
@ -260,3 +262,40 @@ func (p PackageContext) AndroidRemoteStaticRule(name string, supports RemoteRule
|
|||
return params, nil
|
||||
}, argNames...)
|
||||
}
|
||||
|
||||
// RemoteStaticRules 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 (p PackageContext) RemoteStaticRules(name string, ruleParams blueprint.RuleParams, reParams *remoteexec.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 p.AndroidStaticRule(name, ruleParams, commonArgs...),
|
||||
p.AndroidRemoteStaticRule(name+"RE", 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 (p PackageContext) MultiCommandRemoteStaticRules(name string, ruleParams blueprint.RuleParams, reParams map[string]*remoteexec.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 p.AndroidStaticRule(name, ruleParams, commonArgs...),
|
||||
p.AndroidRemoteStaticRule(name+"RE", RemoteRuleSupports{RBE: true}, ruleParamsRE, append(commonArgs, reArgs...)...)
|
||||
}
|
||||
|
||||
// StaticVariableWithEnvOverride creates a static variable that evaluates to the value of the given
|
||||
// environment variable if set, otherwise the given default.
|
||||
func (p PackageContext) StaticVariableWithEnvOverride(name, envVar, defaultVal string) blueprint.Variable {
|
||||
return p.VariableFunc(name, func(ctx PackageVarContext) string {
|
||||
return ctx.Config().GetenvWithDefault(envVar, defaultVal)
|
||||
})
|
||||
}
|
||||
|
|
|
@ -59,7 +59,7 @@ var (
|
|||
|
||||
// Rules to invoke ld to link binaries. Uses a .rsp file to list dependencies, as there may
|
||||
// be many.
|
||||
ld, ldRE = remoteexec.StaticRules(pctx, "ld",
|
||||
ld, ldRE = pctx.RemoteStaticRules("ld",
|
||||
blueprint.RuleParams{
|
||||
Command: "$reTemplate$ldCmd ${crtBegin} @${out}.rsp " +
|
||||
"${libFlags} ${crtEnd} -o ${out} ${ldFlags} ${extraLibFlags}",
|
||||
|
@ -80,7 +80,7 @@ var (
|
|||
}, []string{"ldCmd", "crtBegin", "libFlags", "crtEnd", "ldFlags", "extraLibFlags"}, []string{"implicitInputs", "implicitOutputs"})
|
||||
|
||||
// Rules for .o files to combine to other .o files, using ld partial linking.
|
||||
partialLd, partialLdRE = remoteexec.StaticRules(pctx, "partialLd",
|
||||
partialLd, partialLdRE = pctx.RemoteStaticRules("partialLd",
|
||||
blueprint.RuleParams{
|
||||
// Without -no-pie, clang 7.0 adds -pie to link Android files,
|
||||
// but -r and -pie cannot be used together.
|
||||
|
@ -189,7 +189,7 @@ var (
|
|||
"crossCompile", "format")
|
||||
|
||||
// Rule for invoking clang-tidy (a clang-based linter).
|
||||
clangTidy, clangTidyRE = remoteexec.StaticRules(pctx, "clangTidy",
|
||||
clangTidy, clangTidyRE = pctx.RemoteStaticRules("clangTidy",
|
||||
blueprint.RuleParams{
|
||||
Command: "rm -f $out && $reTemplate${config.ClangBin}/clang-tidy $tidyFlags $in -- $cFlags && touch $out",
|
||||
CommandDeps: []string{"${config.ClangBin}/clang-tidy"},
|
||||
|
@ -228,7 +228,7 @@ var (
|
|||
_ = pctx.SourcePathVariable("sAbiDumper", "prebuilts/clang-tools/${config.HostPrebuiltTag}/bin/header-abi-dumper")
|
||||
|
||||
// -w has been added since header-abi-dumper does not need to produce any sort of diagnostic information.
|
||||
sAbiDump, sAbiDumpRE = remoteexec.StaticRules(pctx, "sAbiDump",
|
||||
sAbiDump, sAbiDumpRE = pctx.RemoteStaticRules("sAbiDump",
|
||||
blueprint.RuleParams{
|
||||
Command: "rm -f $out && $reTemplate$sAbiDumper -o ${out} $in $exportDirs -- $cFlags -w -isystem prebuilts/clang-tools/${config.HostPrebuiltTag}/clang-headers",
|
||||
CommandDeps: []string{"$sAbiDumper"},
|
||||
|
@ -246,7 +246,7 @@ var (
|
|||
|
||||
// Rule to combine .dump sAbi dump files from multiple source files into a single .ldump
|
||||
// sAbi dump file.
|
||||
sAbiLink, sAbiLinkRE = remoteexec.StaticRules(pctx, "sAbiLink",
|
||||
sAbiLink, sAbiLinkRE = pctx.RemoteStaticRules("sAbiLink",
|
||||
blueprint.RuleParams{
|
||||
Command: "$reTemplate$sAbiLinker -o ${out} $symbolFilter -arch $arch $exportedHeaderFlags @${out}.rsp ",
|
||||
CommandDeps: []string{"$sAbiLinker"},
|
||||
|
@ -331,7 +331,6 @@ func init() {
|
|||
pctx.StaticVariable("relPwd", PwdPrefix())
|
||||
|
||||
pctx.HostBinToolVariable("SoongZipCmd", "soong_zip")
|
||||
pctx.Import("android/soong/remoteexec")
|
||||
}
|
||||
|
||||
// builderFlags contains various types of command line flags (and settings) for use in building
|
||||
|
|
|
@ -270,13 +270,13 @@ func init() {
|
|||
return ""
|
||||
})
|
||||
|
||||
pctx.VariableFunc("RECXXPool", remoteexec.EnvOverrideFunc("RBE_CXX_POOL", remoteexec.DefaultPool))
|
||||
pctx.VariableFunc("RECXXLinksPool", remoteexec.EnvOverrideFunc("RBE_CXX_LINKS_POOL", remoteexec.DefaultPool))
|
||||
pctx.VariableFunc("REClangTidyPool", remoteexec.EnvOverrideFunc("RBE_CLANG_TIDY_POOL", remoteexec.DefaultPool))
|
||||
pctx.VariableFunc("RECXXLinksExecStrategy", remoteexec.EnvOverrideFunc("RBE_CXX_LINKS_EXEC_STRATEGY", remoteexec.LocalExecStrategy))
|
||||
pctx.VariableFunc("REClangTidyExecStrategy", remoteexec.EnvOverrideFunc("RBE_CLANG_TIDY_EXEC_STRATEGY", remoteexec.LocalExecStrategy))
|
||||
pctx.VariableFunc("REAbiDumperExecStrategy", remoteexec.EnvOverrideFunc("RBE_ABI_DUMPER_EXEC_STRATEGY", remoteexec.LocalExecStrategy))
|
||||
pctx.VariableFunc("REAbiLinkerExecStrategy", remoteexec.EnvOverrideFunc("RBE_ABI_LINKER_EXEC_STRATEGY", remoteexec.LocalExecStrategy))
|
||||
pctx.StaticVariableWithEnvOverride("RECXXPool", "RBE_CXX_POOL", remoteexec.DefaultPool)
|
||||
pctx.StaticVariableWithEnvOverride("RECXXLinksPool", "RBE_CXX_LINKS_POOL", remoteexec.DefaultPool)
|
||||
pctx.StaticVariableWithEnvOverride("REClangTidyPool", "RBE_CLANG_TIDY_POOL", remoteexec.DefaultPool)
|
||||
pctx.StaticVariableWithEnvOverride("RECXXLinksExecStrategy", "RBE_CXX_LINKS_EXEC_STRATEGY", remoteexec.LocalExecStrategy)
|
||||
pctx.StaticVariableWithEnvOverride("REClangTidyExecStrategy", "RBE_CLANG_TIDY_EXEC_STRATEGY", remoteexec.LocalExecStrategy)
|
||||
pctx.StaticVariableWithEnvOverride("REAbiDumperExecStrategy", "RBE_ABI_DUMPER_EXEC_STRATEGY", remoteexec.LocalExecStrategy)
|
||||
pctx.StaticVariableWithEnvOverride("REAbiLinkerExecStrategy", "RBE_ABI_LINKER_EXEC_STRATEGY", remoteexec.LocalExecStrategy)
|
||||
}
|
||||
|
||||
var HostPrebuiltTag = pctx.VariableConfigMethod("HostPrebuiltTag", android.Config.PrebuiltOS)
|
||||
|
|
|
@ -30,7 +30,7 @@ import (
|
|||
)
|
||||
|
||||
var (
|
||||
Signapk, SignapkRE = remoteexec.StaticRules(pctx, "signapk",
|
||||
Signapk, SignapkRE = pctx.RemoteStaticRules("signapk",
|
||||
blueprint.RuleParams{
|
||||
Command: `rm -f $out && $reTemplate${config.JavaCmd} ${config.JavaVmFlags} -Djava.library.path=$$(dirname ${config.SignapkJniLibrary}) ` +
|
||||
`-jar ${config.SignapkCmd} $flags $certificates $in $out`,
|
||||
|
|
|
@ -40,7 +40,7 @@ var (
|
|||
// (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.
|
||||
// TODO(b/143658984): goma can't handle the --system argument to javac.
|
||||
javac, javacRE = remoteexec.MultiCommandStaticRules(pctx, "javac",
|
||||
javac, javacRE = pctx.MultiCommandRemoteStaticRules("javac",
|
||||
blueprint.RuleParams{
|
||||
Command: `rm -rf "$outDir" "$annoDir" "$srcJarDir" "$out" && mkdir -p "$outDir" "$annoDir" "$srcJarDir" && ` +
|
||||
`${config.ZipSyncCmd} -d $srcJarDir -l $srcJarDir/list -f "*.java" $srcJars && ` +
|
||||
|
@ -129,7 +129,7 @@ var (
|
|||
},
|
||||
"abis", "allow-prereleased", "screen-densities", "sdk-version", "stem", "apkcerts", "partition")
|
||||
|
||||
turbine, turbineRE = remoteexec.StaticRules(pctx, "turbine",
|
||||
turbine, turbineRE = pctx.RemoteStaticRules("turbine",
|
||||
blueprint.RuleParams{
|
||||
Command: `rm -rf "$outDir" && mkdir -p "$outDir" && ` +
|
||||
`$reTemplate${config.JavaCmd} ${config.JavaVmFlags} -jar ${config.TurbineJar} --output $out.tmp ` +
|
||||
|
@ -157,7 +157,7 @@ var (
|
|||
Platform: map[string]string{remoteexec.PoolKey: "${config.REJavaPool}"},
|
||||
}, []string{"javacFlags", "bootClasspath", "classpath", "srcJars", "outDir", "javaVersion"}, []string{"implicits"})
|
||||
|
||||
jar, jarRE = remoteexec.StaticRules(pctx, "jar",
|
||||
jar, jarRE = pctx.RemoteStaticRules("jar",
|
||||
blueprint.RuleParams{
|
||||
Command: `$reTemplate${config.SoongZipCmd} -jar -o $out @$out.rsp`,
|
||||
CommandDeps: []string{"${config.SoongZipCmd}"},
|
||||
|
@ -172,7 +172,7 @@ var (
|
|||
Platform: map[string]string{remoteexec.PoolKey: "${config.REJavaPool}"},
|
||||
}, []string{"jarArgs"}, nil)
|
||||
|
||||
zip, zipRE = remoteexec.StaticRules(pctx, "zip",
|
||||
zip, zipRE = pctx.RemoteStaticRules("zip",
|
||||
blueprint.RuleParams{
|
||||
Command: `${config.SoongZipCmd} -o $out @$out.rsp`,
|
||||
CommandDeps: []string{"${config.SoongZipCmd}"},
|
||||
|
@ -244,7 +244,6 @@ var (
|
|||
func init() {
|
||||
pctx.Import("android/soong/android")
|
||||
pctx.Import("android/soong/java/config")
|
||||
pctx.Import("android/soong/remoteexec")
|
||||
}
|
||||
|
||||
type javaBuilderFlags struct {
|
||||
|
|
|
@ -149,14 +149,14 @@ func init() {
|
|||
pctx.HostBinToolVariable("SoongJavacWrapper", "soong_javac_wrapper")
|
||||
pctx.HostBinToolVariable("DexpreoptGen", "dexpreopt_gen")
|
||||
|
||||
pctx.VariableFunc("REJavaPool", remoteexec.EnvOverrideFunc("RBE_JAVA_POOL", "java16"))
|
||||
pctx.VariableFunc("REJavacExecStrategy", remoteexec.EnvOverrideFunc("RBE_JAVAC_EXEC_STRATEGY", remoteexec.RemoteLocalFallbackExecStrategy))
|
||||
pctx.VariableFunc("RED8ExecStrategy", remoteexec.EnvOverrideFunc("RBE_D8_EXEC_STRATEGY", remoteexec.RemoteLocalFallbackExecStrategy))
|
||||
pctx.VariableFunc("RER8ExecStrategy", remoteexec.EnvOverrideFunc("RBE_R8_EXEC_STRATEGY", remoteexec.RemoteLocalFallbackExecStrategy))
|
||||
pctx.VariableFunc("RETurbineExecStrategy", remoteexec.EnvOverrideFunc("RBE_TURBINE_EXEC_STRATEGY", remoteexec.LocalExecStrategy))
|
||||
pctx.VariableFunc("RESignApkExecStrategy", remoteexec.EnvOverrideFunc("RBE_SIGNAPK_EXEC_STRATEGY", remoteexec.LocalExecStrategy))
|
||||
pctx.VariableFunc("REJarExecStrategy", remoteexec.EnvOverrideFunc("RBE_JAR_EXEC_STRATEGY", remoteexec.LocalExecStrategy))
|
||||
pctx.VariableFunc("REZipExecStrategy", remoteexec.EnvOverrideFunc("RBE_ZIP_EXEC_STRATEGY", remoteexec.LocalExecStrategy))
|
||||
pctx.StaticVariableWithEnvOverride("REJavaPool", "RBE_JAVA_POOL", "java16")
|
||||
pctx.StaticVariableWithEnvOverride("REJavacExecStrategy", "RBE_JAVAC_EXEC_STRATEGY", remoteexec.RemoteLocalFallbackExecStrategy)
|
||||
pctx.StaticVariableWithEnvOverride("RED8ExecStrategy", "RBE_D8_EXEC_STRATEGY", remoteexec.RemoteLocalFallbackExecStrategy)
|
||||
pctx.StaticVariableWithEnvOverride("RER8ExecStrategy", "RBE_R8_EXEC_STRATEGY", remoteexec.RemoteLocalFallbackExecStrategy)
|
||||
pctx.StaticVariableWithEnvOverride("RETurbineExecStrategy", "RBE_TURBINE_EXEC_STRATEGY", remoteexec.LocalExecStrategy)
|
||||
pctx.StaticVariableWithEnvOverride("RESignApkExecStrategy", "RBE_SIGNAPK_EXEC_STRATEGY", remoteexec.LocalExecStrategy)
|
||||
pctx.StaticVariableWithEnvOverride("REJarExecStrategy", "RBE_JAR_EXEC_STRATEGY", remoteexec.LocalExecStrategy)
|
||||
pctx.StaticVariableWithEnvOverride("REZipExecStrategy", "RBE_ZIP_EXEC_STRATEGY", remoteexec.LocalExecStrategy)
|
||||
|
||||
pctx.HostJavaToolVariable("JacocoCLIJar", "jacoco-cli.jar")
|
||||
|
||||
|
|
|
@ -83,7 +83,7 @@ func (d *dexer) effectiveOptimizeEnabled() bool {
|
|||
return BoolDefault(d.dexProperties.Optimize.Enabled, d.dexProperties.Optimize.EnabledByDefault)
|
||||
}
|
||||
|
||||
var d8, d8RE = remoteexec.MultiCommandStaticRules(pctx, "d8",
|
||||
var d8, d8RE = pctx.MultiCommandRemoteStaticRules("d8",
|
||||
blueprint.RuleParams{
|
||||
Command: `rm -rf "$outDir" && mkdir -p "$outDir" && ` +
|
||||
`$d8Template${config.D8Cmd} ${config.DexFlags} --output $outDir $d8Flags $in && ` +
|
||||
|
@ -111,7 +111,7 @@ var d8, d8RE = remoteexec.MultiCommandStaticRules(pctx, "d8",
|
|||
},
|
||||
}, []string{"outDir", "d8Flags", "zipFlags"}, nil)
|
||||
|
||||
var r8, r8RE = remoteexec.MultiCommandStaticRules(pctx, "r8",
|
||||
var r8, r8RE = pctx.MultiCommandRemoteStaticRules("r8",
|
||||
blueprint.RuleParams{
|
||||
Command: `rm -rf "$outDir" && mkdir -p "$outDir" && ` +
|
||||
`rm -f "$outDict" && rm -rf "${outUsageDir}" && ` +
|
||||
|
|
|
@ -1235,7 +1235,7 @@ func metalavaCmd(ctx android.ModuleContext, rule *android.RuleBuilder, javaVersi
|
|||
ToolchainInputs: []string{config.JavaCmd(ctx).String()},
|
||||
Platform: map[string]string{remoteexec.PoolKey: pool},
|
||||
EnvironmentVariables: []string{"ANDROID_SDK_HOME"},
|
||||
}).NoVarTemplate(ctx.Config()))
|
||||
}).NoVarTemplate(ctx.Config().RBEWrapper()))
|
||||
}
|
||||
|
||||
cmd.BuiltTool("metalava").
|
||||
|
|
|
@ -430,7 +430,7 @@ func (l *linter) lint(ctx android.ModuleContext) {
|
|||
"LANG",
|
||||
},
|
||||
Platform: map[string]string{remoteexec.PoolKey: pool},
|
||||
}).NoVarTemplate(ctx.Config()))
|
||||
}).NoVarTemplate(ctx.Config().RBEWrapper()))
|
||||
}
|
||||
|
||||
cmd.BuiltTool("lint").
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in a new issue