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

Unified Diff: tools/gn/command_args.cc

Issue 2514333005: Add support for customizing GN's args text. (Closed)
Patch Set: update docs Created 3 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « tools/gn/build_settings.cc ('k') | tools/gn/docs/reference.md » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/gn/command_args.cc
diff --git a/tools/gn/command_args.cc b/tools/gn/command_args.cc
index 98283f298148676f7ebefc4e78ffa29832e87851..2772fc290c47964d47fbb983550c05355908c040 100644
--- a/tools/gn/command_args.cc
+++ b/tools/gn/command_args.cc
@@ -268,16 +268,32 @@ int EditArgsFile(const std::string& build_dir) {
// Ensure the file exists. Need to normalize path separators since on
// Windows they can come out as forward slashes here, and that confuses some
// of the commands.
+ BuildSettings build_settings = setup.build_settings();
base::FilePath arg_file =
- setup.build_settings().GetFullPath(setup.GetBuildArgFile())
- .NormalizePathSeparators();
+ build_settings.GetFullPath(setup.GetBuildArgFile())
+ .NormalizePathSeparators();
if (!base::PathExists(arg_file)) {
std::string argfile_default_contents =
- "# Build arguments go here. Examples:\n"
- "# is_component_build = true\n"
- "# is_debug = false\n"
+ "# Build arguments go here.\n"
"# See \"gn args <out_dir> --list\" for available build "
"arguments.\n";
+
+ SourceFile template_path = build_settings.arg_file_template_path();
+ if (!template_path.is_null()) {
+ base::FilePath full_path =
+ build_settings.GetFullPath(template_path).NormalizePathSeparators();
+ if (!base::PathExists(full_path)) {
+ Err err =
+ Err(Location(), std::string("Can't load arg_file_template:\n ") +
+ template_path.value());
+ err.PrintToStdout();
+ return 1;
+ }
+
+ // Ignore the return code; if the read fails (unlikely), we'll just
+ // use the default contents.
+ base::ReadFileToString(full_path, &argfile_default_contents);
+ }
#if defined(OS_WIN)
// Use Windows lineendings for this file since it will often open in
// Notepad which can't handle Unix ones.
« no previous file with comments | « tools/gn/build_settings.cc ('k') | tools/gn/docs/reference.md » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698