Index: tools/gn/target.h |
diff --git a/tools/gn/target.h b/tools/gn/target.h |
index ef194f87f73f8a34c089d0949d1b7a385a5c1522..40f1e969616cea8a97e49c4359c0f37e303828c0 100644 |
--- a/tools/gn/target.h |
+++ b/tools/gn/target.h |
@@ -125,16 +125,20 @@ class Target : public Item { |
output_type_ == COPY_FILES; |
} |
- // Linked dependencies. |
- const LabelTargetVector& deps() const { return deps_; } |
- LabelTargetVector& deps() { return deps_; } |
+ // Linked private dependencies. |
+ const LabelTargetVector& private_deps() const { return private_deps_; } |
+ LabelTargetVector& private_deps() { return private_deps_; } |
+ |
+ // Linked public dependencies. |
+ const LabelTargetVector& public_deps() const { return public_deps_; } |
+ LabelTargetVector& public_deps() { return public_deps_; } |
// Non-linked dependencies. |
- const LabelTargetVector& datadeps() const { return datadeps_; } |
- LabelTargetVector& datadeps() { return datadeps_; } |
+ const LabelTargetVector& data_deps() const { return data_deps_; } |
+ LabelTargetVector& data_deps() { return data_deps_; } |
// List of configs that this class inherits settings from. Once a target is |
- // resolved, this will also list all- and direct-dependent configs. |
+ // resolved, this will also list all-dependent and public configs. |
const UniqueVector<LabelConfigPair>& configs() const { return configs_; } |
UniqueVector<LabelConfigPair>& configs() { return configs_; } |
@@ -149,16 +153,16 @@ class Target : public Item { |
} |
// List of configs that targets depending directly on this one get. These |
- // configs are not added to this target. |
- const UniqueVector<LabelConfigPair>& direct_dependent_configs() const { |
- return direct_dependent_configs_; |
+ // configs are also added to this target. |
+ const UniqueVector<LabelConfigPair>& public_configs() const { |
+ return public_configs_; |
} |
- UniqueVector<LabelConfigPair>& direct_dependent_configs() { |
- return direct_dependent_configs_; |
+ UniqueVector<LabelConfigPair>& public_configs() { |
+ return public_configs_; |
} |
- // A list of a subset of deps where we'll re-export direct_dependent_configs |
- // as direct_dependent_configs of this target. |
+ // A list of a subset of deps where we'll re-export public_configs as |
+ // public_configs of this target. |
const UniqueVector<LabelTargetPair>& forward_dependent_configs() const { |
return forward_dependent_configs_; |
} |
@@ -224,8 +228,6 @@ class Target : public Item { |
} |
private: |
- void ExpandGroups(); |
- |
// Pulls necessary information from dependencies to this one when all |
// dependencies have been resolved. |
void PullDependentTargetInfo(); |
@@ -233,6 +235,7 @@ class Target : public Item { |
// These each pull specific things from dependencies to this one when all |
// deps have been resolved. |
void PullForwardedDependentConfigs(); |
+ void PullForwardedDependentConfigsFrom(const Target* from); |
void PullRecursiveHardDeps(); |
// Fills the link and dependency output files when a target is resolved. |
@@ -257,23 +260,13 @@ class Target : public Item { |
bool hard_dep_; |
- // Note that if there are any groups in the deps, once the target is resolved |
- // these vectors will list *both* the groups as well as the groups' deps. |
- // |
- // This is because, in general, groups should be "transparent" ways to add |
- // groups of dependencies, so adding the groups deps make this happen with |
- // no additional complexity when iterating over a target's deps. |
- // |
- // However, a group may also have specific settings and configs added to it, |
- // so we also need the group in the list so we find these things. But you |
- // shouldn't need to look inside the deps of the group since those will |
- // already be added. |
- LabelTargetVector deps_; |
- LabelTargetVector datadeps_; |
+ LabelTargetVector private_deps_; |
+ LabelTargetVector public_deps_; |
+ LabelTargetVector data_deps_; |
UniqueVector<LabelConfigPair> configs_; |
UniqueVector<LabelConfigPair> all_dependent_configs_; |
- UniqueVector<LabelConfigPair> direct_dependent_configs_; |
+ UniqueVector<LabelConfigPair> public_configs_; |
UniqueVector<LabelTargetPair> forward_dependent_configs_; |
std::set<Label> allow_circular_includes_from_; |
@@ -309,6 +302,54 @@ class Target : public Item { |
DISALLOW_COPY_AND_ASSIGN(Target); |
}; |
+// Iterates over the deps of a target. |
+// |
+// Since there are multiple kinds of deps, this iterator allows looping over |
+// each one in one loop. |
+class DepsIterator { |
jamesr
2014/09/16 20:09:25
imho this should get its own .h/.cc
|
+ public: |
+ enum LinkedOnly { |
+ LINKED_ONLY, |
+ }; |
+ |
+ // Iterate over public, private, and data deps. |
+ explicit DepsIterator(const Target* t); |
+ |
+ // Iterate over the public and private linked deps, but not the data deps. |
+ DepsIterator(const Target* t, LinkedOnly); |
+ |
+ // Returns true when there are no more targets. |
+ bool done() const { |
+ return !vect_stack_[0]; |
+ } |
+ |
+ // Advance to the next position. This assumes there are more vectors. |
jamesr
2014/09/16 20:09:25
'more vectors' -> 'more targets' ?
|
+ // |
+ // For internal use, this function tolerates an initial index equal to the |
+ // length of the current vector. In this case, it will advance to the next |
+ // one. |
+ void Advance(); |
+ |
+ // The current dependency. |
+ const LabelTargetPair& pair() const { |
+ DCHECK(current_index_ < vect_stack_[0]->size()); |
jamesr
2014/09/16 20:09:25
DCHECK_LT will print the lhs and rhs when the asse
|
+ return (*vect_stack_[0])[current_index_]; |
+ } |
+ |
+ // The pointer to the current dependency. |
+ const Target* target() const { return pair().ptr; } |
+ |
+ // The label of the current dependency. |
+ const Label& label() const { return pair().label; } |
+ |
+ private: |
+ const LabelTargetVector* vect_stack_[3]; |
+ |
+ size_t current_index_; |
+ |
+ DISALLOW_COPY_AND_ASSIGN(DepsIterator); |
+}; |
+ |
namespace BASE_HASH_NAMESPACE { |
#if defined(COMPILER_GCC) |