OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "tools/gn/analyzer.h" | 5 #include "tools/gn/analyzer.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <iterator> | 8 #include <iterator> |
9 #include <set> | 9 #include <set> |
10 #include <vector> | 10 #include <vector> |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
52 LabelSet LabelsFor(const TargetSet& targets) { | 52 LabelSet LabelsFor(const TargetSet& targets) { |
53 LabelSet labels; | 53 LabelSet labels; |
54 for (auto* target : targets) | 54 for (auto* target : targets) |
55 labels.insert(target->label()); | 55 labels.insert(target->label()); |
56 return labels; | 56 return labels; |
57 } | 57 } |
58 | 58 |
59 bool AnyBuildFilesWereModified(const SourceFileSet& source_files) { | 59 bool AnyBuildFilesWereModified(const SourceFileSet& source_files) { |
60 for (auto* file : source_files) { | 60 for (auto* file : source_files) { |
61 if (base::EndsWith(file->value(), ".gn", base::CompareCase::SENSITIVE) || | 61 if (base::EndsWith(file->value(), ".gn", base::CompareCase::SENSITIVE) || |
62 base::EndsWith(file->value(), ".gni", base::CompareCase::SENSITIVE)) | 62 base::EndsWith(file->value(), ".gni", base::CompareCase::SENSITIVE) || |
| 63 base::EndsWith(file->value(), "build/vs_toolchain.py", |
| 64 base::CompareCase::SENSITIVE)) |
63 return true; | 65 return true; |
64 } | 66 } |
65 return false; | 67 return false; |
66 } | 68 } |
67 | 69 |
68 TargetSet Intersect(const TargetSet& l, const TargetSet& r) { | 70 TargetSet Intersect(const TargetSet& l, const TargetSet& r) { |
69 TargetSet result; | 71 TargetSet result; |
70 std::set_intersection(l.begin(), l.end(), r.begin(), r.end(), | 72 std::set_intersection(l.begin(), l.end(), r.begin(), r.end(), |
71 std::inserter(result, result.begin())); | 73 std::inserter(result, result.begin())); |
72 return result; | 74 return result; |
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
255 for (const auto& label : InvalidLabels(inputs.test_labels)) | 257 for (const auto& label : InvalidLabels(inputs.test_labels)) |
256 invalid_labels.insert(label); | 258 invalid_labels.insert(label); |
257 if (!invalid_labels.empty()) { | 259 if (!invalid_labels.empty()) { |
258 outputs.error = "Invalid targets"; | 260 outputs.error = "Invalid targets"; |
259 outputs.invalid_labels = invalid_labels; | 261 outputs.invalid_labels = invalid_labels; |
260 return OutputsToJSON(outputs, default_toolchain_, err); | 262 return OutputsToJSON(outputs, default_toolchain_, err); |
261 } | 263 } |
262 | 264 |
263 // TODO(crbug.com/555273): We can do smarter things when we detect changes | 265 // TODO(crbug.com/555273): We can do smarter things when we detect changes |
264 // to build files. For example, if all of the ninja files are unchanged, | 266 // to build files. For example, if all of the ninja files are unchanged, |
265 // we know that we can ignore changes to these files. Also, for most .gn | 267 // we know that we can ignore changes to .gn* files. Also, for most .gn |
266 // files, we can treat a change as simply affecting every target, config, | 268 // files, we can treat a change as simply affecting every target, config, |
267 // or toolchain defined in that file. | 269 // or toolchain defined in that file. |
268 if (AnyBuildFilesWereModified(inputs.source_files)) { | 270 if (AnyBuildFilesWereModified(inputs.source_files)) { |
269 outputs.status = "Found dependency (all)"; | 271 outputs.status = "Found dependency (all)"; |
270 if (inputs.compile_included_all) { | 272 if (inputs.compile_included_all) { |
271 outputs.compile_includes_all = true; | 273 outputs.compile_includes_all = true; |
272 } else { | 274 } else { |
273 outputs.compile_labels.insert(inputs.compile_labels.begin(), | 275 outputs.compile_labels.insert(inputs.compile_labels.begin(), |
274 inputs.compile_labels.end()); | 276 inputs.compile_labels.end()); |
275 outputs.compile_labels.insert(inputs.test_labels.begin(), | 277 outputs.compile_labels.insert(inputs.test_labels.begin(), |
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
403 void Analyzer::AddAllRefsTo(const Target* target, TargetSet* results) const { | 405 void Analyzer::AddAllRefsTo(const Target* target, TargetSet* results) const { |
404 if (results->find(target) != results->end()) | 406 if (results->find(target) != results->end()) |
405 return; // Already found this target. | 407 return; // Already found this target. |
406 results->insert(target); | 408 results->insert(target); |
407 | 409 |
408 auto dep_begin = dep_map_.lower_bound(target); | 410 auto dep_begin = dep_map_.lower_bound(target); |
409 auto dep_end = dep_map_.upper_bound(target); | 411 auto dep_end = dep_map_.upper_bound(target); |
410 for (auto cur_dep = dep_begin; cur_dep != dep_end; cur_dep++) | 412 for (auto cur_dep = dep_begin; cur_dep != dep_end; cur_dep++) |
411 AddAllRefsTo(cur_dep->second, results); | 413 AddAllRefsTo(cur_dep->second, results); |
412 } | 414 } |
OLD | NEW |