Add --skip-make to replace Soong's blueprint wrapper with soong_ui
This way we only have one way to start a build, which always has logging
/ tracing / etc, even if we don't need Kati.
There's two ways to use this:
As a direct replacement for mkdir out; cd out; ../bootstrap.bash;
./soong -- as long as --skip-make is always passed, we'll never run
Kati, and Soong will run outside of it's "make" mode. This preserves
most of the speed, and allows full user control over the Soong
configuration.
A (experimental, dangerous) way to temporarily bypass the product
variable and kati steps of a build. As long as a user is sure that
nothing has changed from the last build, and they know exactly which
Ninja targets they want to build (which may not be the same as the
arguments normally passed to 'm'), this can lead to shorter build
startup times.
Test: rm -rf out; m --skip-make libc
Test: rm -rf out; m libc; m --skip-make libc
Test: rm -rf out; mkdir out; cd out; ../bootstrap.bash; ./soong libc
Test: build/soong/scripts/build-ndk-prebuilts.sh
Change-Id: Ic0f91167b5779dba3f248a379fbaac67a75a946e
diff --git a/ui/build/build.go b/ui/build/build.go
index 32f4ba5..f7c305c 100644
--- a/ui/build/build.go
+++ b/ui/build/build.go
@@ -26,7 +26,9 @@
func SetupOutDir(ctx Context, config Config) {
ensureEmptyFileExists(ctx, filepath.Join(config.OutDir(), "Android.mk"))
ensureEmptyFileExists(ctx, filepath.Join(config.OutDir(), "CleanSpec.mk"))
- ensureEmptyFileExists(ctx, filepath.Join(config.SoongOutDir(), ".soong.in_make"))
+ if !config.SkipMake() {
+ ensureEmptyFileExists(ctx, filepath.Join(config.SoongOutDir(), ".soong.in_make"))
+ }
// The ninja_build file is used by our buildbots to understand that the output
// can be parsed as ninja output.
ensureEmptyFileExists(ctx, filepath.Join(config.OutDir(), "ninja_build"))
@@ -34,12 +36,20 @@
var combinedBuildNinjaTemplate = template.Must(template.New("combined").Parse(`
builddir = {{.OutDir}}
-include {{.KatiNinjaFile}}
+{{if .HasKatiSuffix}}include {{.KatiNinjaFile}}
+{{end -}}
include {{.SoongNinjaFile}}
build {{.CombinedNinjaFile}}: phony {{.SoongNinjaFile}}
`))
func createCombinedBuildNinjaFile(ctx Context, config Config) {
+ // If we're in SkipMake mode, skip creating this file if it already exists
+ if config.SkipMake() {
+ if _, err := os.Stat(config.CombinedNinjaFile()); err == nil || !os.IsNotExist(err) {
+ return
+ }
+ }
+
file, err := os.Create(config.CombinedNinjaFile())
if err != nil {
ctx.Fatalln("Failed to create combined ninja file:", err)
@@ -106,6 +116,11 @@
ctx.Verboseln("Starting build with args:", config.Arguments())
ctx.Verboseln("Environment:", config.Environment().Environ())
+ if config.SkipMake() {
+ ctx.Verboseln("Skipping Make/Kati as requested")
+ what = what & (BuildSoong | BuildNinja)
+ }
+
if inList("help", config.Arguments()) {
help(ctx, config, what)
return
@@ -148,10 +163,20 @@
if what&BuildKati != 0 {
// Run ckati
runKati(ctx, config)
+
+ ioutil.WriteFile(config.LastKatiSuffixFile(), []byte(config.KatiSuffix()), 0777)
+ } else {
+ // Load last Kati Suffix if it exists
+ if katiSuffix, err := ioutil.ReadFile(config.LastKatiSuffixFile()); err == nil {
+ ctx.Verboseln("Loaded previous kati config:", string(katiSuffix))
+ config.SetKatiSuffix(string(katiSuffix))
+ }
}
if what&BuildNinja != 0 {
- installCleanIfNecessary(ctx, config)
+ if !config.SkipMake() {
+ installCleanIfNecessary(ctx, config)
+ }
// Write combined ninja file
createCombinedBuildNinjaFile(ctx, config)