Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 77cdcfde authored by Colin Cross's avatar Colin Cross
Browse files

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
parent ab020a73
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -13,6 +13,7 @@ bootstrap_go_package {
        "soong-android-soongconfig",
        "soong-bazel",
        "soong-cquery",
        "soong-remoteexec",
        "soong-shared",
        "soong-ui-metrics_proto",
    ],
+5 −0
Original line number Diff line number Diff line
@@ -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)
}
+4 −0
Original line number Diff line number Diff line
@@ -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 (
+39 −0
Original line number Diff line number Diff line
@@ -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)
	})
}
+5 −6
Original line number Diff line number Diff line
@@ -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
Loading