Commit 8b05f575 authored by brettw's avatar brettw Committed by Commit bot

Mark build arguments implicitly used in GN.

This regressed in https://codereview.chromium.org/2092623002 which caused a revert of the GN roll. The particular issue is that a build argument in a BUILD.gn file was used in only one of the toolchains, so the other toolchains were giving unused variable errors on it.

Build variables kept at their default values already are marked implicitly used, and anything in a .gni file is the same. The remaining cases are pretty confusing so it seems better to not warn in this case instead of requiring the author to wrap the build variable in a condition based on the usage.

TBR=dpranke

Review-Url: https://codereview.chromium.org/2151633002
Cr-Commit-Position: refs/heads/master@{#405291}
parent 86ab4290
......@@ -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);
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment