OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "base/atomicops.h" | 5 #include "base/atomicops.h" |
6 #include "base/bind.h" | 6 #include "base/bind.h" |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/strings/string_number_conversions.h" | 8 #include "base/strings/string_number_conversions.h" |
9 #include "base/strings/stringprintf.h" | 9 #include "base/strings/stringprintf.h" |
10 #include "base/timer/elapsed_timer.h" | 10 #include "base/timer/elapsed_timer.h" |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
64 return nullptr; | 64 return nullptr; |
65 } | 65 } |
66 | 66 |
67 // Prints an error that the given file was present as a source or input in | 67 // Prints an error that the given file was present as a source or input in |
68 // the given target(s) but was not generated by any of its dependencies. | 68 // the given target(s) but was not generated by any of its dependencies. |
69 void PrintInvalidGeneratedInput(const Builder* builder, | 69 void PrintInvalidGeneratedInput(const Builder* builder, |
70 const SourceFile& file, | 70 const SourceFile& file, |
71 const std::vector<const Target*>& targets) { | 71 const std::vector<const Target*>& targets) { |
72 std::string err; | 72 std::string err; |
73 | 73 |
| 74 // Only show the toolchain labels (which can be confusing) if something |
| 75 // isn't the default. |
| 76 bool show_toolchains = false; |
| 77 const Label& default_toolchain = |
| 78 targets[0]->settings()->default_toolchain_label(); |
| 79 for (const Target* target : targets) { |
| 80 if (target->settings()->toolchain_label() != default_toolchain) { |
| 81 show_toolchains = true; |
| 82 break; |
| 83 } |
| 84 } |
| 85 |
| 86 const Target* generator = FindTargetThatGeneratesFile(builder, file); |
| 87 if (generator && |
| 88 generator->settings()->toolchain_label() != default_toolchain) |
| 89 show_toolchains = true; |
| 90 |
74 const std::string target_str = targets.size() > 1 ? "targets" : "target"; | 91 const std::string target_str = targets.size() > 1 ? "targets" : "target"; |
75 err += "The file:\n"; | 92 err += "The file:\n"; |
76 err += " " + file.value() + "\n"; | 93 err += " " + file.value() + "\n"; |
77 err += "is listed as an input or source for the " + target_str + ":\n"; | 94 err += "is listed as an input or source for the " + target_str + ":\n"; |
78 for (const Target* target : targets) | 95 for (const Target* target : targets) |
79 err += " " + target->label().GetUserVisibleName(false) + "\n"; | 96 err += " " + target->label().GetUserVisibleName(show_toolchains) + "\n"; |
80 | 97 |
81 const Target* generator = FindTargetThatGeneratesFile(builder, file); | |
82 if (generator) { | 98 if (generator) { |
83 err += "but this file was not generated by any dependencies of the " + | 99 err += "but this file was not generated by any dependencies of the " + |
84 target_str + ". The target\nthat generates the file is:\n "; | 100 target_str + ". The target\nthat generates the file is:\n "; |
85 err += generator->label().GetUserVisibleName(false); | 101 err += generator->label().GetUserVisibleName(show_toolchains); |
86 } else { | 102 } else { |
87 err += "but no targets in the build generate that file."; | 103 err += "but no targets in the build generate that file."; |
88 } | 104 } |
89 | 105 |
90 Err(Location(), "Input to " + target_str + " not generated by a dependency.", | 106 Err(Location(), "Input to " + target_str + " not generated by a dependency.", |
91 err).PrintToStdout(); | 107 err).PrintToStdout(); |
92 } | 108 } |
93 | 109 |
94 bool CheckForInvalidGeneratedInputs(Setup* setup) { | 110 bool CheckForInvalidGeneratedInputs(Setup* setup) { |
95 std::multimap<SourceFile, const Target*> unknown_inputs = | 111 std::multimap<SourceFile, const Target*> unknown_inputs = |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
206 setup->scheduler().input_file_manager()->GetInputFileCount()) + | 222 setup->scheduler().input_file_manager()->GetInputFileCount()) + |
207 " files in " + | 223 " files in " + |
208 base::Int64ToString(elapsed_time.InMilliseconds()) + "ms\n"; | 224 base::Int64ToString(elapsed_time.InMilliseconds()) + "ms\n"; |
209 OutputString(stats); | 225 OutputString(stats); |
210 } | 226 } |
211 | 227 |
212 return 0; | 228 return 0; |
213 } | 229 } |
214 | 230 |
215 } // namespace commands | 231 } // namespace commands |
OLD | NEW |