OLD | NEW |
---|---|
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. To the same for Target.configs_ when a target is resolved. This | |
Dirk Pranke
2015/09/16 21:03:20
typo: "do the same"
| |
42 // will naturally de-dupe and also prevents recursive config walking to | |
43 // compute every possible flag, although it will expand the configs list | |
44 // on a target nontrivially (depending on build configuration). | |
45 composite_values_ = own_values_; | |
46 for (const auto& pair : configs_) | |
47 composite_values_.AppendValues(pair.ptr->resolved_values()); | |
48 } | |
49 return true; | |
50 } | |
OLD | NEW |