blob: fcc5fa6f9630dc2212d47a9bde2d58daa02e9b22 [file] [log] [blame]
[email protected]96ea63d2013-07-30 10:17:071// 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]96ea63d2013-07-30 10:17:079#include "tools/gn/scheduler.h"
10
Dirk Prankec9126ec982017-08-17 15:05:0711Config::Config(const Settings* settings, const Label& label)
12 : Item(settings, label), resolved_(false) {}
[email protected]96ea63d2013-07-30 10:17:0713
14Config::~Config() {
15}
16
17Config* Config::AsConfig() {
18 return this;
19}
20
21const Config* Config::AsConfig() const {
22 return this;
23}
brettwbd144422015-09-16 22:31:3324
25bool 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}