Index: tools/gn/config.cc |
diff --git a/tools/gn/config.cc b/tools/gn/config.cc |
index dce951f65b33384fec9403cb65176ef6354662d8..c06632449a4634b0c807f010f7e6ff23088f8279 100644 |
--- a/tools/gn/config.cc |
+++ b/tools/gn/config.cc |
@@ -9,7 +9,8 @@ |
#include "tools/gn/scheduler.h" |
Config::Config(const Settings* settings, const Label& label) |
- : Item(settings, label) { |
+ : Item(settings, label), |
+ resolved_(false) { |
} |
Config::~Config() { |
@@ -22,3 +23,29 @@ Config* Config::AsConfig() { |
const Config* Config::AsConfig() const { |
return this; |
} |
+ |
+bool Config::OnResolved(Err* err) { |
+ DCHECK(!resolved_); |
+ resolved_ = true; |
+ |
+ if (!configs_.empty()) { |
+ // Subconfigs, flatten. |
+ // |
+ // Implementation note for the future: Flattening these here means we |
+ // lose the ability to de-dupe subconfigs. If a subconfig is listed as |
+ // a separate config or a subconfig that also applies to the target, the |
+ // subconfig's flags will be duplicated. |
+ // |
+ // If we want to be able to de-dupe these, here's one idea. As a config is |
+ // resolved, inline any sub-sub configs so the configs_ vector is a flat |
+ // list, much the same way that libs and lib_dirs are pushed through |
+ // targets. Do the same for Target.configs_ when a target is resolved. This |
+ // will naturally de-dupe and also prevents recursive config walking to |
+ // compute every possible flag, although it will expand the configs list on |
+ // a target nontrivially (depending on build configuration). |
+ composite_values_ = own_values_; |
+ for (const auto& pair : configs_) |
+ composite_values_.AppendValues(pair.ptr->resolved_values()); |
+ } |
+ return true; |
+} |