Fix propagating EMPTY_NINJA_FILE from multiproduct_kati to minibp

I6dca478f356f56a8aee1e457d71439272351390b replaced calling
build/blueprint/bootstrap.bash with running minibp directly,
but didn't propagate the EMPTY_NINJA_FILE environment variable
to minibp.  Since everything that uses EMPTY_NINJA_FILE is
executed directly from soong_ui now, replace the EMPTY_NINJA_FILE
environment variable with a config bool and pass it to minibp.

Bug: 189148777
Test: build/soong/build_test.bash --dist --incremental --shard-count=300 --shard=1 && du out/multiproduct
Change-Id: I4d64275ce02c5d68948012f71ac4dc3795af9e85
Merged-In: I4d64275ce02c5d68948012f71ac4dc3795af9e85
(cherry picked from commit f3bdbcbea3)
This commit is contained in:
Colin Cross
2021-06-01 11:43:55 -07:00
parent f58e5e8f24
commit 7dcd16c6eb
4 changed files with 14 additions and 5 deletions

View File

@@ -433,7 +433,7 @@ func buildProduct(mpctx *mpContext, product string) {
config := build.NewConfig(ctx, args...)
config.Environment().Set("OUT_DIR", outDir)
if !*keepArtifacts {
config.Environment().Set("EMPTY_NINJA_FILE", "true")
config.SetEmptyNinjaFile(true)
}
build.FindSources(ctx, config, mpctx.Finder)
config.Lunch(ctx, product, *buildVariant)

View File

@@ -72,6 +72,9 @@ type configImpl struct {
// During Bazel execution, Bazel cannot write outside OUT_DIR.
// So if DIST_DIR is set to an external dir (outside of OUT_DIR), we need to rig it temporarily and then migrate files at the end of the build.
riggedDistDirForBazel string
// Set by multiproduct_kati
emptyNinjaFile bool
}
const srcDirFileCheck = "build/soong/root.bp"
@@ -203,9 +206,6 @@ func NewConfig(ctx Context, args ...string) Config {
"ANDROID_DEV_SCRIPTS",
"ANDROID_EMULATOR_PREBUILTS",
"ANDROID_PRE_BUILD_PATHS",
// Only set in multiproduct_kati after config generation
"EMPTY_NINJA_FILE",
)
if ret.UseGoma() || ret.ForceUseGoma() {
@@ -1189,3 +1189,11 @@ func (c *configImpl) LogsDir() string {
func (c *configImpl) BazelMetricsDir() string {
return filepath.Join(c.LogsDir(), "bazel_metrics")
}
func (c *configImpl) SetEmptyNinjaFile(v bool) {
c.emptyNinjaFile = v
}
func (c *configImpl) EmptyNinjaFile() bool {
return c.emptyNinjaFile
}

View File

@@ -136,7 +136,7 @@ func runKati(ctx Context, config Config, extraSuffix string, args []string, envF
// information out with --empty_ninja_file.
//
// From https://github.com/google/kati/commit/87b8da7af2c8bea28b1d8ab17679453d859f96e5
if config.Environment().IsEnvTrue("EMPTY_NINJA_FILE") {
if config.EmptyNinjaFile() {
args = append(args, "--empty_ninja_file")
}

View File

@@ -119,6 +119,7 @@ func bootstrapBlueprint(ctx Context, config Config, integratedBp2Build bool) {
args.OutFile = shared.JoinPath(config.SoongOutDir(), ".bootstrap/build.ninja")
args.GlobFile = globFile
args.GeneratingPrimaryBuilder = true
args.EmptyNinjaFile = config.EmptyNinjaFile()
args.DelveListen = os.Getenv("SOONG_DELVE")
if args.DelveListen != "" {