Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1)

Side by Side Diff: tools/gn/gyp_binary_target_writer.cc

Issue 56433003: GN threading refactor (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « tools/gn/group_target_generator.cc ('k') | tools/gn/gyp_target_writer.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/gyp_binary_target_writer.h" 5 #include "tools/gn/gyp_binary_target_writer.h"
6 6
7 #include <set> 7 #include <set>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "tools/gn/builder_record.h"
10 #include "tools/gn/config_values_extractors.h" 11 #include "tools/gn/config_values_extractors.h"
11 #include "tools/gn/err.h" 12 #include "tools/gn/err.h"
12 #include "tools/gn/escape.h" 13 #include "tools/gn/escape.h"
13 #include "tools/gn/filesystem_utils.h" 14 #include "tools/gn/filesystem_utils.h"
14 #include "tools/gn/settings.h" 15 #include "tools/gn/settings.h"
15 #include "tools/gn/target.h" 16 #include "tools/gn/target.h"
16 17
17 namespace { 18 namespace {
18 19
19 // This functor is used to capture the output of RecursiveTargetConfigToStream 20 // This functor is used to capture the output of RecursiveTargetConfigToStream
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
111 112
112 const int kExtraIndent = 2; 113 const int kExtraIndent = 2;
113 114
114 } // namespace 115 } // namespace
115 116
116 GypBinaryTargetWriter::Flags::Flags() {} 117 GypBinaryTargetWriter::Flags::Flags() {}
117 GypBinaryTargetWriter::Flags::~Flags() {} 118 GypBinaryTargetWriter::Flags::~Flags() {}
118 119
119 GypBinaryTargetWriter::GypBinaryTargetWriter(const TargetGroup& group, 120 GypBinaryTargetWriter::GypBinaryTargetWriter(const TargetGroup& group,
120 std::ostream& out) 121 std::ostream& out)
121 : GypTargetWriter(group.debug, out), 122 : GypTargetWriter(group.debug->item()->AsTarget(), out),
122 group_(group) { 123 group_(group) {
123 } 124 }
124 125
125 GypBinaryTargetWriter::~GypBinaryTargetWriter() { 126 GypBinaryTargetWriter::~GypBinaryTargetWriter() {
126 } 127 }
127 128
128 void GypBinaryTargetWriter::Run() { 129 void GypBinaryTargetWriter::Run() {
129 int indent = 4; 130 int indent = 4;
130 131
131 Indent(indent) << "{\n"; 132 Indent(indent) << "{\n";
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
186 } 187 }
187 188
188 if (target_->hard_dep()) 189 if (target_->hard_dep())
189 Indent(indent) << "'hard_dependency': 1,\n"; 190 Indent(indent) << "'hard_dependency': 1,\n";
190 } 191 }
191 192
192 void GypBinaryTargetWriter::WriteVCConfiguration(int indent) { 193 void GypBinaryTargetWriter::WriteVCConfiguration(int indent) {
193 Indent(indent) << "'configurations': {\n"; 194 Indent(indent) << "'configurations': {\n";
194 195
195 Indent(indent + kExtraIndent) << "'Debug': {\n"; 196 Indent(indent + kExtraIndent) << "'Debug': {\n";
196 Flags debug_flags(FlagsFromTarget(group_.debug)); 197 Flags debug_flags(FlagsFromTarget(group_.debug->item()->AsTarget()));
197 WriteVCFlags(debug_flags, indent + kExtraIndent * 2); 198 WriteVCFlags(debug_flags, indent + kExtraIndent * 2);
198 Indent(indent + kExtraIndent) << "},\n"; 199 Indent(indent + kExtraIndent) << "},\n";
199 200
200 Indent(indent + kExtraIndent) << "'Release': {\n"; 201 Indent(indent + kExtraIndent) << "'Release': {\n";
201 Flags release_flags(FlagsFromTarget(group_.release)); 202 Flags release_flags(FlagsFromTarget(group_.release->item()->AsTarget()));
202 WriteVCFlags(release_flags, indent + kExtraIndent * 2); 203 WriteVCFlags(release_flags, indent + kExtraIndent * 2);
203 Indent(indent + kExtraIndent) << "},\n"; 204 Indent(indent + kExtraIndent) << "},\n";
204 205
205 Indent(indent + kExtraIndent) << "'Debug_x64': {},\n"; 206 Indent(indent + kExtraIndent) << "'Debug_x64': {},\n";
206 Indent(indent + kExtraIndent) << "'Release_x64': {},\n"; 207 Indent(indent + kExtraIndent) << "'Release_x64': {},\n";
207 Indent(indent) << "},\n"; 208 Indent(indent) << "},\n";
208 209
209 WriteSources(target_, indent); 210 WriteSources(target_, indent);
210 WriteDeps(target_, indent); 211 WriteDeps(target_, indent);
211 } 212 }
212 213
213 void GypBinaryTargetWriter::WriteLinuxConfiguration(int indent) { 214 void GypBinaryTargetWriter::WriteLinuxConfiguration(int indent) {
214 // The Linux stuff works differently. On Linux we support cross-compiles and 215 // The Linux stuff works differently. On Linux we support cross-compiles and
215 // all ninja generators know to look for target conditions. Other platforms' 216 // all ninja generators know to look for target conditions. Other platforms'
216 // generators don't all do this, so we can't have the same GYP structure. 217 // generators don't all do this, so we can't have the same GYP structure.
217 Indent(indent) << "'target_conditions': [\n"; 218 Indent(indent) << "'target_conditions': [\n";
218 // The host toolset is configured for the current computer, we will only have 219 // The host toolset is configured for the current computer, we will only have
219 // this when doing cross-compiles. 220 // this when doing cross-compiles.
220 if (group_.host_debug && group_.host_release) { 221 if (group_.host_debug && group_.host_release) {
221 Indent(indent + kExtraIndent) << "['_toolset == \"host\"', {\n"; 222 Indent(indent + kExtraIndent) << "['_toolset == \"host\"', {\n";
222 Indent(indent + kExtraIndent * 2) << "'configurations': {\n"; 223 Indent(indent + kExtraIndent * 2) << "'configurations': {\n";
223 Indent(indent + kExtraIndent * 3) << "'Debug': {\n"; 224 Indent(indent + kExtraIndent * 3) << "'Debug': {\n";
224 WriteLinuxFlagsForTarget(group_.host_debug, indent + kExtraIndent * 4); 225 WriteLinuxFlagsForTarget(group_.host_debug->item()->AsTarget(),
226 indent + kExtraIndent * 4);
225 Indent(indent + kExtraIndent * 3) << "},\n"; 227 Indent(indent + kExtraIndent * 3) << "},\n";
226 Indent(indent + kExtraIndent * 3) << "'Release': {\n"; 228 Indent(indent + kExtraIndent * 3) << "'Release': {\n";
227 WriteLinuxFlagsForTarget(group_.host_release, indent + kExtraIndent * 4); 229 WriteLinuxFlagsForTarget(group_.host_release->item()->AsTarget(),
230 indent + kExtraIndent * 4);
228 Indent(indent + kExtraIndent * 3) << "},\n"; 231 Indent(indent + kExtraIndent * 3) << "},\n";
229 Indent(indent + kExtraIndent * 2) << "}\n"; 232 Indent(indent + kExtraIndent * 2) << "}\n";
230 233
231 // The sources are per-toolset but shared between debug & release. 234 // The sources are per-toolset but shared between debug & release.
232 WriteSources(group_.host_debug, indent + kExtraIndent * 2); 235 WriteSources(group_.host_debug->item()->AsTarget(),
236 indent + kExtraIndent * 2);
233 237
234 Indent(indent + kExtraIndent) << "],\n"; 238 Indent(indent + kExtraIndent) << "],\n";
235 } 239 }
236 240
237 // The target toolset is the "regular" one. 241 // The target toolset is the "regular" one.
238 Indent(indent + kExtraIndent) << "['_toolset == \"target\"', {\n"; 242 Indent(indent + kExtraIndent) << "['_toolset == \"target\"', {\n";
239 Indent(indent + kExtraIndent * 2) << "'configurations': {\n"; 243 Indent(indent + kExtraIndent * 2) << "'configurations': {\n";
240 Indent(indent + kExtraIndent * 3) << "'Debug': {\n"; 244 Indent(indent + kExtraIndent * 3) << "'Debug': {\n";
241 WriteLinuxFlagsForTarget(group_.debug, indent + kExtraIndent * 4); 245 WriteLinuxFlagsForTarget(group_.debug->item()->AsTarget(),
246 indent + kExtraIndent * 4);
242 Indent(indent + kExtraIndent * 3) << "},\n"; 247 Indent(indent + kExtraIndent * 3) << "},\n";
243 Indent(indent + kExtraIndent * 3) << "'Release': {\n"; 248 Indent(indent + kExtraIndent * 3) << "'Release': {\n";
244 WriteLinuxFlagsForTarget(group_.release, indent + kExtraIndent * 4); 249 WriteLinuxFlagsForTarget(group_.release->item()->AsTarget(),
250 indent + kExtraIndent * 4);
245 Indent(indent + kExtraIndent * 3) << "},\n"; 251 Indent(indent + kExtraIndent * 3) << "},\n";
246 Indent(indent + kExtraIndent * 2) << "},\n"; 252 Indent(indent + kExtraIndent * 2) << "},\n";
247 253
248 WriteSources(target_, indent + kExtraIndent * 2); 254 WriteSources(target_, indent + kExtraIndent * 2);
249 255
250 Indent(indent + kExtraIndent) << "},],\n"; 256 Indent(indent + kExtraIndent) << "},],\n";
251 Indent(indent) << "],\n"; 257 Indent(indent) << "],\n";
252 258
253 // Deps in GYP can not vary based on the toolset. 259 // Deps in GYP can not vary based on the toolset.
254 WriteDeps(target_, indent); 260 WriteDeps(target_, indent);
255 } 261 }
256 262
257 void GypBinaryTargetWriter::WriteMacConfiguration(int indent) { 263 void GypBinaryTargetWriter::WriteMacConfiguration(int indent) {
258 Indent(indent) << "'configurations': {\n"; 264 Indent(indent) << "'configurations': {\n";
259 265
260 Indent(indent + kExtraIndent) << "'Debug': {\n"; 266 Indent(indent + kExtraIndent) << "'Debug': {\n";
261 Flags debug_flags(FlagsFromTarget(group_.debug)); 267 Flags debug_flags(FlagsFromTarget(group_.debug->item()->AsTarget()));
262 WriteMacFlags(debug_flags, indent + kExtraIndent * 2); 268 WriteMacFlags(debug_flags, indent + kExtraIndent * 2);
263 Indent(indent + kExtraIndent) << "},\n"; 269 Indent(indent + kExtraIndent) << "},\n";
264 270
265 Indent(indent + kExtraIndent) << "'Release': {\n"; 271 Indent(indent + kExtraIndent) << "'Release': {\n";
266 Flags release_flags(FlagsFromTarget(group_.release)); 272 Flags release_flags(FlagsFromTarget(group_.release->item()->AsTarget()));
267 WriteMacFlags(release_flags, indent + kExtraIndent * 2); 273 WriteMacFlags(release_flags, indent + kExtraIndent * 2);
268 Indent(indent + kExtraIndent) << "},\n"; 274 Indent(indent + kExtraIndent) << "},\n";
269 275
270 Indent(indent) << "},\n"; 276 Indent(indent) << "},\n";
271 277
272 WriteSources(target_, indent); 278 WriteSources(target_, indent);
273 WriteDeps(target_, indent); 279 WriteDeps(target_, indent);
274 } 280 }
275 281
276 void GypBinaryTargetWriter::WriteVCFlags(Flags& flags, int indent) { 282 void GypBinaryTargetWriter::WriteVCFlags(Flags& flags, int indent) {
(...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after
560 EXTRACT(std::string, cflags_objc); 566 EXTRACT(std::string, cflags_objc);
561 EXTRACT(std::string, cflags_objcc); 567 EXTRACT(std::string, cflags_objcc);
562 EXTRACT(std::string, ldflags); 568 EXTRACT(std::string, ldflags);
563 EXTRACT(SourceDir, lib_dirs); 569 EXTRACT(SourceDir, lib_dirs);
564 EXTRACT(std::string, libs); 570 EXTRACT(std::string, libs);
565 571
566 #undef EXTRACT 572 #undef EXTRACT
567 573
568 return ret; 574 return ret;
569 } 575 }
OLDNEW
« no previous file with comments | « tools/gn/group_target_generator.cc ('k') | tools/gn/gyp_target_writer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698