Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(18)

Side by Side Diff: tools/gn/visual_studio_writer.cc

Issue 2200123002: Add option to not generate VS projects for targets deps (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « tools/gn/visual_studio_writer.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/visual_studio_writer.h" 5 #include "tools/gn/visual_studio_writer.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <iterator> 8 #include <iterator>
9 #include <map> 9 #include <map>
10 #include <memory> 10 #include <memory>
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
160 DCHECK(path && !path->empty()); 160 DCHECK(path && !path->empty());
161 for (int i = static_cast<int>(path->size()) - 2; i >= 0; --i) { 161 for (int i = static_cast<int>(path->size()) - 2; i >= 0; --i) {
162 if (IsSlash((*path)[i])) 162 if (IsSlash((*path)[i]))
163 return base::StringPiece(path->data(), i); 163 return base::StringPiece(path->data(), i);
164 } 164 }
165 return base::StringPiece(); 165 return base::StringPiece();
166 } 166 }
167 167
168 bool FilterTargets(const BuildSettings* build_settings, 168 bool FilterTargets(const BuildSettings* build_settings,
169 const Builder& builder, 169 const Builder& builder,
170 const std::string& dir_filters, 170 const std::string& filters,
171 bool no_deps,
171 std::vector<const Target*>* targets, 172 std::vector<const Target*>* targets,
172 Err* err) { 173 Err* err) {
173 if (dir_filters.empty()) { 174 if (filters.empty()) {
174 *targets = builder.GetAllResolvedTargets(); 175 *targets = builder.GetAllResolvedTargets();
175 return true; 176 return true;
176 } 177 }
177 178
178 std::vector<LabelPattern> filters; 179 std::vector<LabelPattern> patterns;
179 if (!commands::FilterPatternsFromString(build_settings, dir_filters, &filters, 180 if (!commands::FilterPatternsFromString(build_settings, filters, &patterns,
180 err)) 181 err))
181 return false; 182 return false;
182 183
183 commands::FilterTargetsByPatterns(builder.GetAllResolvedTargets(), filters, 184 commands::FilterTargetsByPatterns(builder.GetAllResolvedTargets(), patterns,
184 targets); 185 targets);
185 186
187 if (no_deps)
188 return true;
189
186 std::set<Label> labels; 190 std::set<Label> labels;
187 std::queue<const Target*> to_process; 191 std::queue<const Target*> to_process;
188 for (const Target* target : *targets) { 192 for (const Target* target : *targets) {
189 labels.insert(target->label()); 193 labels.insert(target->label());
190 to_process.push(target); 194 to_process.push(target);
191 } 195 }
192 196
193 while (!to_process.empty()) { 197 while (!to_process.empty()) {
194 const Target* target = to_process.front(); 198 const Target* target = to_process.front();
195 to_process.pop(); 199 to_process.pop();
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
265 } 269 }
266 270
267 VisualStudioWriter::~VisualStudioWriter() { 271 VisualStudioWriter::~VisualStudioWriter() {
268 } 272 }
269 273
270 // static 274 // static
271 bool VisualStudioWriter::RunAndWriteFiles(const BuildSettings* build_settings, 275 bool VisualStudioWriter::RunAndWriteFiles(const BuildSettings* build_settings,
272 const Builder& builder, 276 const Builder& builder,
273 Version version, 277 Version version,
274 const std::string& sln_name, 278 const std::string& sln_name,
275 const std::string& dir_filters, 279 const std::string& filters,
280 bool no_deps,
276 Err* err) { 281 Err* err) {
277 std::vector<const Target*> targets; 282 std::vector<const Target*> targets;
278 if (!FilterTargets(build_settings, builder, dir_filters, &targets, err)) 283 if (!FilterTargets(build_settings, builder, filters, no_deps, &targets, err))
279 return false; 284 return false;
280 285
281 const char* config_platform = "Win32"; 286 const char* config_platform = "Win32";
282 287
283 // Assume the "target_cpu" variable does not change between different 288 // Assume the "target_cpu" variable does not change between different
284 // toolchains. 289 // toolchains.
285 if (!targets.empty()) { 290 if (!targets.empty()) {
286 const Scope* scope = targets.front()->settings()->base_config(); 291 const Scope* scope = targets.front()->settings()->base_config();
287 const Value* target_cpu_value = scope->GetValue(variables::kTargetCpu); 292 const Value* target_cpu_value = scope->GetValue(variables::kTargetCpu);
288 if (target_cpu_value != nullptr && 293 if (target_cpu_value != nullptr &&
(...skipping 543 matching lines...) Expand 10 before | Expand all | Expand 10 after
832 } 837 }
833 } 838 }
834 839
835 std::string VisualStudioWriter::GetNinjaTarget(const Target* target) { 840 std::string VisualStudioWriter::GetNinjaTarget(const Target* target) {
836 std::ostringstream ninja_target_out; 841 std::ostringstream ninja_target_out;
837 DCHECK(!target->dependency_output_file().value().empty()); 842 DCHECK(!target->dependency_output_file().value().empty());
838 ninja_path_output_.WriteFile(ninja_target_out, 843 ninja_path_output_.WriteFile(ninja_target_out,
839 target->dependency_output_file()); 844 target->dependency_output_file());
840 return ninja_target_out.str(); 845 return ninja_target_out.str();
841 } 846 }
OLDNEW
« no previous file with comments | « tools/gn/visual_studio_writer.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698