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

Unified Diff: tools/gn/args.h

Issue 2092623002: GN: Don't define argument overrides globally (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address comments 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 | tools/gn/args.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/gn/args.h
diff --git a/tools/gn/args.h b/tools/gn/args.h
index 1f9cb52f7ded8f52c5be389b594e0abfbff307e4..9df5712d9f30e0753d0a8ff02eb435b89e36b457 100644
--- a/tools/gn/args.h
+++ b/tools/gn/args.h
@@ -40,8 +40,8 @@ class Args {
Scope::KeyValueMap GetAllOverrides() const;
// Sets up the root scope for a toolchain. This applies the default system
- // flags, then any overrides stored in this object, then applies any
- // toolchain overrides specified in the argument.
+ // flags and saves the toolchain overrides so they can be applied to
+ // declare_args blocks that appear when loading files in that toolchain.
void SetupRootScope(Scope* dest,
const Scope::KeyValueMap& toolchain_overrides) const;
@@ -68,13 +68,13 @@ class Args {
void MergeDeclaredArguments(Scope::KeyValueMap* dest) const;
private:
- using DeclaredArgumentsPerToolchain =
+ using ArgumentsPerToolchain =
base::hash_map<const Settings*, Scope::KeyValueMap>;
// Sets the default config based on the current system.
void SetSystemVarsLocked(Scope* scope) const;
- // Sets the given vars on the given scope.
+ // Sets the given already declared vars on the given scope.
void ApplyOverridesLocked(const Scope::KeyValueMap& values,
Scope* scope) const;
@@ -84,6 +84,10 @@ class Args {
// toolchain.
Scope::KeyValueMap& DeclaredArgumentsForToolchainLocked(Scope* scope) const;
+ // Returns the KeyValueMap used for overrides for the specified
+ // toolchain.
+ Scope::KeyValueMap& OverridesForToolchainLocked(Scope* scope) const;
+
// Since this is called during setup which we assume is single-threaded,
// this is not protected by the lock. It should be set only during init.
Scope::KeyValueMap overrides_;
@@ -100,7 +104,12 @@ class Args {
// buildfile. This is so we can see if the user set variables on the command
// line that are not used anywhere. Each map is toolchain specific as each
// toolchain may define variables in different locations.
- mutable DeclaredArgumentsPerToolchain declared_arguments_per_toolchain_;
+ mutable ArgumentsPerToolchain declared_arguments_per_toolchain_;
+
+ // Overrides for individual toolchains. This is necessary so we
+ // can apply the correct override for the current toolchain, once
+ // we see an argument declaration.
+ mutable ArgumentsPerToolchain toolchain_overrides_;
DISALLOW_ASSIGN(Args);
};
« no previous file with comments | « no previous file | tools/gn/args.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698