Allow n2 as a replacement for ninja in builds
If `SOONG_USE_N2=true` is set in the environment, then n2 is used in
place of ninja. Some ninja features are not available in n2 at this
time, but this enables bringup efforts to happen in parallel.
Bug: 352368206
Test: manual
Change-Id: I8455cb24eb640a4651782ee76e48a7d3a9932b93
diff --git a/ui/build/config.go b/ui/build/config.go
index 52c5e23..2470f84 100644
--- a/ui/build/config.go
+++ b/ui/build/config.go
@@ -121,6 +121,10 @@
// There's quite a bit of overlap with module-info.json and soong module graph. We
// could consider merging them.
moduleDebugFile string
+
+ // Whether to use n2 instead of ninja. This is controlled with the
+ // environment variable SOONG_USE_N2
+ useN2 bool
}
type NinjaWeightListSource uint
@@ -283,6 +287,10 @@
ret.moduleDebugFile, _ = filepath.Abs(shared.JoinPath(ret.SoongOutDir(), "soong-debug-info.json"))
}
+ if os.Getenv("SOONG_USE_N2") == "true" {
+ ret.useN2 = true
+ }
+
ret.environ.Unset(
// We're already using it
"USE_SOONG_UI",
@@ -339,6 +347,9 @@
// We read it here already, don't let others share in the fun
"GENERATE_SOONG_DEBUG",
+
+ // Use config.useN2 instead.
+ "SOONG_USE_N2",
)
if ret.UseGoma() || ret.ForceUseGoma() {