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

Unified Diff: tools/gn/command_args.cc

Issue 161783002: Remove default value checking in GN, adds getenv function, reorders parameters to rebase_path. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 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/args.cc ('k') | tools/gn/function_rebase_path.cc » ('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 dd28c11839efdb7a3101892fcf834f3857fe0041..2b8c7d771a7a71206751986d74131731cab7b892 100644
--- a/tools/gn/command_args.cc
+++ b/tools/gn/command_args.cc
@@ -42,16 +42,14 @@ size_t BackUpToLineBegin(const std::string& data, size_t offset) {
return 0;
}
-// Assumes DoesLineBeginWithComment().
-std::string StripCommentFromLine(const base::StringPiece& line) {
- std::string ret = line.as_string();
- for (size_t i = 0; i < ret.size(); i++) {
- if (ret[i] == '#') {
- ret[i] = ' ';
- break;
- }
- }
- return ret;
+// Assumes DoesLineBeginWithComment(), this strips the # character from the
+// beginning and normalizes preceeding whitespace.
+std::string StripHashFromLine(const base::StringPiece& line) {
+ // Replace the # sign and everything before it with 3 spaces, so that a
+ // normal comment that has a space after the # will be indented 4 spaces
+ // (which makes our formatting come out nicely). If the comment is indented
+ // from there, we want to preserve that indenting.
+ return " " + line.substr(line.find('#') + 1).as_string();
}
// Tries to find the comment before the setting of the given value.
@@ -79,7 +77,7 @@ void GetContextForValue(const Value& value,
if (!DoesLineBeginWithComment(line))
break;
- comment->insert(0, StripCommentFromLine(line) + "\n");
+ comment->insert(0, StripHashFromLine(line) + "\n");
line_off = previous_line_offset;
}
}
@@ -150,6 +148,12 @@ int RunArgs(const std::vector<std::string>& args) {
i != build_args.end(); ++i)
sorted_args.insert(*i);
+ OutputString(
+ "Available build arguments. Note that the which arguments are declared\n"
+ "and their default values may depend on other arguments or the current\n"
+ "platform and architecture. So setting some values may add, remove, or\n"
+ "change the default value of other values.\n\n");
+
for (std::map<base::StringPiece, Value>::iterator i = sorted_args.begin();
i != sorted_args.end(); ++i) {
PrintArgHelp(i->first, i->second);
« no previous file with comments | « tools/gn/args.cc ('k') | tools/gn/function_rebase_path.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698