diff options
author | brettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-05-05 20:27:53 +0000 |
---|---|---|
committer | brettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-05-05 20:27:53 +0000 |
commit | e1bd79f30d777a17411bf0efd54d90b59c00f600 (patch) | |
tree | 8ec4d5560c1df26a3c655ce98ae8586c23eaf096 /tools/gn/scope.h | |
parent | da22c3c95242b05675da6b5e452c5dad8c5db1ee (diff) | |
download | chromium_src-e1bd79f30d777a17411bf0efd54d90b59c00f600.zip chromium_src-e1bd79f30d777a17411bf0efd54d90b59c00f600.tar.gz chromium_src-e1bd79f30d777a17411bf0efd54d90b59c00f600.tar.bz2 |
Add get_target_outputs function to GN
This function returns the outputs for a target that appeared previously in the same file. This is frequently needed for getting the files resulting from an action.
The main operational change is that targets that are generated are stashed in a vector as we process a file and then dispatched once that file is finished, rather than being dispatched as-we-go. This way we can ask questions about the targets that appeared previously in the file.
R=scottmg@chromium.org
Review URL: https://codereview.chromium.org/269723006
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@268260 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'tools/gn/scope.h')
-rw-r--r-- | tools/gn/scope.h | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/tools/gn/scope.h b/tools/gn/scope.h index 82e037f..208ee55 100644 --- a/tools/gn/scope.h +++ b/tools/gn/scope.h @@ -11,6 +11,7 @@ #include "base/basictypes.h" #include "base/containers/hash_tables.h" #include "base/memory/scoped_ptr.h" +#include "base/memory/scoped_vector.h" #include "tools/gn/err.h" #include "tools/gn/pattern.h" #include "tools/gn/source_dir.h" @@ -18,6 +19,7 @@ class FunctionCallNode; class ImportManager; +class Item; class ParseNode; class Settings; class TargetManager; @@ -37,6 +39,9 @@ class Template; class Scope { public: typedef base::hash_map<base::StringPiece, Value> KeyValueMap; + // Holds an owning list of scoped_ptrs of Items (since we can't make a vector + // of scoped_ptrs). + typedef ScopedVector< scoped_ptr<Item> > ItemVector; // Allows code to provide values for built-in variables. This class will // automatically register itself on construction and deregister itself on @@ -224,6 +229,26 @@ class Scope { const SourceDir& GetSourceDir() const; void set_source_dir(const SourceDir& d) { source_dir_ = d; } + // The item collector is where Items (Targets, Configs, etc.) go that have + // been defined. If a scope can generate items, this non-owning pointer will + // point to the storage for such items. The creator of this scope will be + // responsible for setting up the collector and then dealing with the + // collected items once execution of the context is complete. + // + // The items in a scope are collected as we go and then dispatched at the end + // of execution of a scope so that we can query the previously-generated + // targets (like getting the outputs). + // + // This can be null if the current scope can not generate items (like for + // imports and such). + // + // When retrieving the collector, the non-const scopes are recursively + // queried. The collector is not copied for closures, etc. + void set_item_collector(ItemVector* collector) { + item_collector_ = collector; + } + ItemVector* GetItemCollector(); + // Properties are opaque pointers that code can use to set state on a Scope // that it can retrieve later. // @@ -283,6 +308,8 @@ class Scope { typedef std::map<std::string, const Template*> TemplateMap; TemplateMap templates_; + ItemVector* item_collector_; + // Opaque pointers. See SetProperty() above. typedef std::map<const void*, void*> PropertyMap; PropertyMap properties_; |