Add bazel staging mode to soong build.
This is to use bazel to build targets that are being prepared for an incipient release to the prod mode allowlist. Bug: 254265047 Test: m nothing Test: m nothing --bazel-mode-dev Test: m nothing --bazel-mode-staging Change-Id: Ic78a59cf51dba83ef1ac26483586560ea9b24aaf
This commit is contained in:
parent
bdb7495fe5
commit
b78465de1d
8 changed files with 56 additions and 9 deletions
|
@ -1347,4 +1347,8 @@ var (
|
|||
ProdMixedBuildsEnabledList = []string{
|
||||
"com.android.adbd",
|
||||
}
|
||||
|
||||
// Staging builds should be entirely prod, plus some near-ready ones. Add the
|
||||
// new ones to the first argument as needed.
|
||||
StagingMixedBuildsEnabledList = append([]string{}, ProdMixedBuildsEnabledList...)
|
||||
)
|
||||
|
|
|
@ -386,6 +386,12 @@ func NewBazelContext(c *config) (BazelContext, error) {
|
|||
for _, enabledProdModule := range allowlists.ProdMixedBuildsEnabledList {
|
||||
enabledModules[enabledProdModule] = true
|
||||
}
|
||||
case BazelStagingMode:
|
||||
modulesDefaultToBazel = false
|
||||
for _, enabledStagingMode := range allowlists.StagingMixedBuildsEnabledList {
|
||||
enabledModules[enabledStagingMode] = true
|
||||
|
||||
}
|
||||
case BazelDevMode:
|
||||
modulesDefaultToBazel = true
|
||||
|
||||
|
|
|
@ -97,6 +97,11 @@ const (
|
|||
// allowlisted on an experimental basis.
|
||||
BazelDevMode
|
||||
|
||||
// Use bazel during analysis of a few allowlisted build modules. The allowlist
|
||||
// is considered "staging, as these are modules being prepared to be released
|
||||
// into prod mode shortly after.
|
||||
BazelStagingMode
|
||||
|
||||
// Use bazel during analysis of build modules from an allowlist carefully
|
||||
// curated by the build team to be proven stable.
|
||||
BazelProdMode
|
||||
|
|
|
@ -88,6 +88,7 @@ func init() {
|
|||
flag.StringVar(&cmdlineArgs.OutFile, "o", "build.ninja", "the Ninja file to output")
|
||||
flag.BoolVar(&cmdlineArgs.EmptyNinjaFile, "empty-ninja-file", false, "write out a 0-byte ninja file")
|
||||
flag.BoolVar(&cmdlineArgs.BazelMode, "bazel-mode", false, "use bazel for analysis of certain modules")
|
||||
flag.BoolVar(&cmdlineArgs.BazelMode, "bazel-mode-staging", false, "use bazel for analysis of certain near-ready modules")
|
||||
flag.BoolVar(&cmdlineArgs.BazelModeDev, "bazel-mode-dev", false, "use bazel for analysis of a large number of modules (less stable)")
|
||||
|
||||
// Flags that probably shouldn't be flags of soong_build but we haven't found
|
||||
|
@ -142,6 +143,8 @@ func newConfig(availableEnv map[string]string) android.Config {
|
|||
buildMode = android.BazelDevMode
|
||||
} else if cmdlineArgs.BazelMode {
|
||||
buildMode = android.BazelProdMode
|
||||
} else if cmdlineArgs.BazelModeStaging {
|
||||
buildMode = android.BazelStagingMode
|
||||
} else {
|
||||
buildMode = android.AnalysisNoBazel
|
||||
}
|
||||
|
|
|
@ -112,9 +112,19 @@ const (
|
|||
// checkBazelMode fails the build if there are conflicting arguments for which bazel
|
||||
// build mode to use.
|
||||
func checkBazelMode(ctx Context, config Config) {
|
||||
if config.bazelProdMode && config.bazelDevMode {
|
||||
count := 0
|
||||
if config.bazelProdMode {
|
||||
count++
|
||||
}
|
||||
if config.bazelDevMode {
|
||||
count++
|
||||
}
|
||||
if config.bazelStagingMode {
|
||||
count++
|
||||
}
|
||||
if count > 1 {
|
||||
ctx.Fatalln("Conflicting bazel mode.\n" +
|
||||
"Do not specify both --bazel-mode and --bazel-mode-dev")
|
||||
"Do not specify more than one of --bazel-mode and --bazel-mode-dev and --bazel-mode-staging ")
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -100,8 +100,9 @@ type configImpl struct {
|
|||
|
||||
pathReplaced bool
|
||||
|
||||
bazelProdMode bool
|
||||
bazelDevMode bool
|
||||
bazelProdMode bool
|
||||
bazelDevMode bool
|
||||
bazelStagingMode bool
|
||||
|
||||
// Set by multiproduct_kati
|
||||
emptyNinjaFile bool
|
||||
|
@ -721,6 +722,8 @@ func (c *configImpl) parseArgs(ctx Context, args []string) {
|
|||
c.bazelProdMode = true
|
||||
} else if arg == "--bazel-mode-dev" {
|
||||
c.bazelDevMode = true
|
||||
} else if arg == "--bazel-mode-staging" {
|
||||
c.bazelStagingMode = true
|
||||
} else if len(arg) > 0 && arg[0] == '-' {
|
||||
parseArgNum := func(def int) int {
|
||||
if len(arg) > 2 {
|
||||
|
@ -1115,7 +1118,7 @@ func (c *configImpl) UseRBE() bool {
|
|||
}
|
||||
|
||||
func (c *configImpl) BazelBuildEnabled() bool {
|
||||
return c.bazelProdMode || c.bazelDevMode
|
||||
return c.bazelProdMode || c.bazelDevMode || c.bazelStagingMode
|
||||
}
|
||||
|
||||
func (c *configImpl) StartRBE() bool {
|
||||
|
|
|
@ -1008,6 +1008,7 @@ func TestBuildConfig(t *testing.T) {
|
|||
useBazel bool
|
||||
bazelDevMode bool
|
||||
bazelProdMode bool
|
||||
bazelStagingMode bool
|
||||
expectedBuildConfig *smpb.BuildConfig
|
||||
}{
|
||||
{
|
||||
|
@ -1083,6 +1084,17 @@ func TestBuildConfig(t *testing.T) {
|
|||
BazelMixedBuild: proto.Bool(true),
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "bazel mixed build from staging mode",
|
||||
environ: Environment{},
|
||||
bazelStagingMode: true,
|
||||
expectedBuildConfig: &smpb.BuildConfig{
|
||||
ForceUseGoma: proto.Bool(false),
|
||||
UseGoma: proto.Bool(false),
|
||||
UseRbe: proto.Bool(false),
|
||||
BazelMixedBuild: proto.Bool(true),
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "specified targets",
|
||||
environ: Environment{},
|
||||
|
@ -1118,10 +1130,11 @@ func TestBuildConfig(t *testing.T) {
|
|||
for _, tc := range tests {
|
||||
t.Run(tc.name, func(t *testing.T) {
|
||||
c := &configImpl{
|
||||
environ: &tc.environ,
|
||||
bazelDevMode: tc.bazelDevMode,
|
||||
bazelProdMode: tc.bazelProdMode,
|
||||
arguments: tc.arguments,
|
||||
environ: &tc.environ,
|
||||
bazelDevMode: tc.bazelDevMode,
|
||||
bazelProdMode: tc.bazelProdMode,
|
||||
bazelStagingMode: tc.bazelStagingMode,
|
||||
arguments: tc.arguments,
|
||||
}
|
||||
config := Config{c}
|
||||
checkBazelMode(ctx, config)
|
||||
|
|
|
@ -260,6 +260,9 @@ func bootstrapBlueprint(ctx Context, config Config) {
|
|||
if config.bazelDevMode {
|
||||
mainSoongBuildExtraArgs = append(mainSoongBuildExtraArgs, "--bazel-mode-dev")
|
||||
}
|
||||
if config.bazelStagingMode {
|
||||
mainSoongBuildExtraArgs = append(mainSoongBuildExtraArgs, "--bazel-mode-staging")
|
||||
}
|
||||
|
||||
mainSoongBuildInvocation := primaryBuilderInvocation(
|
||||
config,
|
||||
|
|
Loading…
Reference in a new issue