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

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

Issue 2514333005: Add support for customizing GN's args text. (Closed)
Patch Set: Created 4 years 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
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 <stddef.h> 5 #include <stddef.h>
6 #include <stdio.h> 6 #include <stdio.h>
7 #include <stdlib.h> 7 #include <stdlib.h>
8 #include <string.h> 8 #include <string.h>
9 9
10 #include <map> 10 #include <map>
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after
236 if (!setup.DoSetup(build_dir, true)) 236 if (!setup.DoSetup(build_dir, true))
237 return 1; 237 return 1;
238 238
239 // Ensure the file exists. Need to normalize path separators since on 239 // Ensure the file exists. Need to normalize path separators since on
240 // Windows they can come out as forward slashes here, and that confuses some 240 // Windows they can come out as forward slashes here, and that confuses some
241 // of the commands. 241 // of the commands.
242 base::FilePath arg_file = 242 base::FilePath arg_file =
243 setup.build_settings().GetFullPath(setup.GetBuildArgFile()) 243 setup.build_settings().GetFullPath(setup.GetBuildArgFile())
244 .NormalizePathSeparators(); 244 .NormalizePathSeparators();
245 if (!base::PathExists(arg_file)) { 245 if (!base::PathExists(arg_file)) {
246 std::string argfile_default_contents = 246 BuildSettings build_settings = setup.build_settings();
247 "# Build arguments go here. Examples:\n" 247 base::FilePath arg_file_template_path =
248 "# is_component_build = true\n" 248 build_settings.GetFullPath(build_settings.arg_file_template_path())
brettw 2016/11/22 16:14:32 Indent more.
Dirk Pranke 2016/11/22 18:41:52 Done.
249 "# is_debug = false\n" 249 .NormalizePathSeparators();
250 "# See \"gn args <out_dir> --list\" for available build " 250
251 "arguments.\n"; 251 std::string argfile_default_contents;
252 if (!build_settings.arg_file_template_path().is_null()) {
253 base::FilePath arg_file_path_template_path =
254 build_settings.GetFullPath(build_settings.arg_file_template_path());
brettw 2016/11/22 16:14:32 Indent mode (maybe this will have to wrap, sadly).
Dirk Pranke 2016/11/22 18:41:52 Reworked to be shorter.
255 if (!base::ReadFileToString(arg_file_template_path,
256 &argfile_default_contents)) {
257 return 1;
Dirk Pranke 2016/11/22 04:27:39 Should I print an err to stdout here if this read
brettw 2016/11/22 16:14:32 No, but I would prefer if it fell through to the d
Dirk Pranke 2016/11/22 18:41:52 Done. I'm not sure if I'm wild about that, but it'
258 }
259 } else {
260 argfile_default_contents =
261 "# Build arguments go here. Examples:\n"
262 "# is_component_build = true\n"
263 "# is_debug = false\n"
brettw 2016/11/22 16:14:32 Can you remove the examples in this case?
Dirk Pranke 2016/11/22 18:41:52 Done.
264 "# See \"gn args <out_dir> --list\" for available build "
265 "arguments.\n";
266 }
252 #if defined(OS_WIN) 267 #if defined(OS_WIN)
253 // Use Windows lineendings for this file since it will often open in 268 // Use Windows lineendings for this file since it will often open in
254 // Notepad which can't handle Unix ones. 269 // Notepad which can't handle Unix ones.
255 base::ReplaceSubstringsAfterOffset( 270 base::ReplaceSubstringsAfterOffset(
256 &argfile_default_contents, 0, "\n", "\r\n"); 271 &argfile_default_contents, 0, "\n", "\r\n");
257 #endif 272 #endif
258 base::CreateDirectory(arg_file.DirName()); 273 base::CreateDirectory(arg_file.DirName());
259 base::WriteFile(arg_file, argfile_default_contents.c_str(), 274 base::WriteFile(arg_file, argfile_default_contents.c_str(),
260 static_cast<int>(argfile_default_contents.size())); 275 static_cast<int>(argfile_default_contents.size()));
261 } 276 }
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
343 "Or see \"gn help args\" for more variants.").PrintToStdout(); 358 "Or see \"gn help args\" for more variants.").PrintToStdout();
344 return 1; 359 return 1;
345 } 360 }
346 361
347 if (base::CommandLine::ForCurrentProcess()->HasSwitch(kSwitchList)) 362 if (base::CommandLine::ForCurrentProcess()->HasSwitch(kSwitchList))
348 return ListArgs(args[0]); 363 return ListArgs(args[0]);
349 return EditArgsFile(args[0]); 364 return EditArgsFile(args[0]);
350 } 365 }
351 366
352 } // namespace commands 367 } // namespace commands
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698