aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDan Willemsen <dwillemsen@google.com>2018-10-26 09:21:23 -0700
committerDan Willemsen <dwillemsen@google.com>2018-10-26 09:27:37 -0700
commit87b8da7af2c8bea28b1d8ab17679453d859f96e5 (patch)
tree0c4a7b7081a2b351e5dc17a6cbc3a00433eee3b7
parent4cc71ae464e38364f9f8abf3d2b79f1211c3b3ca (diff)
downloadplatform_build_kati-87b8da7af2c8bea28b1d8ab17679453d859f96e5.tar.gz
platform_build_kati-87b8da7af2c8bea28b1d8ab17679453d859f96e5.tar.bz2
platform_build_kati-87b8da7af2c8bea28b1d8ab17679453d859f96e5.zip
Add --empty_ninja_file for test usecases
In cases that we want to run Kati in many configurations to verify all of the generation logic works without errors, but don't care about running the final ninja file, writing it out only wastes time. So add a --empty_ninja_file option that skips writing out build rules and defaults information, leading to a very small ninja file. Our specific use case (Soong's build_test / multiproduct_kati) runs Kati several hundred times for different configurations, and the ninja files are around 750MB. Even when we truncate them immediately after writing, that still leads to hundreds of gigabytes of writes to disk. Change-Id: Ie4e7800ccfaeb653e89ed5d5ea3010b0c8ff314a
-rw-r--r--flags.cc2
-rw-r--r--flags.h1
-rw-r--r--ninja.cc12
3 files changed, 11 insertions, 4 deletions
diff --git a/flags.cc b/flags.cc
index 07b5748..54828e5 100644
--- a/flags.cc
+++ b/flags.cc
@@ -82,6 +82,8 @@ void Flags::Parse(int argc, char** argv) {
enable_kati_warnings = true;
} else if (!strcmp(arg, "--ninja")) {
generate_ninja = true;
+ } else if (!strcmp(arg, "--empty_ninja_file")) {
+ generate_empty_ninja = true;
} else if (!strcmp(arg, "--gen_all_targets")) {
gen_all_targets = true;
} else if (!strcmp(arg, "--regen")) {
diff --git a/flags.h b/flags.h
index 025979a..62865a3 100644
--- a/flags.h
+++ b/flags.h
@@ -32,6 +32,7 @@ struct Flags {
bool enable_stat_logs;
bool gen_all_targets;
bool generate_ninja;
+ bool generate_empty_ninja;
bool is_dry_run;
bool is_silent_mode;
bool is_syntax_check_only;
diff --git a/ninja.cc b/ninja.cc
index 0b87d5c..90e56c8 100644
--- a/ninja.cc
+++ b/ninja.cc
@@ -629,8 +629,10 @@ class NinjaGenerator {
}
tp->Wait();
- for (const ostringstream& buf : bufs) {
- fprintf(fp_, "%s", buf.str().c_str());
+ if (!g_flags.generate_empty_ninja) {
+ for (const ostringstream& buf : bufs) {
+ fprintf(fp_, "%s", buf.str().c_str());
+ }
}
SymbolSet used_env_vars(Vars::used_env_vars());
@@ -652,8 +654,10 @@ class NinjaGenerator {
default_targets += EscapeBuildTarget(s);
}
}
- fprintf(fp_, "\n");
- fprintf(fp_, "default %s\n", default_targets.c_str());
+ if (!g_flags.generate_empty_ninja) {
+ fprintf(fp_, "\n");
+ fprintf(fp_, "default %s\n", default_targets.c_str());
+ }
fclose(fp_);
}