OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/header_checker.h" | 5 #include "tools/gn/header_checker.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/file_util.h" | 10 #include "base/file_util.h" |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
57 !values.cflags_cc().empty() || | 57 !values.cflags_cc().empty() || |
58 !values.cflags_objc().empty() || | 58 !values.cflags_objc().empty() || |
59 !values.cflags_objcc().empty() || | 59 !values.cflags_objcc().empty() || |
60 !values.defines().empty() || | 60 !values.defines().empty() || |
61 !values.include_dirs().empty(); | 61 !values.include_dirs().empty(); |
62 } | 62 } |
63 | 63 |
64 // Returns true if the given target has any direct dependent configs with | 64 // Returns true if the given target has any direct dependent configs with |
65 // compiler settings in it. | 65 // compiler settings in it. |
66 bool HasDirectDependentCompilerSettings(const Target* target) { | 66 bool HasDirectDependentCompilerSettings(const Target* target) { |
67 const LabelConfigVector& direct = target->direct_dependent_configs(); | 67 const UniqueVector<LabelConfigPair>& direct = |
| 68 target->direct_dependent_configs(); |
68 for (size_t i = 0; i < direct.size(); i++) { | 69 for (size_t i = 0; i < direct.size(); i++) { |
69 if (ConfigHasCompilerSettings(direct[i].ptr)) | 70 if (ConfigHasCompilerSettings(direct[i].ptr)) |
70 return true; | 71 return true; |
71 } | 72 } |
72 return false; | 73 return false; |
73 } | 74 } |
74 | 75 |
75 // Given a reverse dependency chain where the target chain[0]'s dependent | 76 // Given a reverse dependency chain where the target chain[0]'s dependent |
76 // configs don't apply to chain[end], returns the string describing the error. | 77 // configs don't apply to chain[end], returns the string describing the error. |
77 // The problematic index is the target where the dependent configs were lost. | 78 // The problematic index is the target where the dependent configs were lost. |
(...skipping 346 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
424 return true; | 425 return true; |
425 | 426 |
426 // Check the middle configs to make sure they're either groups or configs | 427 // Check the middle configs to make sure they're either groups or configs |
427 // are forwarded. | 428 // are forwarded. |
428 for (size_t i = 1; i < chain.size() - 1; i++) { | 429 for (size_t i = 1; i < chain.size() - 1; i++) { |
429 if (chain[i]->output_type() == Target::GROUP) | 430 if (chain[i]->output_type() == Target::GROUP) |
430 continue; // This one is OK, skip to next one. | 431 continue; // This one is OK, skip to next one. |
431 | 432 |
432 // The forward list on this target should have contained in it the target | 433 // The forward list on this target should have contained in it the target |
433 // at the next lower level. | 434 // at the next lower level. |
434 const LabelTargetVector& forwarded = chain[i]->forward_dependent_configs(); | 435 const UniqueVector<LabelTargetPair>& forwarded = |
| 436 chain[i]->forward_dependent_configs(); |
435 if (std::find_if(forwarded.begin(), forwarded.end(), | 437 if (std::find_if(forwarded.begin(), forwarded.end(), |
436 LabelPtrPtrEquals<Target>(chain[i - 1])) == | 438 LabelPtrPtrEquals<Target>(chain[i - 1])) == |
437 forwarded.end()) { | 439 forwarded.end()) { |
438 *problematic_index = i; | 440 *problematic_index = i; |
439 return false; | 441 return false; |
440 } | 442 } |
441 } | 443 } |
442 | 444 |
443 return true; | 445 return true; |
444 } | 446 } |
OLD | NEW |