| 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/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/config_values_extractors.h" | 10 #include "tools/gn/config_values_extractors.h" |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 90 } | 90 } |
| 91 } | 91 } |
| 92 } | 92 } |
| 93 return "'2'"; // Default value. | 93 return "'2'"; // Default value. |
| 94 } | 94 } |
| 95 | 95 |
| 96 // Finds all values from the given getter from all configs in the given list, | 96 // Finds all values from the given getter from all configs in the given list, |
| 97 // and adds them to the given result vector. | 97 // and adds them to the given result vector. |
| 98 template<typename T> | 98 template<typename T> |
| 99 void FillConfigListValues( | 99 void FillConfigListValues( |
| 100 const std::vector<const Config*>& configs, | 100 const LabelConfigVector& configs, |
| 101 const std::vector<T>& (ConfigValues::* getter)() const, | 101 const std::vector<T>& (ConfigValues::* getter)() const, |
| 102 std::vector<T>* result) { | 102 std::vector<T>* result) { |
| 103 for (size_t config_i = 0; config_i < configs.size(); config_i++) { | 103 for (size_t config_i = 0; config_i < configs.size(); config_i++) { |
| 104 const std::vector<T>& values = | 104 const std::vector<T>& values = |
| 105 (configs[config_i]->config_values().*getter)(); | 105 (configs[config_i].ptr->config_values().*getter)(); |
| 106 for (size_t val_i = 0; val_i < values.size(); val_i++) | 106 for (size_t val_i = 0; val_i < values.size(); val_i++) |
| 107 result->push_back(values[val_i]); | 107 result->push_back(values[val_i]); |
| 108 } | 108 } |
| 109 } | 109 } |
| 110 | 110 |
| 111 const int kExtraIndent = 2; | 111 const int kExtraIndent = 2; |
| 112 | 112 |
| 113 } // namespace | 113 } // namespace |
| 114 | 114 |
| 115 GypBinaryTargetWriter::Flags::Flags() {} | 115 GypBinaryTargetWriter::Flags::Flags() {} |
| (...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 350 for (size_t i = 0; i < sources.size(); i++) { | 350 for (size_t i = 0; i < sources.size(); i++) { |
| 351 const SourceFile& input_file = sources[i]; | 351 const SourceFile& input_file = sources[i]; |
| 352 Indent(indent + kExtraIndent) << "'" << helper_.GetFileReference(input_file) | 352 Indent(indent + kExtraIndent) << "'" << helper_.GetFileReference(input_file) |
| 353 << "',\n"; | 353 << "',\n"; |
| 354 } | 354 } |
| 355 | 355 |
| 356 Indent(indent) << "],\n"; | 356 Indent(indent) << "],\n"; |
| 357 } | 357 } |
| 358 | 358 |
| 359 void GypBinaryTargetWriter::WriteDeps(const Target* target, int indent) { | 359 void GypBinaryTargetWriter::WriteDeps(const Target* target, int indent) { |
| 360 const std::vector<const Target*>& deps = target->deps(); | 360 const LabelTargetVector& deps = target->deps(); |
| 361 if (deps.empty()) | 361 if (deps.empty()) |
| 362 return; | 362 return; |
| 363 | 363 |
| 364 EscapeOptions escape_options; | 364 EscapeOptions escape_options; |
| 365 escape_options.mode = ESCAPE_JSON; | 365 escape_options.mode = ESCAPE_JSON; |
| 366 | 366 |
| 367 Indent(indent) << "'dependencies': [\n"; | 367 Indent(indent) << "'dependencies': [\n"; |
| 368 for (size_t i = 0; i < deps.size(); i++) { | 368 for (size_t i = 0; i < deps.size(); i++) { |
| 369 Indent(indent + kExtraIndent) << "'"; | 369 Indent(indent + kExtraIndent) << "'"; |
| 370 EscapeStringToStream(out_, helper_.GetFullRefForTarget(deps[i]), | 370 EscapeStringToStream(out_, helper_.GetFullRefForTarget(deps[i].ptr), |
| 371 escape_options); | 371 escape_options); |
| 372 out_ << "',\n"; | 372 out_ << "',\n"; |
| 373 } | 373 } |
| 374 Indent(indent) << "],\n"; | 374 Indent(indent) << "],\n"; |
| 375 } | 375 } |
| 376 | 376 |
| 377 void GypBinaryTargetWriter::WriteIncludeDirs(const Flags& flags, int indent) { | 377 void GypBinaryTargetWriter::WriteIncludeDirs(const Flags& flags, int indent) { |
| 378 if (flags.include_dirs.empty()) | 378 if (flags.include_dirs.empty()) |
| 379 return; | 379 return; |
| 380 | 380 |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 454 ret.lib_dirs.push_back(all_lib_dirs[i]); | 454 ret.lib_dirs.push_back(all_lib_dirs[i]); |
| 455 | 455 |
| 456 const OrderedSet<std::string> all_libs = target->all_libs(); | 456 const OrderedSet<std::string> all_libs = target->all_libs(); |
| 457 for (size_t i = 0; i < all_libs.size(); i++) | 457 for (size_t i = 0; i < all_libs.size(); i++) |
| 458 ret.libs.push_back(all_libs[i]); | 458 ret.libs.push_back(all_libs[i]); |
| 459 | 459 |
| 460 return ret; | 460 return ret; |
| 461 } | 461 } |
| 462 | 462 |
| 463 GypBinaryTargetWriter::Flags GypBinaryTargetWriter::FlagsFromConfigList( | 463 GypBinaryTargetWriter::Flags GypBinaryTargetWriter::FlagsFromConfigList( |
| 464 const std::vector<const Config*>& configs) const { | 464 const LabelConfigVector& configs) const { |
| 465 Flags ret; | 465 Flags ret; |
| 466 | 466 |
| 467 #define EXTRACT(type, name) \ | 467 #define EXTRACT(type, name) \ |
| 468 FillConfigListValues<type>(configs, &ConfigValues::name, &ret.name); | 468 FillConfigListValues<type>(configs, &ConfigValues::name, &ret.name); |
| 469 | 469 |
| 470 EXTRACT(std::string, defines); | 470 EXTRACT(std::string, defines); |
| 471 EXTRACT(SourceDir, include_dirs); | 471 EXTRACT(SourceDir, include_dirs); |
| 472 EXTRACT(std::string, cflags); | 472 EXTRACT(std::string, cflags); |
| 473 EXTRACT(std::string, cflags_c); | 473 EXTRACT(std::string, cflags_c); |
| 474 EXTRACT(std::string, cflags_cc); | 474 EXTRACT(std::string, cflags_cc); |
| 475 EXTRACT(std::string, cflags_objc); | 475 EXTRACT(std::string, cflags_objc); |
| 476 EXTRACT(std::string, cflags_objcc); | 476 EXTRACT(std::string, cflags_objcc); |
| 477 EXTRACT(std::string, ldflags); | 477 EXTRACT(std::string, ldflags); |
| 478 EXTRACT(SourceDir, lib_dirs); | 478 EXTRACT(SourceDir, lib_dirs); |
| 479 EXTRACT(std::string, libs); | 479 EXTRACT(std::string, libs); |
| 480 | 480 |
| 481 #undef EXTRACT | 481 #undef EXTRACT |
| 482 | 482 |
| 483 return ret; | 483 return ret; |
| 484 } | 484 } |
| OLD | NEW |