OLD | NEW |
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 17 matching lines...) Expand all Loading... |
28 | 28 |
29 // Specifies overrides of the build arguments. These are normally specified | 29 // Specifies overrides of the build arguments. These are normally specified |
30 // on the command line. | 30 // on the command line. |
31 void AddArgOverride(const char* name, const Value& value); | 31 void AddArgOverride(const char* name, const Value& value); |
32 void AddArgOverrides(const Scope::KeyValueMap& overrides); | 32 void AddArgOverrides(const Scope::KeyValueMap& overrides); |
33 | 33 |
34 // Returns the value corresponding to the given argument name, or NULL if no | 34 // Returns the value corresponding to the given argument name, or NULL if no |
35 // argument is set. | 35 // argument is set. |
36 const Value* GetArgOverride(const char* name) const; | 36 const Value* GetArgOverride(const char* name) const; |
37 | 37 |
| 38 // Gets all overrides set on the build. |
| 39 Scope::KeyValueMap GetAllOverrides() const; |
| 40 |
38 // Sets up the root scope for a toolchain. This applies the default system | 41 // Sets up the root scope for a toolchain. This applies the default system |
39 // flags, then any overrides stored in this object, then applies any | 42 // flags, then any overrides stored in this object, then applies any |
40 // toolchain overrides specified in the argument. | 43 // toolchain overrides specified in the argument. |
41 void SetupRootScope(Scope* dest, | 44 void SetupRootScope(Scope* dest, |
42 const Scope::KeyValueMap& toolchain_overrides) const; | 45 const Scope::KeyValueMap& toolchain_overrides) const; |
43 | 46 |
44 // Sets up the given scope with arguments passed in. | 47 // Sets up the given scope with arguments passed in. |
45 // | 48 // |
46 // If the values specified in the args are not already set, the values in | 49 // If the values specified in the args are not already set, the values in |
47 // the args list will be used (which are assumed to be the defaults), but | 50 // the args list will be used (which are assumed to be the defaults), but |
48 // they will not override the system defaults or the current overrides. | 51 // they will not override the system defaults or the current overrides. |
49 // | 52 // |
50 // All args specified in the input will be marked as "used". | 53 // All args specified in the input will be marked as "used". |
51 // | 54 // |
52 // 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. |
53 bool DeclareArgs(const Scope::KeyValueMap& args, | 56 bool DeclareArgs(const Scope::KeyValueMap& args, |
54 Scope* scope_to_set, | 57 Scope* scope_to_set, |
55 Err* err) const; | 58 Err* err) const; |
56 | 59 |
57 // 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 |
58 // arguments. If there are, this returns false and sets the error. | 61 // arguments. If there are, this returns false and sets the error. |
59 bool VerifyAllOverridesUsed(Err* err) const; | 62 bool VerifyAllOverridesUsed(Err* err) const; |
60 | 63 |
61 // This function is not threadsafe, it must only be used when | 64 // Like VerifyAllOverridesUsed but takes the lists of overrides specified and |
62 // single-threaded. It's used to implement the "args" command. | 65 // parameters declared. |
63 const Scope::KeyValueMap& declared_arguments() const { | 66 static bool VerifyAllOverridesUsed( |
64 return declared_arguments_; | 67 const Scope::KeyValueMap& overrides, |
65 } | 68 const Scope::KeyValueMap& declared_arguments, |
| 69 Err* err); |
| 70 |
| 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; |
66 | 75 |
67 private: | 76 private: |
68 // Sets the default config based on the current system. | 77 // Sets the default config based on the current system. |
69 void SetSystemVarsLocked(Scope* scope) const; | 78 void SetSystemVarsLocked(Scope* scope) const; |
70 | 79 |
71 // Sets the given vars on the given scope. | 80 // Sets the given vars on the given scope. |
72 void ApplyOverridesLocked(const Scope::KeyValueMap& values, | 81 void ApplyOverridesLocked(const Scope::KeyValueMap& values, |
73 Scope* scope) const; | 82 Scope* scope) const; |
74 | 83 |
75 void SaveOverrideRecordLocked(const Scope::KeyValueMap& values) const; | 84 void SaveOverrideRecordLocked(const Scope::KeyValueMap& values) const; |
(...skipping 10 matching lines...) Expand all Loading... |
86 mutable Scope::KeyValueMap all_overrides_; | 95 mutable Scope::KeyValueMap all_overrides_; |
87 | 96 |
88 // Tracks all variables declared in any buildfile. This is so we can see if | 97 // Tracks all variables declared in any buildfile. This is so we can see if |
89 // the user set variables on the command line that are not used anywhere. | 98 // the user set variables on the command line that are not used anywhere. |
90 mutable Scope::KeyValueMap declared_arguments_; | 99 mutable Scope::KeyValueMap declared_arguments_; |
91 | 100 |
92 Args& operator=(const Args& other); // Disallow assignment. | 101 Args& operator=(const Args& other); // Disallow assignment. |
93 }; | 102 }; |
94 | 103 |
95 #endif // TOOLS_GN_ARGS_H_ | 104 #endif // TOOLS_GN_ARGS_H_ |
OLD | NEW |