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/item_node.h" | 9 #include "tools/gn/item_node.h" |
10 #include "tools/gn/item_tree.h" | 10 #include "tools/gn/item_tree.h" |
11 #include "tools/gn/scheduler.h" | 11 #include "tools/gn/scheduler.h" |
12 | 12 |
13 Config::Config(const Label& label) : Item(label) { | 13 Config::Config(const Settings* settings, const Label& label) |
| 14 : Item(settings, label) { |
14 } | 15 } |
15 | 16 |
16 Config::~Config() { | 17 Config::~Config() { |
17 } | 18 } |
18 | 19 |
19 Config* Config::AsConfig() { | 20 Config* Config::AsConfig() { |
20 return this; | 21 return this; |
21 } | 22 } |
22 | 23 |
23 const Config* Config::AsConfig() const { | 24 const Config* Config::AsConfig() const { |
24 return this; | 25 return this; |
25 } | 26 } |
26 | 27 |
27 // static | 28 // static |
28 Config* Config::GetConfig(const Settings* settings, | 29 Config* Config::GetConfig(const Settings* settings, |
29 const LocationRange& specified_from_here, | 30 const LocationRange& specified_from_here, |
30 const Label& label, | 31 const Label& label, |
31 Item* dep_from, | 32 Item* dep_from, |
32 Err* err) { | 33 Err* err) { |
33 DCHECK(!label.is_null()); | 34 DCHECK(!label.is_null()); |
34 | 35 |
35 ItemTree* tree = &settings->build_settings()->item_tree(); | 36 ItemTree* tree = &settings->build_settings()->item_tree(); |
36 base::AutoLock lock(tree->lock()); | 37 base::AutoLock lock(tree->lock()); |
37 | 38 |
38 ItemNode* node = tree->GetExistingNodeLocked(label); | 39 ItemNode* node = tree->GetExistingNodeLocked(label); |
39 Config* config = NULL; | 40 Config* config = NULL; |
40 if (!node) { | 41 if (!node) { |
41 config = new Config(label); | 42 config = new Config(settings, label); |
42 node = new ItemNode(config); | 43 node = new ItemNode(config); |
43 node->set_originally_referenced_from_here(specified_from_here); | 44 node->set_originally_referenced_from_here(specified_from_here); |
44 tree->AddNodeLocked(node); | 45 tree->AddNodeLocked(node); |
45 | 46 |
46 // Only schedule loading the given target if somebody is depending on it | 47 // Only schedule loading the given target if somebody is depending on it |
47 // (and we optimize by not re-asking it to run the current file). | 48 // (and we optimize by not re-asking it to run the current file). |
48 // Otherwise, we're probably generating it right now. | 49 // Otherwise, we're probably generating it right now. |
49 if (dep_from && dep_from->label().dir() != label.dir()) { | 50 if (dep_from && dep_from->label().dir() != label.dir()) { |
50 settings->build_settings()->toolchain_manager().ScheduleInvocationLocked( | 51 settings->build_settings()->toolchain_manager().ScheduleInvocationLocked( |
51 specified_from_here, label.GetToolchainLabel(), label.dir(), | 52 specified_from_here, label.GetToolchainLabel(), label.dir(), |
(...skipping 20 matching lines...) Expand all Loading... |
72 | 73 |
73 // Keep a record of the guy asking us for this dependency. We know if | 74 // Keep a record of the guy asking us for this dependency. We know if |
74 // somebody is adding a dependency, that guy it himself not resolved. | 75 // somebody is adding a dependency, that guy it himself not resolved. |
75 if (dep_from) { | 76 if (dep_from) { |
76 if (!dep_from->item_node()->AddDependency( | 77 if (!dep_from->item_node()->AddDependency( |
77 settings->build_settings(), specified_from_here, node, err)) | 78 settings->build_settings(), specified_from_here, node, err)) |
78 return NULL; | 79 return NULL; |
79 } | 80 } |
80 return config; | 81 return config; |
81 } | 82 } |
OLD | NEW |