Various cleanup in soong_ui to aid new feature
- Rename the "BuildX" variables to "RunX"
- Remove redundant comments
- Inline all the "what to do" based on config in build.go
- Inline some constants only used in one place
Bug: 189187214
Test: m nothing
Test: build/soong/build_test.bash
Change-Id: I111a69e642212d7938d4971283545e0d9acbb01a
Merged-In: I111a69e642212d7938d4971283545e0d9acbb01a
(cherry picked from commit d274ea9196
)
This commit is contained in:
@@ -460,19 +460,21 @@ func buildProduct(mpctx *mpContext, product string) {
|
|||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
|
||||||
buildWhat := build.BuildProductConfig
|
config.SetSkipNinja(true)
|
||||||
|
|
||||||
|
buildWhat := build.RunProductConfig
|
||||||
if !*onlyConfig {
|
if !*onlyConfig {
|
||||||
buildWhat |= build.BuildSoong
|
buildWhat |= build.RunSoong
|
||||||
if !*onlySoong {
|
if !*onlySoong {
|
||||||
buildWhat |= build.BuildKati
|
buildWhat |= build.RunKati
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
before := time.Now()
|
before := time.Now()
|
||||||
build.Build(ctx, config, buildWhat)
|
build.Build(ctx, config)
|
||||||
|
|
||||||
// Save std_full.log if Kati re-read the makefiles
|
// Save std_full.log if Kati re-read the makefiles
|
||||||
if buildWhat&build.BuildKati != 0 {
|
if buildWhat&build.RunKati != 0 {
|
||||||
if after, err := os.Stat(config.KatiBuildNinjaFile()); err == nil && after.ModTime().After(before) {
|
if after, err := os.Stat(config.KatiBuildNinjaFile()); err == nil && after.ModTime().After(before) {
|
||||||
err := copyFile(stdLog, filepath.Join(filepath.Dir(stdLog), "std_full.log"))
|
err := copyFile(stdLog, filepath.Join(filepath.Dir(stdLog), "std_full.log"))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@@ -59,12 +59,10 @@ type command struct {
|
|||||||
run func(ctx build.Context, config build.Config, args []string, logsDir string)
|
run func(ctx build.Context, config build.Config, args []string, logsDir string)
|
||||||
}
|
}
|
||||||
|
|
||||||
const makeModeFlagName = "--make-mode"
|
|
||||||
|
|
||||||
// list of supported commands (flags) supported by soong ui
|
// list of supported commands (flags) supported by soong ui
|
||||||
var commands []command = []command{
|
var commands []command = []command{
|
||||||
{
|
{
|
||||||
flag: makeModeFlagName,
|
flag: "--make-mode",
|
||||||
description: "build the modules by the target name (i.e. soong_docs)",
|
description: "build the modules by the target name (i.e. soong_docs)",
|
||||||
config: func(ctx build.Context, args ...string) build.Config {
|
config: func(ctx build.Context, args ...string) build.Config {
|
||||||
return build.NewConfig(ctx, args...)
|
return build.NewConfig(ctx, args...)
|
||||||
@@ -506,15 +504,7 @@ func runMake(ctx build.Context, config build.Config, _ []string, logsDir string)
|
|||||||
ctx.Fatal("done")
|
ctx.Fatal("done")
|
||||||
}
|
}
|
||||||
|
|
||||||
toBuild := build.BuildAll
|
build.Build(ctx, config)
|
||||||
if config.UseBazel() {
|
|
||||||
toBuild = build.BuildAllWithBazel
|
|
||||||
}
|
|
||||||
|
|
||||||
if config.Checkbuild() {
|
|
||||||
toBuild |= build.RunBuildTests
|
|
||||||
}
|
|
||||||
build.Build(ctx, config, toBuild)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// getCommand finds the appropriate command based on args[1] flag. args[0]
|
// getCommand finds the appropriate command based on args[1] flag. args[0]
|
||||||
|
@@ -115,7 +115,7 @@ func (t *Test) Run(logsDir string) {
|
|||||||
defer f.Shutdown()
|
defer f.Shutdown()
|
||||||
build.FindSources(buildCtx, config, f)
|
build.FindSources(buildCtx, config, f)
|
||||||
|
|
||||||
build.Build(buildCtx, config, build.BuildAll)
|
build.Build(buildCtx, config)
|
||||||
|
|
||||||
t.results.metrics = met
|
t.results.metrics = met
|
||||||
}
|
}
|
||||||
|
@@ -87,15 +87,20 @@ func createCombinedBuildNinjaFile(ctx Context, config Config) {
|
|||||||
|
|
||||||
// These are bitmasks which can be used to check whether various flags are set e.g. whether to use Bazel.
|
// These are bitmasks which can be used to check whether various flags are set e.g. whether to use Bazel.
|
||||||
const (
|
const (
|
||||||
BuildNone = iota
|
_ = iota
|
||||||
BuildProductConfig = 1 << iota
|
// Whether to run the kati config step.
|
||||||
BuildSoong = 1 << iota
|
RunProductConfig = 1 << iota
|
||||||
BuildKati = 1 << iota
|
// Whether to run soong to generate a ninja file.
|
||||||
BuildNinja = 1 << iota
|
RunSoong = 1 << iota
|
||||||
BuildBazel = 1 << iota
|
// Whether to run kati to generate a ninja file.
|
||||||
RunBuildTests = 1 << iota
|
RunKati = 1 << iota
|
||||||
BuildAll = BuildProductConfig | BuildSoong | BuildKati | BuildNinja
|
// Whether to run ninja on the combined ninja.
|
||||||
BuildAllWithBazel = BuildProductConfig | BuildSoong | BuildKati | BuildBazel
|
RunNinja = 1 << iota
|
||||||
|
// Whether to run bazel on the combined ninja.
|
||||||
|
RunBazel = 1 << iota
|
||||||
|
RunBuildTests = 1 << iota
|
||||||
|
RunAll = RunProductConfig | RunSoong | RunKati | RunNinja
|
||||||
|
RunAllWithBazel = RunProductConfig | RunSoong | RunKati | RunBazel
|
||||||
)
|
)
|
||||||
|
|
||||||
// checkProblematicFiles fails the build if existing Android.mk or CleanSpec.mk files are found at the root of the tree.
|
// checkProblematicFiles fails the build if existing Android.mk or CleanSpec.mk files are found at the root of the tree.
|
||||||
@@ -173,7 +178,7 @@ func checkRAM(ctx Context, config Config) {
|
|||||||
|
|
||||||
// Build the tree. The 'what' argument can be used to chose which components of
|
// Build the tree. The 'what' argument can be used to chose which components of
|
||||||
// the build to run, via checking various bitmasks.
|
// the build to run, via checking various bitmasks.
|
||||||
func Build(ctx Context, config Config, what int) {
|
func Build(ctx Context, config Config) {
|
||||||
ctx.Verboseln("Starting build with args:", config.Arguments())
|
ctx.Verboseln("Starting build with args:", config.Arguments())
|
||||||
ctx.Verboseln("Environment:", config.Environment().Environ())
|
ctx.Verboseln("Environment:", config.Environment().Environ())
|
||||||
|
|
||||||
@@ -208,33 +213,35 @@ func Build(ctx Context, config Config, what int) {
|
|||||||
|
|
||||||
SetupPath(ctx, config)
|
SetupPath(ctx, config)
|
||||||
|
|
||||||
|
what := RunAll
|
||||||
|
if config.UseBazel() {
|
||||||
|
what = RunAllWithBazel
|
||||||
|
}
|
||||||
|
if config.Checkbuild() {
|
||||||
|
what |= RunBuildTests
|
||||||
|
}
|
||||||
if config.SkipConfig() {
|
if config.SkipConfig() {
|
||||||
ctx.Verboseln("Skipping Config as requested")
|
ctx.Verboseln("Skipping Config as requested")
|
||||||
what = what &^ BuildProductConfig
|
what = what &^ RunProductConfig
|
||||||
}
|
}
|
||||||
|
|
||||||
if config.SkipKati() {
|
if config.SkipKati() {
|
||||||
ctx.Verboseln("Skipping Kati as requested")
|
ctx.Verboseln("Skipping Kati as requested")
|
||||||
what = what &^ BuildKati
|
what = what &^ RunKati
|
||||||
}
|
}
|
||||||
|
|
||||||
if config.SkipNinja() {
|
if config.SkipNinja() {
|
||||||
ctx.Verboseln("Skipping Ninja as requested")
|
ctx.Verboseln("Skipping Ninja as requested")
|
||||||
what = what &^ BuildNinja
|
what = what &^ RunNinja
|
||||||
}
|
}
|
||||||
|
|
||||||
if config.StartGoma() {
|
if config.StartGoma() {
|
||||||
// Ensure start Goma compiler_proxy
|
|
||||||
startGoma(ctx, config)
|
startGoma(ctx, config)
|
||||||
}
|
}
|
||||||
|
|
||||||
if config.StartRBE() {
|
if config.StartRBE() {
|
||||||
// Ensure RBE proxy is started
|
|
||||||
startRBE(ctx, config)
|
startRBE(ctx, config)
|
||||||
}
|
}
|
||||||
|
|
||||||
if what&BuildProductConfig != 0 {
|
if what&RunProductConfig != 0 {
|
||||||
// Run make for product config
|
|
||||||
runMakeProductConfig(ctx, config)
|
runMakeProductConfig(ctx, config)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -254,8 +261,7 @@ func Build(ctx Context, config Config, what int) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if what&BuildSoong != 0 {
|
if what&RunSoong != 0 {
|
||||||
// Run Soong
|
|
||||||
runSoong(ctx, config)
|
runSoong(ctx, config)
|
||||||
|
|
||||||
if config.bazelBuildMode() == generateBuildFiles {
|
if config.bazelBuildMode() == generateBuildFiles {
|
||||||
@@ -264,8 +270,7 @@ func Build(ctx Context, config Config, what int) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if what&BuildKati != 0 {
|
if what&RunKati != 0 {
|
||||||
// Run ckati
|
|
||||||
genKatiSuffix(ctx, config)
|
genKatiSuffix(ctx, config)
|
||||||
runKatiCleanSpec(ctx, config)
|
runKatiCleanSpec(ctx, config)
|
||||||
runKatiBuild(ctx, config)
|
runKatiBuild(ctx, config)
|
||||||
@@ -289,17 +294,16 @@ func Build(ctx Context, config Config, what int) {
|
|||||||
testForDanglingRules(ctx, config)
|
testForDanglingRules(ctx, config)
|
||||||
}
|
}
|
||||||
|
|
||||||
if what&BuildNinja != 0 {
|
if what&RunNinja != 0 {
|
||||||
if what&BuildKati != 0 {
|
if what&RunKati != 0 {
|
||||||
installCleanIfNecessary(ctx, config)
|
installCleanIfNecessary(ctx, config)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Run ninja
|
|
||||||
runNinjaForBuild(ctx, config)
|
runNinjaForBuild(ctx, config)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Currently, using Bazel requires Kati and Soong to run first, so check whether to run Bazel last.
|
// Currently, using Bazel requires Kati and Soong to run first, so check whether to run Bazel last.
|
||||||
if what&BuildBazel != 0 {
|
if what&RunBazel != 0 {
|
||||||
runBazel(ctx, config)
|
runBazel(ctx, config)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -567,8 +567,7 @@ func getTargetsFromDirs(ctx Context, relDir string, dirs []string, targetNamePre
|
|||||||
func (c *configImpl) parseArgs(ctx Context, args []string) {
|
func (c *configImpl) parseArgs(ctx Context, args []string) {
|
||||||
for i := 0; i < len(args); i++ {
|
for i := 0; i < len(args); i++ {
|
||||||
arg := strings.TrimSpace(args[i])
|
arg := strings.TrimSpace(args[i])
|
||||||
if arg == "--make-mode" {
|
if arg == "showcommands" {
|
||||||
} else if arg == "showcommands" {
|
|
||||||
c.verbose = true
|
c.verbose = true
|
||||||
} else if arg == "--skip-ninja" {
|
} else if arg == "--skip-ninja" {
|
||||||
c.skipNinja = true
|
c.skipNinja = true
|
||||||
@@ -796,6 +795,10 @@ func (c *configImpl) SkipNinja() bool {
|
|||||||
return c.skipNinja
|
return c.skipNinja
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (c *configImpl) SetSkipNinja(v bool) {
|
||||||
|
c.skipNinja = v
|
||||||
|
}
|
||||||
|
|
||||||
func (c *configImpl) SkipConfig() bool {
|
func (c *configImpl) SkipConfig() bool {
|
||||||
return c.skipConfig
|
return c.skipConfig
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user