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_SCOPE_H_ | 5 #ifndef TOOLS_GN_SCOPE_H_ |
6 #define TOOLS_GN_SCOPE_H_ | 6 #define TOOLS_GN_SCOPE_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <memory> | 9 #include <memory> |
10 #include <set> | 10 #include <set> |
11 #include <utility> | 11 #include <utility> |
12 | 12 |
13 #include "base/containers/hash_tables.h" | 13 #include "base/containers/hash_tables.h" |
14 #include "base/macros.h" | 14 #include "base/macros.h" |
15 #include "base/memory/ref_counted.h" | 15 #include "base/memory/ref_counted.h" |
16 #include "base/memory/scoped_vector.h" | 16 #include "base/memory/scoped_vector.h" |
17 #include "tools/gn/err.h" | 17 #include "tools/gn/err.h" |
| 18 #include "tools/gn/input_file.h" |
18 #include "tools/gn/pattern.h" | 19 #include "tools/gn/pattern.h" |
19 #include "tools/gn/source_dir.h" | 20 #include "tools/gn/source_dir.h" |
20 #include "tools/gn/value.h" | 21 #include "tools/gn/value.h" |
21 | 22 |
22 class Item; | 23 class Item; |
23 class ParseNode; | 24 class ParseNode; |
24 class Settings; | 25 class Settings; |
25 class Template; | 26 class Template; |
26 | 27 |
27 // Scope for the script execution. | 28 // Scope for the script execution. |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
92 // so won't trigger an unused variable warning. You want this when doing an | 93 // so won't trigger an unused variable warning. You want this when doing an |
93 // import, for example, or files that don't need a variable from the .gni | 94 // import, for example, or files that don't need a variable from the .gni |
94 // file will throw an error. | 95 // file will throw an error. |
95 bool mark_dest_used; | 96 bool mark_dest_used; |
96 | 97 |
97 // When set, those variables are not merged. | 98 // When set, those variables are not merged. |
98 std::set<std::string> excluded_values; | 99 std::set<std::string> excluded_values; |
99 }; | 100 }; |
100 | 101 |
101 // Creates an empty toplevel scope. | 102 // Creates an empty toplevel scope. |
102 explicit Scope(const Settings* settings); | 103 Scope(const Settings* settings, const InputFileSet& input_files); |
103 | 104 |
104 // Creates a dependent scope. | 105 // Creates a dependent scope. |
105 explicit Scope(Scope* parent); | 106 explicit Scope(Scope* parent); |
106 explicit Scope(const Scope* parent); | 107 explicit Scope(const Scope* parent); |
107 | 108 |
108 ~Scope(); | 109 ~Scope(); |
109 | 110 |
110 const Settings* settings() const { return settings_; } | 111 const Settings* settings() const { return settings_; } |
111 | 112 |
112 // See the const_/mutable_containing_ var declarations below. Yes, it's a | 113 // See the const_/mutable_containing_ var declarations below. Yes, it's a |
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
277 void SetProcessingImport(); | 278 void SetProcessingImport(); |
278 void ClearProcessingImport(); | 279 void ClearProcessingImport(); |
279 bool IsProcessingImport() const; | 280 bool IsProcessingImport() const; |
280 | 281 |
281 // The source directory associated with this scope. This will check embedded | 282 // The source directory associated with this scope. This will check embedded |
282 // scopes until it finds a nonempty source directory. This will default to | 283 // scopes until it finds a nonempty source directory. This will default to |
283 // an empty dir if no containing scope has a source dir set. | 284 // an empty dir if no containing scope has a source dir set. |
284 const SourceDir& GetSourceDir() const; | 285 const SourceDir& GetSourceDir() const; |
285 void set_source_dir(const SourceDir& d) { source_dir_ = d; } | 286 void set_source_dir(const SourceDir& d) { source_dir_ = d; } |
286 | 287 |
| 288 // The set of source files which affected this scope. |
| 289 const InputFileSet& input_files() const { return input_files_; } |
| 290 void AddInputFile(const InputFile* input_file); |
| 291 |
287 // The item collector is where Items (Targets, Configs, etc.) go that have | 292 // The item collector is where Items (Targets, Configs, etc.) go that have |
288 // been defined. If a scope can generate items, this non-owning pointer will | 293 // been defined. If a scope can generate items, this non-owning pointer will |
289 // point to the storage for such items. The creator of this scope will be | 294 // point to the storage for such items. The creator of this scope will be |
290 // responsible for setting up the collector and then dealing with the | 295 // responsible for setting up the collector and then dealing with the |
291 // collected items once execution of the context is complete. | 296 // collected items once execution of the context is complete. |
292 // | 297 // |
293 // The items in a scope are collected as we go and then dispatched at the end | 298 // The items in a scope are collected as we go and then dispatched at the end |
294 // of execution of a scope so that we can query the previously-generated | 299 // of execution of a scope so that we can query the previously-generated |
295 // targets (like getting the outputs). | 300 // targets (like getting the outputs). |
296 // | 301 // |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
372 | 377 |
373 // Opaque pointers. See SetProperty() above. | 378 // Opaque pointers. See SetProperty() above. |
374 typedef std::map<const void*, void*> PropertyMap; | 379 typedef std::map<const void*, void*> PropertyMap; |
375 PropertyMap properties_; | 380 PropertyMap properties_; |
376 | 381 |
377 typedef std::set<ProgrammaticProvider*> ProviderSet; | 382 typedef std::set<ProgrammaticProvider*> ProviderSet; |
378 ProviderSet programmatic_providers_; | 383 ProviderSet programmatic_providers_; |
379 | 384 |
380 SourceDir source_dir_; | 385 SourceDir source_dir_; |
381 | 386 |
| 387 InputFileSet input_files_; |
| 388 |
382 DISALLOW_COPY_AND_ASSIGN(Scope); | 389 DISALLOW_COPY_AND_ASSIGN(Scope); |
383 }; | 390 }; |
384 | 391 |
385 #endif // TOOLS_GN_SCOPE_H_ | 392 #endif // TOOLS_GN_SCOPE_H_ |
OLD | NEW |