Chromium Code Reviews| Index: tools/gn/loader.cc |
| diff --git a/tools/gn/loader.cc b/tools/gn/loader.cc |
| index 4cca2ce71b2805f5eeb9004a55cba0a0630c2853..1e9e76fdb14195b98930dd97b06b781ae416281e 100644 |
| --- a/tools/gn/loader.cc |
| +++ b/tools/gn/loader.cc |
| @@ -19,6 +19,19 @@ |
| #include "tools/gn/source_file.h" |
| #include "tools/gn/trace.h" |
| +namespace { |
| + |
| +void ClearPrivateVariables(Scope* scope) { |
|
cjhopman
2014/05/14 16:42:43
Why not just add this on Scope?
brettw
2014/05/15 19:44:15
Done.
|
| + std::vector<base::StringPiece> variables; |
| + scope->GetCurrentScopeVariables(&variables); |
| + for (size_t i = 0; i < variables.size(); i++) { |
| + if (Scope::IsPrivateVar(variables[i])) |
| + scope->DeleteValue(variables[i]); |
| + } |
| +} |
| + |
| +} // namespace |
| + |
| // Identifies one time a file is loaded in a given toolchain so we don't load |
| // it more than once. |
| struct LoaderImpl::LoadID { |
| @@ -245,6 +258,9 @@ void LoaderImpl::BackgroundLoadFile(const Settings* settings, |
| if (err.has_error()) |
| g_scheduler->FailWithError(err); |
| + if (!our_scope.CheckForUnusedVars(&err)) |
| + g_scheduler->FailWithError(err); |
| + |
| // Pass all of the items that were defined off to the builder. |
| for (size_t i = 0; i < collected_items.size(); i++) |
| settings->build_settings()->ItemDefined(collected_items[i]->Pass()); |
| @@ -285,6 +301,11 @@ void LoaderImpl::BackgroundLoadBuildConfig( |
| Err err; |
| root_block->ExecuteBlockInScope(base_config, &err); |
| + // Clear all private variables left in the scope. We want the root build |
| + // config to be like a .gni file in that variables beginning with an |
| + // underscore aren't exported. |
| + ClearPrivateVariables(base_config); |
| + |
| trace.Done(); |
| if (err.has_error()) |