Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(42)

Unified Diff: tools/gn/config.cc

Issue 1342183003: Allow GN configs to have sub-configs. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « tools/gn/config.h ('k') | tools/gn/config_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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;
+}
« no previous file with comments | « tools/gn/config.h ('k') | tools/gn/config_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698