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" |
11 #include "tools/gn/err.h" | 11 #include "tools/gn/err.h" |
12 #include "tools/gn/scope.h" | 12 #include "tools/gn/scope.h" |
13 | 13 |
14 extern const char kBuildArgs_Help[]; | 14 extern const char kBuildArgs_Help[]; |
15 | 15 |
16 // Manages build arguments. It stores the global arguments specified on the | 16 // Manages build arguments. It stores the global arguments specified on the |
17 // command line, and sets up the root scope with the proper values. | 17 // command line, and sets up the root scope with the proper values. |
18 // | 18 // |
19 // This class tracks accesses so we can report errors about unused variables. | 19 // This class tracks accesses so we can report errors about unused variables. |
20 // The use case is if the user specifies an override on the command line, but | 20 // The use case is if the user specifies an override on the command line, but |
21 // no buildfile actually uses that variable. We want to be able to report that | 21 // no buildfile actually uses that variable. We want to be able to report that |
22 // the argument was unused. | 22 // the argument was unused. |
23 class Args { | 23 class Args { |
24 public: | 24 public: |
25 Args(); | 25 Args(); |
| 26 Args(const Args& other); |
26 ~Args(); | 27 ~Args(); |
27 | 28 |
28 // Specifies overrides of the build arguments. These are normally specified | 29 // Specifies overrides of the build arguments. These are normally specified |
29 // on the command line. | 30 // on the command line. |
| 31 void AddArgOverride(const char* name, const Value& value); |
30 void AddArgOverrides(const Scope::KeyValueMap& overrides); | 32 void AddArgOverrides(const Scope::KeyValueMap& overrides); |
31 | 33 |
32 // Sets up the root scope for a toolchain. This applies the default system | 34 // Sets up the root scope for a toolchain. This applies the default system |
33 // flags, then any overrides stored in this object, then applies any | 35 // flags, then any overrides stored in this object, then applies any |
34 // toolchain overrides specified in the argument. | 36 // toolchain overrides specified in the argument. |
35 void SetupRootScope(Scope* dest, | 37 void SetupRootScope(Scope* dest, |
36 const Scope::KeyValueMap& toolchain_overrides) const; | 38 const Scope::KeyValueMap& toolchain_overrides) const; |
37 | 39 |
38 // Sets up the given scope with arguments passed in. | 40 // Sets up the given scope with arguments passed in. |
39 // | 41 // |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
75 | 77 |
76 // Maintains a list of all overrides we've ever seen. This is the main | 78 // Maintains a list of all overrides we've ever seen. This is the main |
77 // |overrides_| as well as toolchain overrides. Tracking this allows us to | 79 // |overrides_| as well as toolchain overrides. Tracking this allows us to |
78 // check for overrides that were specified but never used. | 80 // check for overrides that were specified but never used. |
79 mutable Scope::KeyValueMap all_overrides_; | 81 mutable Scope::KeyValueMap all_overrides_; |
80 | 82 |
81 // Tracks all variables declared in any buildfile. This is so we can see if | 83 // Tracks all variables declared in any buildfile. This is so we can see if |
82 // the user set variables on the command line that are not used anywhere. | 84 // the user set variables on the command line that are not used anywhere. |
83 mutable Scope::KeyValueMap declared_arguments_; | 85 mutable Scope::KeyValueMap declared_arguments_; |
84 | 86 |
85 DISALLOW_COPY_AND_ASSIGN(Args); | 87 Args& operator=(const Args& other); // Disallow assignment. |
86 }; | 88 }; |
87 | 89 |
88 #endif // TOOLS_GN_ARGS_H_ | 90 #endif // TOOLS_GN_ARGS_H_ |
OLD | NEW |