• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 "gn/config.h"
6 
7 #include "gn/err.h"
8 #include "gn/input_file_manager.h"
9 #include "gn/scheduler.h"
10 
Config(const Settings * settings,const Label & label,const SourceFileSet & build_dependency_files)11 Config::Config(const Settings* settings,
12                const Label& label,
13                const SourceFileSet& build_dependency_files)
14     : Item(settings, label, build_dependency_files) {}
15 
16 Config::~Config() = default;
17 
AsConfig()18 Config* Config::AsConfig() {
19   return this;
20 }
21 
AsConfig() const22 const Config* Config::AsConfig() const {
23   return this;
24 }
25 
OnResolved(Err * err)26 bool Config::OnResolved(Err* err) {
27   DCHECK(!resolved_);
28   resolved_ = true;
29 
30   if (!configs_.empty()) {
31     // Subconfigs, flatten.
32     //
33     // Implementation note for the future: Flattening these here means we
34     // lose the ability to de-dupe subconfigs. If a subconfig is listed as
35     // a separate config or a subconfig that also applies to the target, the
36     // subconfig's flags will be duplicated.
37     //
38     // If we want to be able to de-dupe these, here's one idea. As a config is
39     // resolved, inline any sub-sub configs so the configs_ vector is a flat
40     // list, much the same way that libs and lib_dirs are pushed through
41     // targets. Do the same for Target.configs_ when a target is resolved. This
42     // will naturally de-dupe and also prevents recursive config walking to
43     // compute every possible flag, although it will expand the configs list on
44     // 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 }
51