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

Unified Diff: tools/gn/args.cc

Issue 2151633002: Mark build arguments implicitly used in GN. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 5 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/gn/args.cc
diff --git a/tools/gn/args.cc b/tools/gn/args.cc
index accdf7ecb2dcbd3756e81a636747b62ecfbb5d68..823a8ccdbed9722d96d3bc32f0a670f9e9dca311 100644
--- a/tools/gn/args.cc
+++ b/tools/gn/args.cc
@@ -184,6 +184,12 @@ bool Args::DeclareArgs(const Scope::KeyValueMap& args,
declared_arguments.insert(arg);
}
+ // In all the cases below, mark the variable used. If a variable is set
+ // that's only used in one toolchain, we don't want to report unused
+ // variable errors in other toolchains. Also, in some cases it's reasonable
+ // for the build file to overwrite the value with a different value based
+ // on some other condition without dereferencing the value first.
+
// Check whether this argument has been overridden on the toolchain level
// and use the override instead.
Scope::KeyValueMap::const_iterator toolchain_override =
@@ -192,6 +198,7 @@ bool Args::DeclareArgs(const Scope::KeyValueMap& args,
scope_to_set->SetValue(toolchain_override->first,
toolchain_override->second,
toolchain_override->second.origin());
+ scope_to_set->MarkUsed(arg.first);
continue;
}
@@ -201,11 +208,10 @@ bool Args::DeclareArgs(const Scope::KeyValueMap& args,
if (override != overrides_.end()) {
scope_to_set->SetValue(override->first, override->second,
override->second.origin());
+ scope_to_set->MarkUsed(override->first);
continue;
}
- // Mark the variable used so the build script can override it in
- // certain cases without getting unused value errors.
scope_to_set->SetValue(arg.first, arg.second, arg.second.origin());
scope_to_set->MarkUsed(arg.first);
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698