diff options
author | dpranke <dpranke@chromium.org> | 2015-04-24 17:29:36 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-04-25 00:29:44 +0000 |
commit | ab689a4f50c56521396eeab8deb9f8c6945d3c88 (patch) | |
tree | 7109671d715cc5a8a93834e7638872434c94dee8 /tools | |
parent | 4746695083b2ad5f38dae726f4f0ef16439264d9 (diff) | |
download | chromium_src-ab689a4f50c56521396eeab8deb9f8c6945d3c88.zip chromium_src-ab689a4f50c56521396eeab8deb9f8c6945d3c88.tar.gz chromium_src-ab689a4f50c56521396eeab8deb9f8c6945d3c88.tar.bz2 |
GN: Generate phony rules for unique executables.
Prior to this CL, if there were multiple targets ina GN build
with the name 'unit_tests', we would not generate a top-level
phony ninja target for them; you would have to specify either
the full path to the output or the label name.
This is confusing for things like 'browser_tests' and 'unit_tests',
where in Chromium we might have multiple targets with that name,
but only one of those is an executable (at least in the default
toolchain).
This CL adds logic to handle that case (so that 'unit_tests' does work).
R=brettw@chromium.org
BUG=480042
Review URL: https://codereview.chromium.org/1101323005
Cr-Commit-Position: refs/heads/master@{#326942}
Diffstat (limited to 'tools')
-rw-r--r-- | tools/gn/ninja_build_writer.cc | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/tools/gn/ninja_build_writer.cc b/tools/gn/ninja_build_writer.cc index 3ed0a62..248a45a 100644 --- a/tools/gn/ninja_build_writer.cc +++ b/tools/gn/ninja_build_writer.cc @@ -191,6 +191,7 @@ bool NinjaBuildWriter::WritePhonyAndAllRules(Err* err) { // isn't unique, also skip it. The exception is for the toplevel targets // which we also find. std::map<std::string, int> small_name_count; + std::map<std::string, int> exe_count; std::vector<const Target*> toplevel_targets; base::hash_set<std::string> target_files; for (const auto& target : default_toolchain_targets_) { @@ -208,6 +209,11 @@ bool NinjaBuildWriter::WritePhonyAndAllRules(Err* err) { dir_string[dir_string.size() - 1] == '/' && // "/" at end. dir_string.compare(2, label.name().size(), label.name()) == 0) toplevel_targets.push_back(target); + + // Look for executables; later we will generate phony rules for them + // even if there are non-executable targets with the same name. + if (target->output_type() == Target::EXECUTABLE) + exe_count[label.name()]++; } for (const auto& target : default_toolchain_targets_) { @@ -236,9 +242,13 @@ bool NinjaBuildWriter::WritePhonyAndAllRules(Err* err) { WritePhonyRule(target, target_file, medium_name); } - // Write short names for ones which are unique. - if (small_name_count[label.name()] == 1) + // Write short names for ones which are either completely unique or there + // at least only one of them in the default toolchain that is an exe. + if (small_name_count[label.name()] == 1 || + (target->output_type() == Target::EXECUTABLE && + exe_count[label.name()] == 1)) { WritePhonyRule(target, target_file, label.name()); + } if (!all_rules.empty()) all_rules.append(" $\n "); |