Loading ui/build/config.go +11 −0 Original line number Diff line number Diff line Loading @@ -121,6 +121,10 @@ type configImpl struct { // 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 Loading Loading @@ -283,6 +287,10 @@ func NewConfig(ctx Context, args ...string) Config { 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", Loading Loading @@ -339,6 +347,9 @@ func NewConfig(ctx Context, args ...string) Config { // 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() { Loading ui/build/ninja.go +37 −11 Original line number Diff line number Diff line Loading @@ -56,6 +56,17 @@ func runNinjaForBuild(ctx Context, config Config) { "-d", "stats", "--frontend_file", fifo, } if config.useN2 { executable = config.PrebuiltBuildTool("n2") args = []string{ "-d", "trace", // TODO: implement these features, or remove them. //"-d", "keepdepfile", //"-d", "keeprsp", //"-d", "stats", "--frontend-file", fifo, } } args = append(args, config.NinjaArgs()...) Loading @@ -72,18 +83,22 @@ func runNinjaForBuild(ctx Context, config Config) { args = append(args, "-f", config.CombinedNinjaFile()) if !config.useN2 { args = append(args, "-o", "usesphonyoutputs=yes", "-w", "dupbuild=err", "-w", "missingdepfile=err") } if !config.BuildBrokenMissingOutputs() { // Missing outputs will be treated as errors. // BUILD_BROKEN_MISSING_OUTPUTS can be used to bypass this check. if !config.useN2 { args = append(args, "-w", "missingoutfile=err", ) } } cmd := Command(ctx, config, "ninja", executable, args...) Loading @@ -97,17 +112,23 @@ func runNinjaForBuild(ctx Context, config Config) { switch config.NinjaWeightListSource() { case NINJA_LOG: if !config.useN2 { cmd.Args = append(cmd.Args, "-o", "usesninjalogasweightlist=yes") } case EVENLY_DISTRIBUTED: // pass empty weight list means ninja considers every tasks's weight as 1(default value). if !config.useN2 { cmd.Args = append(cmd.Args, "-o", "usesweightlist=/dev/null") } case EXTERNAL_FILE: fallthrough case HINT_FROM_SOONG: // The weight list is already copied/generated. if !config.useN2 { ninjaWeightListPath := filepath.Join(config.OutDir(), ninjaWeightListFileName) cmd.Args = append(cmd.Args, "-o", "usesweightlist="+ninjaWeightListPath) } } // Allow both NINJA_ARGS and NINJA_EXTRA_ARGS, since both have been // used in the past to specify extra ninja arguments. Loading Loading @@ -206,11 +227,16 @@ func runNinjaForBuild(ctx Context, config Config) { // We don't want this build broken flag to cause reanalysis, so allow it through to the // actions. "BUILD_BROKEN_INCORRECT_PARTITION_IMAGES", "SOONG_USE_N2", "RUST_BACKTRACE", }, config.BuildBrokenNinjaUsesEnvVars()...)...) } cmd.Environment.Set("DIST_DIR", config.DistDir()) cmd.Environment.Set("SHELL", "/bin/bash") if config.useN2 { cmd.Environment.Set("RUST_BACKTRACE", "1") } // Print the environment variables that Ninja is operating in. ctx.Verboseln("Ninja environment: ") Loading ui/build/soong.go +22 −1 Original line number Diff line number Diff line Loading @@ -638,6 +638,22 @@ func runSoong(ctx Context, config Config) { "--frontend_file", fifo, "-f", filepath.Join(config.SoongOutDir(), "bootstrap.ninja"), } if config.useN2 { ninjaArgs = []string{ // TODO: implement these features, or remove them. //"-d", "keepdepfile", //"-d", "stats", //"-o", "usesphonyoutputs=yes", //"-o", "preremoveoutputs=yes", //"-w", "dupbuild=err", //"-w", "outputdir=err", //"-w", "missingoutfile=err", "-v", "-j", strconv.Itoa(config.Parallel()), "--frontend-file", fifo, "-f", filepath.Join(config.SoongOutDir(), "bootstrap.ninja"), } } if extra, ok := config.Environment().Get("SOONG_UI_NINJA_ARGS"); ok { ctx.Printf(`CAUTION: arguments in $SOONG_UI_NINJA_ARGS=%q, e.g. "-n", can make soong_build FAIL or INCORRECT`, extra) Loading @@ -645,8 +661,13 @@ func runSoong(ctx Context, config Config) { } ninjaArgs = append(ninjaArgs, targets...) ninjaCmd := config.PrebuiltBuildTool("ninja") if config.useN2 { ninjaCmd = config.PrebuiltBuildTool("n2") } cmd := Command(ctx, config, "soong bootstrap", config.PrebuiltBuildTool("ninja"), ninjaArgs...) ninjaCmd, ninjaArgs...) var ninjaEnv Environment Loading Loading
ui/build/config.go +11 −0 Original line number Diff line number Diff line Loading @@ -121,6 +121,10 @@ type configImpl struct { // 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 Loading Loading @@ -283,6 +287,10 @@ func NewConfig(ctx Context, args ...string) Config { 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", Loading Loading @@ -339,6 +347,9 @@ func NewConfig(ctx Context, args ...string) Config { // 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() { Loading
ui/build/ninja.go +37 −11 Original line number Diff line number Diff line Loading @@ -56,6 +56,17 @@ func runNinjaForBuild(ctx Context, config Config) { "-d", "stats", "--frontend_file", fifo, } if config.useN2 { executable = config.PrebuiltBuildTool("n2") args = []string{ "-d", "trace", // TODO: implement these features, or remove them. //"-d", "keepdepfile", //"-d", "keeprsp", //"-d", "stats", "--frontend-file", fifo, } } args = append(args, config.NinjaArgs()...) Loading @@ -72,18 +83,22 @@ func runNinjaForBuild(ctx Context, config Config) { args = append(args, "-f", config.CombinedNinjaFile()) if !config.useN2 { args = append(args, "-o", "usesphonyoutputs=yes", "-w", "dupbuild=err", "-w", "missingdepfile=err") } if !config.BuildBrokenMissingOutputs() { // Missing outputs will be treated as errors. // BUILD_BROKEN_MISSING_OUTPUTS can be used to bypass this check. if !config.useN2 { args = append(args, "-w", "missingoutfile=err", ) } } cmd := Command(ctx, config, "ninja", executable, args...) Loading @@ -97,17 +112,23 @@ func runNinjaForBuild(ctx Context, config Config) { switch config.NinjaWeightListSource() { case NINJA_LOG: if !config.useN2 { cmd.Args = append(cmd.Args, "-o", "usesninjalogasweightlist=yes") } case EVENLY_DISTRIBUTED: // pass empty weight list means ninja considers every tasks's weight as 1(default value). if !config.useN2 { cmd.Args = append(cmd.Args, "-o", "usesweightlist=/dev/null") } case EXTERNAL_FILE: fallthrough case HINT_FROM_SOONG: // The weight list is already copied/generated. if !config.useN2 { ninjaWeightListPath := filepath.Join(config.OutDir(), ninjaWeightListFileName) cmd.Args = append(cmd.Args, "-o", "usesweightlist="+ninjaWeightListPath) } } // Allow both NINJA_ARGS and NINJA_EXTRA_ARGS, since both have been // used in the past to specify extra ninja arguments. Loading Loading @@ -206,11 +227,16 @@ func runNinjaForBuild(ctx Context, config Config) { // We don't want this build broken flag to cause reanalysis, so allow it through to the // actions. "BUILD_BROKEN_INCORRECT_PARTITION_IMAGES", "SOONG_USE_N2", "RUST_BACKTRACE", }, config.BuildBrokenNinjaUsesEnvVars()...)...) } cmd.Environment.Set("DIST_DIR", config.DistDir()) cmd.Environment.Set("SHELL", "/bin/bash") if config.useN2 { cmd.Environment.Set("RUST_BACKTRACE", "1") } // Print the environment variables that Ninja is operating in. ctx.Verboseln("Ninja environment: ") Loading
ui/build/soong.go +22 −1 Original line number Diff line number Diff line Loading @@ -638,6 +638,22 @@ func runSoong(ctx Context, config Config) { "--frontend_file", fifo, "-f", filepath.Join(config.SoongOutDir(), "bootstrap.ninja"), } if config.useN2 { ninjaArgs = []string{ // TODO: implement these features, or remove them. //"-d", "keepdepfile", //"-d", "stats", //"-o", "usesphonyoutputs=yes", //"-o", "preremoveoutputs=yes", //"-w", "dupbuild=err", //"-w", "outputdir=err", //"-w", "missingoutfile=err", "-v", "-j", strconv.Itoa(config.Parallel()), "--frontend-file", fifo, "-f", filepath.Join(config.SoongOutDir(), "bootstrap.ninja"), } } if extra, ok := config.Environment().Get("SOONG_UI_NINJA_ARGS"); ok { ctx.Printf(`CAUTION: arguments in $SOONG_UI_NINJA_ARGS=%q, e.g. "-n", can make soong_build FAIL or INCORRECT`, extra) Loading @@ -645,8 +661,13 @@ func runSoong(ctx Context, config Config) { } ninjaArgs = append(ninjaArgs, targets...) ninjaCmd := config.PrebuiltBuildTool("ninja") if config.useN2 { ninjaCmd = config.PrebuiltBuildTool("n2") } cmd := Command(ctx, config, "soong bootstrap", config.PrebuiltBuildTool("ninja"), ninjaArgs...) ninjaCmd, ninjaArgs...) var ninjaEnv Environment Loading