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

Unified Diff: tools/gn/command_gyp.cc

Issue 137713007: Check for GN args using the union of all rather than individually. (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/command_args.cc ('k') | tools/gn/setup.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/gn/command_gyp.cc
diff --git a/tools/gn/command_gyp.cc b/tools/gn/command_gyp.cc
index 570a8c405201f7ae8c1e0fabc17a7f080a5ccb40..5ed445260e95d8bd399b86cc2f41a3aea5b8692f 100644
--- a/tools/gn/command_gyp.cc
+++ b/tools/gn/command_gyp.cc
@@ -317,6 +317,39 @@ std::pair<int, int> WriteGypFiles(Setups& setups, Err* err) {
static_cast<int>(grouped_targets.size()));
}
+// Verifies that all build argument overrides are used by at least one of the
+// build types.
+void VerifyAllOverridesUsed(const Setups& setups) {
+ // Collect all declared args from all builds.
+ Scope::KeyValueMap declared;
+ setups.debug->build_settings().build_args().MergeDeclaredArguments(
+ &declared);
+ setups.release->build_settings().build_args().MergeDeclaredArguments(
+ &declared);
+ if (setups.debug64 && setups.release64) {
+ setups.debug64->build_settings().build_args().MergeDeclaredArguments(
+ &declared);
+ setups.release64->build_settings().build_args().MergeDeclaredArguments(
+ &declared);
+ }
+ if (setups.xcode_debug && setups.xcode_release) {
+ setups.xcode_debug->build_settings().build_args().MergeDeclaredArguments(
+ &declared);
+ setups.xcode_release->build_settings().build_args().MergeDeclaredArguments(
+ &declared);
+ }
+
+ Scope::KeyValueMap used =
+ setups.debug->build_settings().build_args().GetAllOverrides();
+
+ Err err;
+ if (!Args::VerifyAllOverridesUsed(used, declared, &err)) {
+ // TODO(brettw) implement a system of warnings. Until we have a better
+ // system, print the error but don't cause a failure.
+ err.PrintToStdout();
+ }
+}
+
} // namespace
// Suppress output on success.
@@ -391,8 +424,13 @@ int RunGyp(const std::vector<std::string>& args) {
base::ElapsedTimer timer;
Setups setups;
- // Deliberately leaked to avoid expensive process teardown.
+ // Deliberately leaked to avoid expensive process teardown. We also turn off
+ // unused override checking since we want to merge all declared arguments and
+ // check those, rather than check each build individually. Otherwise, you
+ // couldn't have an arg that was used in only one build type. This comes up
+ // because some args are build-type specific.
setups.debug = new Setup;
+ setups.debug->set_check_for_unused_overrides(false);
if (!setups.debug->DoSetup())
return 1;
const char kIsDebug[] = "is_debug";
@@ -466,6 +504,8 @@ int RunGyp(const std::vector<std::string>& args) {
if (setups.xcode_release && !setups.xcode_release->RunPostMessageLoop())
return 1;
+ VerifyAllOverridesUsed(setups);
+
Err err;
std::pair<int, int> counts = WriteGypFiles(setups, &err);
if (err.has_error()) {
« no previous file with comments | « tools/gn/command_args.cc ('k') | tools/gn/setup.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698