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

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

Issue 1718093006: Limit the set of Visual Studio projects generated by GN (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix filter path correction Created 4 years, 10 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 | « no previous file | tools/gn/visual_studio_writer.h » ('j') | tools/gn/visual_studio_writer.cc » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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 "base/atomicops.h" 5 #include "base/atomicops.h"
6 #include "base/bind.h" 6 #include "base/bind.h"
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/strings/string_number_conversions.h" 8 #include "base/strings/string_number_conversions.h"
9 #include "base/strings/stringprintf.h" 9 #include "base/strings/stringprintf.h"
10 #include "base/timer/elapsed_timer.h" 10 #include "base/timer/elapsed_timer.h"
11 #include "tools/gn/build_settings.h" 11 #include "tools/gn/build_settings.h"
12 #include "tools/gn/commands.h" 12 #include "tools/gn/commands.h"
13 #include "tools/gn/eclipse_writer.h" 13 #include "tools/gn/eclipse_writer.h"
14 #include "tools/gn/ninja_target_writer.h" 14 #include "tools/gn/ninja_target_writer.h"
15 #include "tools/gn/ninja_writer.h" 15 #include "tools/gn/ninja_writer.h"
16 #include "tools/gn/runtime_deps.h" 16 #include "tools/gn/runtime_deps.h"
17 #include "tools/gn/scheduler.h" 17 #include "tools/gn/scheduler.h"
18 #include "tools/gn/setup.h" 18 #include "tools/gn/setup.h"
19 #include "tools/gn/standard_out.h" 19 #include "tools/gn/standard_out.h"
20 #include "tools/gn/switches.h" 20 #include "tools/gn/switches.h"
21 #include "tools/gn/target.h" 21 #include "tools/gn/target.h"
22 #include "tools/gn/visual_studio_writer.h" 22 #include "tools/gn/visual_studio_writer.h"
23 23
24 namespace commands { 24 namespace commands {
25 25
26 namespace { 26 namespace {
27 27
28 const char kSwitchCheck[] = "check"; 28 const char kSwitchCheck[] = "check";
29 const char kSwitchFilters[] = "filters";
29 const char kSwitchIde[] = "ide"; 30 const char kSwitchIde[] = "ide";
30 const char kSwitchIdeValueEclipse[] = "eclipse"; 31 const char kSwitchIdeValueEclipse[] = "eclipse";
31 const char kSwitchIdeValueVs[] = "vs"; 32 const char kSwitchIdeValueVs[] = "vs";
32 const char kSwitchIdeValueVs2013[] = "vs2013"; 33 const char kSwitchIdeValueVs2013[] = "vs2013";
33 const char kSwitchIdeValueVs2015[] = "vs2015"; 34 const char kSwitchIdeValueVs2015[] = "vs2015";
35 const char kSwitchSln[] = "sln";
34 36
35 // Called on worker thread to write the ninja file. 37 // Called on worker thread to write the ninja file.
36 void BackgroundDoWrite(const Target* target) { 38 void BackgroundDoWrite(const Target* target) {
37 NinjaTargetWriter::RunAndWriteFile(target); 39 NinjaTargetWriter::RunAndWriteFile(target);
38 g_scheduler->DecrementWorkCount(); 40 g_scheduler->DecrementWorkCount();
39 } 41 }
40 42
41 // Called on the main thread. 43 // Called on the main thread.
42 void ItemResolvedCallback(base::subtle::Atomic32* write_counter, 44 void ItemResolvedCallback(base::subtle::Atomic32* write_counter,
43 scoped_refptr<Builder> builder, 45 scoped_refptr<Builder> builder,
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
148 OutputString(base::StringPrintf("\n%d generated input errors found.\n", 150 OutputString(base::StringPrintf("\n%d generated input errors found.\n",
149 errors_found), DECORATION_YELLOW); 151 errors_found), DECORATION_YELLOW);
150 } 152 }
151 return false; 153 return false;
152 } 154 }
153 155
154 bool RunIdeWriter(const std::string& ide, 156 bool RunIdeWriter(const std::string& ide,
155 const BuildSettings* build_settings, 157 const BuildSettings* build_settings,
156 Builder* builder, 158 Builder* builder,
157 Err* err) { 159 Err* err) {
160 const base::CommandLine* command_line =
161 base::CommandLine::ForCurrentProcess();
158 base::ElapsedTimer timer; 162 base::ElapsedTimer timer;
163
159 if (ide == kSwitchIdeValueEclipse) { 164 if (ide == kSwitchIdeValueEclipse) {
160 bool res = EclipseWriter::RunAndWriteFile(build_settings, builder, err); 165 bool res = EclipseWriter::RunAndWriteFile(build_settings, builder, err);
161 if (res && 166 if (res && !command_line->HasSwitch(switches::kQuiet)) {
162 !base::CommandLine::ForCurrentProcess()->HasSwitch(switches::kQuiet)) {
163 OutputString("Generating Eclipse settings took " + 167 OutputString("Generating Eclipse settings took " +
164 base::Int64ToString(timer.Elapsed().InMilliseconds()) + 168 base::Int64ToString(timer.Elapsed().InMilliseconds()) +
165 "ms\n"); 169 "ms\n");
166 } 170 }
167 return res; 171 return res;
168 } else if (ide == kSwitchIdeValueVs || ide == kSwitchIdeValueVs2013 || 172 } else if (ide == kSwitchIdeValueVs || ide == kSwitchIdeValueVs2013 ||
169 ide == kSwitchIdeValueVs2015) { 173 ide == kSwitchIdeValueVs2015) {
170 VisualStudioWriter::Version version = 174 VisualStudioWriter::Version version =
171 ide == kSwitchIdeValueVs2013 ? VisualStudioWriter::Version::Vs2013 175 ide == kSwitchIdeValueVs2013 ? VisualStudioWriter::Version::Vs2013
172 : VisualStudioWriter::Version::Vs2015; 176 : VisualStudioWriter::Version::Vs2015;
173 bool res = VisualStudioWriter::RunAndWriteFiles(build_settings, builder, 177 std::string sln_name;
174 version, err); 178 if (command_line->HasSwitch(kSwitchSln))
175 if (res && 179 sln_name = command_line->GetSwitchValueASCII(kSwitchSln);
176 !base::CommandLine::ForCurrentProcess()->HasSwitch(switches::kQuiet)) { 180 std::string filters;
181 if (command_line->HasSwitch(kSwitchFilters))
182 filters = command_line->GetSwitchValueASCII(kSwitchFilters);
183 bool res = VisualStudioWriter::RunAndWriteFiles(
184 build_settings, builder, version, sln_name, filters, err);
185 if (res && !command_line->HasSwitch(switches::kQuiet)) {
177 OutputString("Generating Visual Studio projects took " + 186 OutputString("Generating Visual Studio projects took " +
178 base::Int64ToString(timer.Elapsed().InMilliseconds()) + 187 base::Int64ToString(timer.Elapsed().InMilliseconds()) +
179 "ms\n"); 188 "ms\n");
180 } 189 }
181 return res; 190 return res;
182 } 191 }
183 192
184 *err = Err(Location(), "Unknown IDE: " + ide); 193 *err = Err(Location(), "Unknown IDE: " + ide);
185 return false; 194 return false;
186 } 195 }
187 196
188 } // namespace 197 } // namespace
189 198
190 const char kGen[] = "gen"; 199 const char kGen[] = "gen";
191 const char kGen_HelpShort[] = 200 const char kGen_HelpShort[] =
192 "gen: Generate ninja files."; 201 "gen: Generate ninja files.";
193 const char kGen_Help[] = 202 const char kGen_Help[] =
194 "gn gen: Generate ninja files.\n" 203 "gn gen: Generate ninja files.\n"
195 "\n" 204 "\n"
196 " gn gen [--ide=<ide_name>] <out_dir>\n" 205 " gn gen [<ide options>] <out_dir>\n"
197 "\n" 206 "\n"
198 " Generates ninja files from the current tree and puts them in the given\n" 207 " Generates ninja files from the current tree and puts them in the given\n"
199 " output directory.\n" 208 " output directory.\n"
200 "\n" 209 "\n"
201 " The output directory can be a source-repo-absolute path name such as:\n" 210 " The output directory can be a source-repo-absolute path name such as:\n"
202 " //out/foo\n" 211 " //out/foo\n"
203 " Or it can be a directory relative to the current directory such as:\n" 212 " Or it can be a directory relative to the current directory such as:\n"
204 " out/foo\n" 213 " out/foo\n"
205 "\n" 214 "\n"
215 " See \"gn help switches\" for the common command-line switches.\n"
216 "\n"
217 "GN optionally generates files for IDEs. Possibilities for <ide options>\n"
brettw 2016/02/24 22:11:26 Can you do this instead: """ IDE options GN opt
Tomasz Moniuszko 2016/02/25 13:28:20 Done.
218 "\n"
206 " --ide=<ide_name>\n" 219 " --ide=<ide_name>\n"
207 " Also generate files for an IDE. Currently supported values:\n" 220 " Generate files for an IDE. Currently supported values:\n"
208 " \"eclipse\" - Eclipse CDT settings file.\n" 221 " \"eclipse\" - Eclipse CDT settings file.\n"
209 " \"vs\" - Visual Studio project/solution files.\n" 222 " \"vs\" - Visual Studio project/solution files.\n"
210 " (default Visual Studio version: 2015)\n" 223 " (default Visual Studio version: 2015)\n"
211 " \"vs2013\" - Visual Studio 2013 project/solution files.\n" 224 " \"vs2013\" - Visual Studio 2013 project/solution files.\n"
212 " \"vs2015\" - Visual Studio 2015 project/solution files.\n" 225 " \"vs2015\" - Visual Studio 2015 project/solution files.\n"
213 "\n" 226 "\n"
214 " See \"gn help switches\" for the common command-line switches.\n" 227 " --sln=<file_name>\n"
228 " Override default sln file name (\"all\"). Only for Visual Studio.\n"
brettw 2016/02/24 22:11:26 Can you explain where this file will be put (I ass
Tomasz Moniuszko 2016/02/25 13:28:20 Yes, exactly (I added this information to the help
229 "\n"
230 " --filters=<path_prefixes>\n"
231 " Semicolon-separated list of path prefixes used to limit the set of\n"
brettw 2016/02/24 22:11:26 Assuming we do the label pattern thing I suggested
Tomasz Moniuszko 2016/02/25 13:28:20 Done.
232 " generated projects. Each prefix may be source-absolute\n"
233 " (e.g. \"//base\") or system-absolute (e.g. \"/C:/foo/bar\"). Only\n"
234 " targets whose directory paths start with one of specified prefixes\n"
235 " will be included to the solution. Only for Visual Studio.\n"
236 " Example: --filters=\"//base;//tools/gn\"\n"
215 "\n" 237 "\n"
216 "Eclipse IDE Support\n" 238 "Eclipse IDE Support\n"
217 "\n" 239 "\n"
218 " GN DOES NOT generate Eclipse CDT projects. Instead, it generates a\n" 240 " GN DOES NOT generate Eclipse CDT projects. Instead, it generates a\n"
219 " settings file which can be imported into an Eclipse CDT project. The\n" 241 " settings file which can be imported into an Eclipse CDT project. The\n"
220 " XML file contains a list of include paths and defines. Because GN does\n" 242 " XML file contains a list of include paths and defines. Because GN does\n"
221 " not generate a full .cproject definition, it is not possible to\n" 243 " not generate a full .cproject definition, it is not possible to\n"
222 " properly define includes/defines for each file individually.\n" 244 " properly define includes/defines for each file individually.\n"
223 " Instead, one set of includes/defines is generated for the entire\n" 245 " Instead, one set of includes/defines is generated for the entire\n"
224 " project. This works fairly well but may still result in a few indexer\n" 246 " project. This works fairly well but may still result in a few indexer\n"
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
291 setup->scheduler().input_file_manager()->GetInputFileCount()) + 313 setup->scheduler().input_file_manager()->GetInputFileCount()) +
292 " files in " + 314 " files in " +
293 base::Int64ToString(elapsed_time.InMilliseconds()) + "ms\n"; 315 base::Int64ToString(elapsed_time.InMilliseconds()) + "ms\n";
294 OutputString(stats); 316 OutputString(stats);
295 } 317 }
296 318
297 return 0; 319 return 0;
298 } 320 }
299 321
300 } // namespace commands 322 } // namespace commands
OLDNEW
« no previous file with comments | « no previous file | tools/gn/visual_studio_writer.h » ('j') | tools/gn/visual_studio_writer.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698