Chromium Code Reviews| Index: tools/gn/config.h |
| diff --git a/tools/gn/config.h b/tools/gn/config.h |
| index 543d660418776b4d35e281c7e53f9b8c56837b25..26a858dc77954129d7f2050f3244b1269a095372 100644 |
| --- a/tools/gn/config.h |
| +++ b/tools/gn/config.h |
| @@ -5,24 +5,59 @@ |
| #ifndef TOOLS_GN_CONFIG_H_ |
| #define TOOLS_GN_CONFIG_H_ |
| +#include "base/logging.h" |
| #include "base/macros.h" |
| #include "tools/gn/config_values.h" |
| #include "tools/gn/item.h" |
| +#include "tools/gn/label_ptr.h" |
| +#include "tools/gn/unique_vector.h" |
| // Represents a named config in the dependency graph. |
| +// |
| +// A config can contain other configs. We track both the data assigned directly |
|
Dirk Pranke
2015/09/15 21:31:31
"contain" seems like a confusing way to describe t
|
| +// on the config, this list of sub-configs, and (when the config is resolved) |
| +// the resulting values of everything merged together. This prevents us from |
| +// having to do a complicated recursive walk of configs to compute a target's |
| +// flags. |
|
Dirk Pranke
2015/09/15 21:31:31
I don't think I understand this sentence; aren't y
|
| class Config : public Item { |
| public: |
| Config(const Settings* settings, const Label& label); |
| ~Config() override; |
| + // Item implementation. |
| Config* AsConfig() override; |
| const Config* AsConfig() const override; |
| + bool OnResolved(Err* err) override; |
| - ConfigValues& config_values() { return config_values_; } |
| - const ConfigValues& config_values() const { return config_values_; } |
| + // The values set directly on this config. This will not contain datra from |
|
Dirk Pranke
2015/09/15 21:31:31
typo: "data"
|
| + // sub-configs. |
| + ConfigValues& own_values() { return own_values_; } |
| + const ConfigValues& own_values() const { return own_values_; } |
| + |
| + // The values that represent this config and all sub-configs combined into |
| + // one. This is only valid after the config is resolved (when we know the |
| + // contents of the sub-configs). |
| + const ConfigValues& resolved_values() const { |
| + DCHECK(resolved_); |
| + if (configs_.empty()) // No sub configs, just use the regular values. |
| + return own_values_; |
| + return composite_values_; |
| + } |
| + |
| + // List of sub-configs. |
| + const UniqueVector<LabelConfigPair>& configs() const { return configs_; } |
| + UniqueVector<LabelConfigPair>& configs() { return configs_; } |
| private: |
| - ConfigValues config_values_; |
| + ConfigValues own_values_; |
| + |
| + // Contains the own_values combined with sub-configs. Most configs don't have |
| + // sub-configs. So as an optimization, this is not populated if there are no |
| + // items in configs_. The resolved_values() getter handles this. |
| + bool resolved_; |
| + ConfigValues composite_values_; |
| + |
| + UniqueVector<LabelConfigPair> configs_; |
| DISALLOW_COPY_AND_ASSIGN(Config); |
| }; |