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

Side by Side Diff: tools/gn/args.h

Issue 984353002: Makes declared_arguments per toolchain (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: cleanup Created 5 years, 9 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef TOOLS_GN_ARGS_H_ 5 #ifndef TOOLS_GN_ARGS_H_
6 #define TOOLS_GN_ARGS_H_ 6 #define TOOLS_GN_ARGS_H_
7 7
8 #include "base/basictypes.h" 8 #include "base/basictypes.h"
9 #include "base/containers/hash_tables.h" 9 #include "base/containers/hash_tables.h"
10 #include "base/synchronization/lock.h" 10 #include "base/synchronization/lock.h"
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
54 // 54 //
55 // On failure, the err will be set and it will return false. 55 // On failure, the err will be set and it will return false.
56 bool DeclareArgs(const Scope::KeyValueMap& args, 56 bool DeclareArgs(const Scope::KeyValueMap& args,
57 Scope* scope_to_set, 57 Scope* scope_to_set,
58 Err* err) const; 58 Err* err) const;
59 59
60 // Checks to see if any of the overrides ever used were never declared as 60 // Checks to see if any of the overrides ever used were never declared as
61 // arguments. If there are, this returns false and sets the error. 61 // arguments. If there are, this returns false and sets the error.
62 bool VerifyAllOverridesUsed(Err* err) const; 62 bool VerifyAllOverridesUsed(Err* err) const;
63 63
64 // Adds all declared arguments to the given output list. If the values exist
65 // in the list already, their values will be overwriten, but other values
66 // already in the list will remain.
67 void MergeDeclaredArguments(Scope::KeyValueMap* dest) const;
68
69 private:
70 using DeclaredArgumentsPerToolchain =
71 base::hash_map<const Settings*, Scope::KeyValueMap>;
72
64 // Like VerifyAllOverridesUsed but takes the lists of overrides specified and 73 // Like VerifyAllOverridesUsed but takes the lists of overrides specified and
65 // parameters declared. 74 // parameters declared.
66 static bool VerifyAllOverridesUsed( 75 static bool VerifyAllOverridesUsed(
sky 2015/03/13 20:43:13 I moved this to the private block as no one but th
67 const Scope::KeyValueMap& overrides, 76 const Scope::KeyValueMap& overrides,
68 const Scope::KeyValueMap& declared_arguments, 77 const Scope::KeyValueMap& declared_arguments,
69 Err* err); 78 Err* err);
70 79
71 // Adds all declared arguments to the given output list. If the values exist
72 // in the list already, their values will be overwriten, but other values
73 // already in the list will remain.
74 void MergeDeclaredArguments(Scope::KeyValueMap* dest) const;
75
76 private:
77 // Sets the default config based on the current system. 80 // Sets the default config based on the current system.
78 void SetSystemVarsLocked(Scope* scope) const; 81 void SetSystemVarsLocked(Scope* scope) const;
79 82
80 // Sets the given vars on the given scope. 83 // Sets the given vars on the given scope.
81 void ApplyOverridesLocked(const Scope::KeyValueMap& values, 84 void ApplyOverridesLocked(const Scope::KeyValueMap& values,
82 Scope* scope) const; 85 Scope* scope) const;
83 86
84 void SaveOverrideRecordLocked(const Scope::KeyValueMap& values) const; 87 void SaveOverrideRecordLocked(const Scope::KeyValueMap& values) const;
85 88
89 // Returns the KeyValueMap used for arguments declared for the specified
90 // toolchain.
91 // NOTE: this does not grab a lock.
brettw 2015/03/14 05:14:32 I was calling such functions ...Locked. I think if
sky 2015/03/16 16:20:45 Done.
92 Scope::KeyValueMap& DeclaredArgumentsForToolchain(Scope* scope) const;
93
86 // Since this is called during setup which we assume is single-threaded, 94 // Since this is called during setup which we assume is single-threaded,
87 // this is not protected by the lock. It should be set only during init. 95 // this is not protected by the lock. It should be set only during init.
88 Scope::KeyValueMap overrides_; 96 Scope::KeyValueMap overrides_;
89 97
90 mutable base::Lock lock_; 98 mutable base::Lock lock_;
91 99
92 // Maintains a list of all overrides we've ever seen. This is the main 100 // Maintains a list of all overrides we've ever seen. This is the main
93 // |overrides_| as well as toolchain overrides. Tracking this allows us to 101 // |overrides_| as well as toolchain overrides. Tracking this allows us to
94 // check for overrides that were specified but never used. 102 // check for overrides that were specified but never used.
95 mutable Scope::KeyValueMap all_overrides_; 103 mutable Scope::KeyValueMap all_overrides_;
96 104
97 // Tracks all variables declared in any buildfile. This is so we can see if 105 // Maps from Settings (which corresponds to a toolchain) to the map of
98 // the user set variables on the command line that are not used anywhere. 106 // declared variables. This is used to tracks all variables declared in any
99 mutable Scope::KeyValueMap declared_arguments_; 107 // buildfile. This is so we can see if the user set variables on the command
108 // line that are not used anywhere. Each map is toolchain specific as each
109 // toolchain may define variables in different locations.
110 mutable DeclaredArgumentsPerToolchain declared_arguments_per_toolchain_;
100 111
101 Args& operator=(const Args& other); // Disallow assignment. 112 Args& operator=(const Args& other); // Disallow assignment.
102 }; 113 };
103 114
104 #endif // TOOLS_GN_ARGS_H_ 115 #endif // TOOLS_GN_ARGS_H_
OLDNEW
« no previous file with comments | « tools/gn/BUILD.gn ('k') | tools/gn/args.cc » ('j') | tools/gn/args.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698