Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(331)

Unified Diff: tools/gn/ninja_build_writer.cc

Issue 784413004: Add support for a 'default' target to GN. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/gn/ninja_build_writer.cc
diff --git a/tools/gn/ninja_build_writer.cc b/tools/gn/ninja_build_writer.cc
index 94a9f3d7878aa94f8a9ff020ff73444f31509b42..9a5e2d68ac45bb0be98b9b286a4e1a7d0a607b9a 100644
--- a/tools/gn/ninja_build_writer.cc
+++ b/tools/gn/ninja_build_writer.cc
@@ -256,10 +256,26 @@ bool NinjaBuildWriter::WritePhonyAndAllRules(Err* err) {
}
}
+ // Figure out if the BUILD file wants to declare a custom "default"
+ // target (rather than building 'all' by default). By convention
+ // we use group("default") but it doesn't have to be a group.
+ bool default_target_exists = false;
+ for (size_t i = 0; i < default_toolchain_targets_.size(); i++) {
+ const Label& label = default_toolchain_targets_[i]->label();
+ if (label.dir().value() == "//" && label.name() == "default")
+ default_target_exists = true;
+ }
+
if (!all_rules.empty()) {
out_ << "\nbuild all: phony " << all_rules << std::endl;
+ }
+
+ if (default_target_exists) {
+ out_ << "default default" << std::endl;
+ } else if (!all_rules.empty()) {
out_ << "default all" << std::endl;
}
+
return true;
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698