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 <algorithm> | 5 #include <algorithm> |
6 #include <set> | 6 #include <set> |
7 | 7 |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "tools/gn/commands.h" | 9 #include "tools/gn/commands.h" |
10 #include "tools/gn/label_pattern.h" | 10 #include "tools/gn/label_pattern.h" |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
78 if (args.size() == 2) { | 78 if (args.size() == 2) { |
79 // Given a pattern, match it. | 79 // Given a pattern, match it. |
80 if (!ResolveTargetsFromCommandLinePattern(setup, args[1], all_toolchains, | 80 if (!ResolveTargetsFromCommandLinePattern(setup, args[1], all_toolchains, |
81 &matches)) | 81 &matches)) |
82 return 1; | 82 return 1; |
83 } else if (all_toolchains) { | 83 } else if (all_toolchains) { |
84 // List all resolved targets. | 84 // List all resolved targets. |
85 matches = setup->builder()->GetAllResolvedTargets(); | 85 matches = setup->builder()->GetAllResolvedTargets(); |
86 } else { | 86 } else { |
87 // List all resolved targets in the default toolchain. | 87 // List all resolved targets in the default toolchain. |
88 std::vector<const Target*> all_targets = | 88 for (const auto& target : setup->builder()->GetAllResolvedTargets()) { |
89 setup->builder()->GetAllResolvedTargets(); | 89 if (target->settings()->is_default()) |
90 for (size_t i = 0; i < all_targets.size(); i++) { | 90 matches.push_back(target); |
91 if (all_targets[i]->settings()->is_default()) | |
92 matches.push_back(all_targets[i]); | |
93 } | 91 } |
94 } | 92 } |
95 | 93 |
96 if (cmdline->HasSwitch("out")) { | 94 if (cmdline->HasSwitch("out")) { |
97 // List results as build files. | 95 // List results as build files. |
98 for (size_t i = 0; i < matches.size(); i++) { | 96 for (const auto& match : matches) { |
99 OutputString(matches[i]->dependency_output_file().value()); | 97 OutputString(match->dependency_output_file().value()); |
100 OutputString("\n"); | 98 OutputString("\n"); |
101 } | 99 } |
102 } else { | 100 } else { |
103 // List results as sorted labels. | 101 // List results as sorted labels. |
104 std::vector<Label> sorted_matches; | 102 std::vector<Label> sorted_matches; |
105 for (size_t i = 0; i < matches.size(); i++) | 103 for (const auto& match : matches) |
106 sorted_matches.push_back(matches[i]->label()); | 104 sorted_matches.push_back(match->label()); |
107 std::sort(sorted_matches.begin(), sorted_matches.end()); | 105 std::sort(sorted_matches.begin(), sorted_matches.end()); |
108 | 106 |
109 Label default_tc_label = setup->loader()->default_toolchain_label(); | 107 Label default_tc_label = setup->loader()->default_toolchain_label(); |
110 for (size_t i = 0; i < sorted_matches.size(); i++) { | 108 for (const auto& match : sorted_matches) { |
111 // Print toolchain only for ones not in the default toolchain. | 109 // Print toolchain only for ones not in the default toolchain. |
112 OutputString(sorted_matches[i].GetUserVisibleName( | 110 OutputString(match.GetUserVisibleName( |
113 sorted_matches[i].GetToolchainLabel() != default_tc_label)); | 111 match.GetToolchainLabel() != default_tc_label)); |
114 OutputString("\n"); | 112 OutputString("\n"); |
115 } | 113 } |
116 } | 114 } |
117 | 115 |
118 return 0; | 116 return 0; |
119 } | 117 } |
120 | 118 |
121 } // namespace commands | 119 } // namespace commands |
OLD | NEW |