[email protected] | 96ea63d | 2013-07-30 10:17:07 | [diff] [blame] | 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 |
| 3 | // found in the LICENSE file. |
| 4 | |
| 5 | #include "tools/gn/config.h" |
| 6 | |
| 7 | #include "tools/gn/err.h" |
| 8 | #include "tools/gn/input_file_manager.h" |
[email protected] | 96ea63d | 2013-07-30 10:17:07 | [diff] [blame] | 9 | #include "tools/gn/scheduler.h" |
| 10 | |
Dirk Pranke | c9126ec98 | 2017-08-17 15:05:07 | [diff] [blame^] | 11 | Config::Config(const Settings* settings, const Label& label) |
| 12 | : Item(settings, label), resolved_(false) {} |
[email protected] | 96ea63d | 2013-07-30 10:17:07 | [diff] [blame] | 13 | |
| 14 | Config::~Config() { |
| 15 | } |
| 16 | |
| 17 | Config* Config::AsConfig() { |
| 18 | return this; |
| 19 | } |
| 20 | |
| 21 | const Config* Config::AsConfig() const { |
| 22 | return this; |
| 23 | } |
brettw | bd14442 | 2015-09-16 22:31:33 | [diff] [blame] | 24 | |
| 25 | bool Config::OnResolved(Err* err) { |
| 26 | DCHECK(!resolved_); |
| 27 | resolved_ = true; |
| 28 | |
| 29 | if (!configs_.empty()) { |
| 30 | // Subconfigs, flatten. |
| 31 | // |
| 32 | // Implementation note for the future: Flattening these here means we |
| 33 | // lose the ability to de-dupe subconfigs. If a subconfig is listed as |
| 34 | // a separate config or a subconfig that also applies to the target, the |
| 35 | // subconfig's flags will be duplicated. |
| 36 | // |
| 37 | // If we want to be able to de-dupe these, here's one idea. As a config is |
| 38 | // resolved, inline any sub-sub configs so the configs_ vector is a flat |
| 39 | // list, much the same way that libs and lib_dirs are pushed through |
| 40 | // targets. Do the same for Target.configs_ when a target is resolved. This |
| 41 | // will naturally de-dupe and also prevents recursive config walking to |
| 42 | // compute every possible flag, although it will expand the configs list on |
| 43 | // a target nontrivially (depending on build configuration). |
| 44 | composite_values_ = own_values_; |
| 45 | for (const auto& pair : configs_) |
| 46 | composite_values_.AppendValues(pair.ptr->resolved_values()); |
| 47 | } |
| 48 | return true; |
| 49 | } |