Skip to content

Commit

Permalink
Merge pull request #155 from danw/empty_ninja_file
Browse files Browse the repository at this point in the history
Add --empty_ninja_file for test usecases
  • Loading branch information
danw authored Oct 26, 2018
2 parents 4cc71ae + 87b8da7 commit 0d9ffea
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
2 changes: 2 additions & 0 deletions flags.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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")) {
Expand Down
1 change: 1 addition & 0 deletions flags.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
12 changes: 8 additions & 4 deletions ninja.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand All @@ -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_);
}
Expand Down

0 comments on commit 0d9ffea

Please sign in to comment.