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 file->GetName() == "vs_toolchain.py") | |
brettw
2017/03/29 23:05:07
I notice there are three such files:
//v8/gypfile
| |
63 return true; | 64 return true; |
64 } | 65 } |
65 return false; | 66 return false; |
66 } | 67 } |
67 | 68 |
68 TargetSet Intersect(const TargetSet& l, const TargetSet& r) { | 69 TargetSet Intersect(const TargetSet& l, const TargetSet& r) { |
69 TargetSet result; | 70 TargetSet result; |
70 std::set_intersection(l.begin(), l.end(), r.begin(), r.end(), | 71 std::set_intersection(l.begin(), l.end(), r.begin(), r.end(), |
71 std::inserter(result, result.begin())); | 72 std::inserter(result, result.begin())); |
72 return result; | 73 return result; |
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
255 for (const auto& label : InvalidLabels(inputs.test_labels)) | 256 for (const auto& label : InvalidLabels(inputs.test_labels)) |
256 invalid_labels.insert(label); | 257 invalid_labels.insert(label); |
257 if (!invalid_labels.empty()) { | 258 if (!invalid_labels.empty()) { |
258 outputs.error = "Invalid targets"; | 259 outputs.error = "Invalid targets"; |
259 outputs.invalid_labels = invalid_labels; | 260 outputs.invalid_labels = invalid_labels; |
260 return OutputsToJSON(outputs, default_toolchain_, err); | 261 return OutputsToJSON(outputs, default_toolchain_, err); |
261 } | 262 } |
262 | 263 |
263 // TODO(crbug.com/555273): We can do smarter things when we detect changes | 264 // 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, | 265 // 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 | 266 // 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, | 267 // files, we can treat a change as simply affecting every target, config, |
267 // or toolchain defined in that file. | 268 // or toolchain defined in that file. |
268 if (AnyBuildFilesWereModified(inputs.source_files)) { | 269 if (AnyBuildFilesWereModified(inputs.source_files)) { |
269 outputs.status = "Found dependency (all)"; | 270 outputs.status = "Found dependency (all)"; |
270 if (inputs.compile_included_all) { | 271 if (inputs.compile_included_all) { |
271 outputs.compile_includes_all = true; | 272 outputs.compile_includes_all = true; |
272 } else { | 273 } else { |
273 outputs.compile_labels.insert(inputs.compile_labels.begin(), | 274 outputs.compile_labels.insert(inputs.compile_labels.begin(), |
274 inputs.compile_labels.end()); | 275 inputs.compile_labels.end()); |
275 outputs.compile_labels.insert(inputs.test_labels.begin(), | 276 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 { | 404 void Analyzer::AddAllRefsTo(const Target* target, TargetSet* results) const { |
404 if (results->find(target) != results->end()) | 405 if (results->find(target) != results->end()) |
405 return; // Already found this target. | 406 return; // Already found this target. |
406 results->insert(target); | 407 results->insert(target); |
407 | 408 |
408 auto dep_begin = dep_map_.lower_bound(target); | 409 auto dep_begin = dep_map_.lower_bound(target); |
409 auto dep_end = dep_map_.upper_bound(target); | 410 auto dep_end = dep_map_.upper_bound(target); |
410 for (auto cur_dep = dep_begin; cur_dep != dep_end; cur_dep++) | 411 for (auto cur_dep = dep_begin; cur_dep != dep_end; cur_dep++) |
411 AddAllRefsTo(cur_dep->second, results); | 412 AddAllRefsTo(cur_dep->second, results); |
412 } | 413 } |
OLD | NEW |