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

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

Issue 895433002: gn: Use the term 'out_dir' consistently when referring to the output directory. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: build_dir Created 5 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/command_gen.cc » ('j') | no next file with comments »
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 <stdio.h> 5 #include <stdio.h>
6 #include <stdlib.h> 6 #include <stdlib.h>
7 7
8 #include <map> 8 #include <map>
9 9
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after
238 // Windows they can come out as forward slashes here, and that confuses some 238 // Windows they can come out as forward slashes here, and that confuses some
239 // of the commands. 239 // of the commands.
240 base::FilePath arg_file = 240 base::FilePath arg_file =
241 setup.build_settings().GetFullPath(setup.GetBuildArgFile()) 241 setup.build_settings().GetFullPath(setup.GetBuildArgFile())
242 .NormalizePathSeparators(); 242 .NormalizePathSeparators();
243 if (!base::PathExists(arg_file)) { 243 if (!base::PathExists(arg_file)) {
244 std::string argfile_default_contents = 244 std::string argfile_default_contents =
245 "# Build arguments go here. Examples:\n" 245 "# Build arguments go here. Examples:\n"
246 "# is_component_build = true\n" 246 "# is_component_build = true\n"
247 "# is_debug = false\n" 247 "# is_debug = false\n"
248 "# See \"gn args <dir_name> --list\" for available build " 248 "# See \"gn args <out_dir> --list\" for available build "
249 "arguments.\n"; 249 "arguments.\n";
250 #if defined(OS_WIN) 250 #if defined(OS_WIN)
251 // Use Windows lineendings for this file since it will often open in 251 // Use Windows lineendings for this file since it will often open in
252 // Notepad which can't handle Unix ones. 252 // Notepad which can't handle Unix ones.
253 ReplaceSubstringsAfterOffset(&argfile_default_contents, 0, "\n", "\r\n"); 253 ReplaceSubstringsAfterOffset(&argfile_default_contents, 0, "\n", "\r\n");
254 #endif 254 #endif
255 base::CreateDirectory(arg_file.DirName()); 255 base::CreateDirectory(arg_file.DirName());
256 base::WriteFile(arg_file, argfile_default_contents.c_str(), 256 base::WriteFile(arg_file, argfile_default_contents.c_str(),
257 static_cast<int>(argfile_default_contents.size())); 257 static_cast<int>(argfile_default_contents.size()));
258 } 258 }
259 259
260 ScopedTrace editor_trace(TraceItem::TRACE_SETUP, "Waiting for editor"); 260 ScopedTrace editor_trace(TraceItem::TRACE_SETUP, "Waiting for editor");
261 if (!RunEditor(arg_file)) 261 if (!RunEditor(arg_file))
262 return 1; 262 return 1;
263 } 263 }
264 264
265 // Now do a normal "gen" command. 265 // Now do a normal "gen" command.
266 OutputString("Generating files...\n"); 266 OutputString("Generating files...\n");
267 std::vector<std::string> gen_commands; 267 std::vector<std::string> gen_commands;
268 gen_commands.push_back(build_dir); 268 gen_commands.push_back(build_dir);
269 return RunGen(gen_commands); 269 return RunGen(gen_commands);
270 } 270 }
271 271
272 } // namespace 272 } // namespace
273 273
274 extern const char kArgs[] = "args"; 274 extern const char kArgs[] = "args";
275 extern const char kArgs_HelpShort[] = 275 extern const char kArgs_HelpShort[] =
276 "args: Display or configure arguments declared by the build."; 276 "args: Display or configure arguments declared by the build.";
277 extern const char kArgs_Help[] = 277 extern const char kArgs_Help[] =
278 "gn args [arg name]\n" 278 "gn args <out_dir> [--list] [--short] [--args]\n"
279 "\n" 279 "\n"
280 " See also \"gn help buildargs\" for a more high-level overview of how\n" 280 " See also \"gn help buildargs\" for a more high-level overview of how\n"
281 " build arguments work.\n" 281 " build arguments work.\n"
282 "\n" 282 "\n"
283 "Usage\n" 283 "Usage\n"
284 " gn args <dir_name>\n" 284 " gn args <out_dir>\n"
285 " Open the arguments for the given build directory in an editor\n" 285 " Open the arguments for the given build directory in an editor\n"
286 " (as specified by the EDITOR environment variable). If the given\n" 286 " (as specified by the EDITOR environment variable). If the given\n"
287 " build directory doesn't exist, it will be created and an empty\n" 287 " build directory doesn't exist, it will be created and an empty\n"
288 " args file will be opened in the editor. You would type something\n" 288 " args file will be opened in the editor. You would type something\n"
289 " like this into that file:\n" 289 " like this into that file:\n"
290 " enable_doom_melon=false\n" 290 " enable_doom_melon=false\n"
291 " os=\"android\"\n" 291 " os=\"android\"\n"
292 "\n" 292 "\n"
293 " Note: you can edit the build args manually by editing the file\n" 293 " Note: you can edit the build args manually by editing the file\n"
294 " \"args.gn\" in the build directory and then running\n" 294 " \"args.gn\" in the build directory and then running\n"
295 " \"gn gen <build_dir>\".\n" 295 " \"gn gen <out_dir>\".\n"
296 "\n" 296 "\n"
297 " gn args <dir_name> --list[=<exact_arg>] [--short]\n" 297 " gn args <out_dir> --list[=<exact_arg>] [--short]\n"
298 " Lists all build arguments available in the current configuration,\n" 298 " Lists all build arguments available in the current configuration,\n"
299 " or, if an exact_arg is specified for the list flag, just that one\n" 299 " or, if an exact_arg is specified for the list flag, just that one\n"
300 " build argument.\n" 300 " build argument.\n"
301 "\n" 301 "\n"
302 " The output will list the declaration location, default value, and\n" 302 " The output will list the declaration location, default value, and\n"
303 " comment preceeding the declaration. If --short is specified,\n" 303 " comment preceeding the declaration. If --short is specified,\n"
304 " only the names and values will be printed.\n" 304 " only the names and values will be printed.\n"
305 "\n" 305 "\n"
306 " If the dir_name is specified, the build configuration will be\n" 306 " If the out_dir is specified, the build configuration will be\n"
307 " taken from that build directory. The reason this is needed is that\n" 307 " taken from that build directory. The reason this is needed is that\n"
308 " the definition of some arguments is dependent on the build\n" 308 " the definition of some arguments is dependent on the build\n"
309 " configuration, so setting some values might add, remove, or change\n" 309 " configuration, so setting some values might add, remove, or change\n"
310 " the default values for other arguments. Specifying your exact\n" 310 " the default values for other arguments. Specifying your exact\n"
311 " configuration allows the proper arguments to be displayed.\n" 311 " configuration allows the proper arguments to be displayed.\n"
312 "\n" 312 "\n"
313 " Instead of specifying the dir_name, you can also use the\n" 313 " Instead of specifying the out_dir, you can also use the\n"
314 " command-line flag to specify the build configuration:\n" 314 " command-line flag to specify the build configuration:\n"
315 " --args=<exact list of args to use>\n" 315 " --args=<exact list of args to use>\n"
316 "\n" 316 "\n"
317 "Examples\n" 317 "Examples\n"
318 " gn args out/Debug\n" 318 " gn args out/Debug\n"
319 " Opens an editor with the args for out/Debug.\n" 319 " Opens an editor with the args for out/Debug.\n"
320 "\n" 320 "\n"
321 " gn args out/Debug --list --short\n" 321 " gn args out/Debug --list --short\n"
322 " Prints all arguments with their default values for the out/Debug\n" 322 " Prints all arguments with their default values for the out/Debug\n"
323 " build.\n" 323 " build.\n"
324 "\n" 324 "\n"
325 " gn args out/Debug --list=cpu_arch\n" 325 " gn args out/Debug --list=cpu_arch\n"
326 " Prints information about the \"cpu_arch\" argument for the out/Debug\n" 326 " Prints information about the \"cpu_arch\" argument for the out/Debug\n"
327 " build.\n" 327 " build.\n"
328 "\n" 328 "\n"
329 " gn args --list --args=\"os=\\\"android\\\" enable_doom_melon=true\"\n" 329 " gn args --list --args=\"os=\\\"android\\\" enable_doom_melon=true\"\n"
330 " Prints all arguments with the default values for a build with the\n" 330 " Prints all arguments with the default values for a build with the\n"
331 " given arguments set (which may affect the values of other\n" 331 " given arguments set (which may affect the values of other\n"
332 " arguments).\n"; 332 " arguments).\n";
333 333
334 int RunArgs(const std::vector<std::string>& args) { 334 int RunArgs(const std::vector<std::string>& args) {
335 if (args.size() != 1) { 335 if (args.size() != 1) {
336 Err(Location(), "Exactly one build dir needed.", 336 Err(Location(), "Exactly one build dir needed.",
337 "Usage: \"gn args <build_dir>\"\n" 337 "Usage: \"gn args <out_dir>\"\n"
338 "Or see \"gn help args\" for more variants.").PrintToStdout(); 338 "Or see \"gn help args\" for more variants.").PrintToStdout();
339 return 1; 339 return 1;
340 } 340 }
341 341
342 if (base::CommandLine::ForCurrentProcess()->HasSwitch(kSwitchList)) 342 if (base::CommandLine::ForCurrentProcess()->HasSwitch(kSwitchList))
343 return ListArgs(args[0]); 343 return ListArgs(args[0]);
344 return EditArgsFile(args[0]); 344 return EditArgsFile(args[0]);
345 } 345 }
346 346
347 } // namespace commands 347 } // namespace commands
OLDNEW
« no previous file with comments | « no previous file | tools/gn/command_gen.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698