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 #ifndef TOOLS_GN_BUILD_SETTINGS_H_ | 5 #ifndef TOOLS_GN_BUILD_SETTINGS_H_ |
6 #define TOOLS_GN_BUILD_SETTINGS_H_ | 6 #define TOOLS_GN_BUILD_SETTINGS_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
11 #include "base/callback.h" | 11 #include "base/callback.h" |
12 #include "base/files/file_path.h" | 12 #include "base/files/file_path.h" |
13 #include "tools/gn/args.h" | 13 #include "tools/gn/args.h" |
14 #include "tools/gn/item_tree.h" | 14 #include "tools/gn/item_tree.h" |
15 #include "tools/gn/scope.h" | 15 #include "tools/gn/scope.h" |
16 #include "tools/gn/source_dir.h" | 16 #include "tools/gn/source_dir.h" |
17 #include "tools/gn/source_file.h" | 17 #include "tools/gn/source_file.h" |
18 #include "tools/gn/target_manager.h" | 18 #include "tools/gn/target_manager.h" |
19 #include "tools/gn/toolchain_manager.h" | 19 #include "tools/gn/toolchain_manager.h" |
20 | 20 |
21 class OutputFile; | 21 class OutputFile; |
22 | 22 |
23 // Settings for one build, which is one toplevel output directory. There | 23 // Settings for one build, which is one toplevel output directory. There |
24 // may be multiple Settings objects that refer to this, one for each toolchain. | 24 // may be multiple Settings objects that refer to this, one for each toolchain. |
25 class BuildSettings { | 25 class BuildSettings { |
26 public: | 26 public: |
27 typedef base::Callback<void(const Target*)> TargetResolvedCallback; | 27 typedef base::Callback<void(const Target*)> TargetResolvedCallback; |
28 typedef std::multimap<Label, OutputFile> AdditionalLibsMap; | |
29 | 28 |
30 BuildSettings(); | 29 BuildSettings(); |
| 30 BuildSettings(const BuildSettings& other); |
31 ~BuildSettings(); | 31 ~BuildSettings(); |
32 | 32 |
33 // Absolute path of the source root on the local system. Everything is | 33 // Absolute path of the source root on the local system. Everything is |
34 // relative to this. Does not end in a [back]slash. | 34 // relative to this. Does not end in a [back]slash. |
35 const base::FilePath& root_path() const { return root_path_; } | 35 const base::FilePath& root_path() const { return root_path_; } |
36 const std::string& root_path_utf8() const { return root_path_utf8_; } | 36 const std::string& root_path_utf8() const { return root_path_utf8_; } |
37 void SetRootPath(const base::FilePath& r); | 37 void SetRootPath(const base::FilePath& r); |
38 | 38 |
39 // When nonempty, specifies a parallel directory higherarchy in which to | 39 // When nonempty, specifies a parallel directory higherarchy in which to |
40 // search for buildfiles if they're not found in the root higherarchy. This | 40 // search for buildfiles if they're not found in the root higherarchy. This |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
99 // don't need to do anything, this will be null. When a target is resolved, | 99 // don't need to do anything, this will be null. When a target is resolved, |
100 // this callback should be posted to the scheduler pool so the work is | 100 // this callback should be posted to the scheduler pool so the work is |
101 // distributed properly. | 101 // distributed properly. |
102 const TargetResolvedCallback& target_resolved_callback() const { | 102 const TargetResolvedCallback& target_resolved_callback() const { |
103 return target_resolved_callback_; | 103 return target_resolved_callback_; |
104 } | 104 } |
105 void set_target_resolved_callback(const TargetResolvedCallback& cb) { | 105 void set_target_resolved_callback(const TargetResolvedCallback& cb) { |
106 target_resolved_callback_ = cb; | 106 target_resolved_callback_ = cb; |
107 } | 107 } |
108 | 108 |
109 // When using_external_generator is set, this will be populated with | |
110 // known linker dependencies for each target. The mapping is from .ninja | |
111 // files to library (.a, .so, .dll, etc.) files needed by that target. | |
112 // | |
113 // When generating a GN binary that depends on some GYP-generated targets, | |
114 // we need to know the GYP target's recursive set of libraries so we can in | |
115 // turn link them into the final binary. | |
116 AdditionalLibsMap& external_link_deps() { return external_link_deps_; } | |
117 const AdditionalLibsMap& external_link_deps() const { | |
118 return external_link_deps_; | |
119 } | |
120 | |
121 private: | 109 private: |
122 base::FilePath root_path_; | 110 base::FilePath root_path_; |
123 std::string root_path_utf8_; | 111 std::string root_path_utf8_; |
124 base::FilePath secondary_source_path_; | 112 base::FilePath secondary_source_path_; |
125 bool using_external_generator_; | 113 bool using_external_generator_; |
126 base::FilePath python_path_; | 114 base::FilePath python_path_; |
127 | 115 |
128 SourceFile build_config_file_; | 116 SourceFile build_config_file_; |
129 SourceDir build_dir_; | 117 SourceDir build_dir_; |
130 std::string build_to_source_dir_string_; | 118 std::string build_to_source_dir_string_; |
131 Args build_args_; | 119 Args build_args_; |
132 AdditionalLibsMap external_link_deps_; | |
133 | 120 |
134 TargetResolvedCallback target_resolved_callback_; | 121 TargetResolvedCallback target_resolved_callback_; |
135 | 122 |
136 // See getters above. | 123 // See getters above. |
137 mutable ItemTree item_tree_; | 124 mutable ItemTree item_tree_; |
138 mutable TargetManager target_manager_; | 125 mutable TargetManager target_manager_; |
139 mutable ToolchainManager toolchain_manager_; | 126 mutable ToolchainManager toolchain_manager_; |
140 | 127 |
141 DISALLOW_COPY_AND_ASSIGN(BuildSettings); | 128 BuildSettings& operator=(const BuildSettings& other); // Disallow. |
142 }; | 129 }; |
143 | 130 |
144 #endif // TOOLS_GN_BUILD_SETTINGS_H_ | 131 #endif // TOOLS_GN_BUILD_SETTINGS_H_ |
OLD | NEW |