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

Unified Diff: tools/gn/ninja_build_writer.cc

Issue 232063002: GN: Don't write duplicate phony rules. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 8 months 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 a6cb773882ab8924e3f4d51e847521bb20aeb554..11b36e6b591e74a85753f2998aad2dcfe003dc36 100644
--- a/tools/gn/ninja_build_writer.cc
+++ b/tools/gn/ninja_build_writer.cc
@@ -5,6 +5,7 @@
#include "tools/gn/ninja_build_writer.h"
#include <fstream>
+#include <map>
#include "base/command_line.h"
#include "base/file_util.h"
@@ -176,13 +177,19 @@ void NinjaBuildWriter::WriteSubninjas() {
void NinjaBuildWriter::WritePhonyAndAllRules() {
std::string all_rules;
- // Write phony rules for the default toolchain (don't do other toolchains or
- // we'll get naming conflicts).
+ // Write phony rules for all uniquely-named targets in the default toolchain.
+ // Don't do other toolchains or we'll get naming conflicts, and if the name
+ // isn't unique, also skip it.
+ std::map<std::string, int> small_name_count;
+ for (size_t i = 0; i < default_toolchain_targets_.size(); i++)
+ small_name_count[default_toolchain_targets_[i]->label().name()]++;
+
for (size_t i = 0; i < default_toolchain_targets_.size(); i++) {
const Target* target = default_toolchain_targets_[i];
OutputFile target_file = helper_.GetTargetOutputFile(target);
- if (target_file.value() != target->label().name()) {
+ if (target_file.value() != target->label().name() &&
+ small_name_count[default_toolchain_targets_[i]->label().name()] == 1) {
out_ << "build " << target->label().name() << ": phony ";
path_output_.WriteFile(out_, target_file);
out_ << std::endl;
« 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