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

Side by Side 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 unified diff | Download patch
« no previous file with comments | « tools/gn/config.h ('k') | tools/gn/config_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "tools/gn/config.h" 5 #include "tools/gn/config.h"
6 6
7 #include "tools/gn/err.h" 7 #include "tools/gn/err.h"
8 #include "tools/gn/input_file_manager.h" 8 #include "tools/gn/input_file_manager.h"
9 #include "tools/gn/scheduler.h" 9 #include "tools/gn/scheduler.h"
10 10
11 Config::Config(const Settings* settings, const Label& label) 11 Config::Config(const Settings* settings, const Label& label)
12 : Item(settings, label) { 12 : Item(settings, label),
13 resolved_(false) {
13 } 14 }
14 15
15 Config::~Config() { 16 Config::~Config() {
16 } 17 }
17 18
18 Config* Config::AsConfig() { 19 Config* Config::AsConfig() {
19 return this; 20 return this;
20 } 21 }
21 22
22 const Config* Config::AsConfig() const { 23 const Config* Config::AsConfig() const {
23 return this; 24 return this;
24 } 25 }
26
27 bool Config::OnResolved(Err* err) {
28 DCHECK(!resolved_);
29 resolved_ = true;
30
31 if (!configs_.empty()) {
32 // Subconfigs, flatten.
33 //
34 // Implementation note for the future: Flattening these here means we
35 // lose the ability to de-dupe subconfigs. If a subconfig is listed as
36 // a separate config or a subconfig that also applies to the target, the
37 // subconfig's flags will be duplicated.
38 //
39 // If we want to be able to de-dupe these, here's one idea. As a config is
40 // resolved, inline any sub-sub configs so the configs_ vector is a flat
41 // list, much the same way that libs and lib_dirs are pushed through
42 // targets. Do the same for Target.configs_ when a target is resolved. This
43 // will naturally de-dupe and also prevents recursive config walking to
44 // compute every possible flag, although it will expand the configs list on
45 // a target nontrivially (depending on build configuration).
46 composite_values_ = own_values_;
47 for (const auto& pair : configs_)
48 composite_values_.AppendValues(pair.ptr->resolved_values());
49 }
50 return true;
51 }
OLDNEW
« 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