| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/xcode_object.h" | 5 #include "tools/gn/xcode_object.h" |
| 6 | 6 |
| 7 #include <iomanip> | 7 #include <iomanip> |
| 8 #include <sstream> | 8 #include <sstream> |
| 9 #include <utility> | 9 #include <utility> |
| 10 | 10 |
| (...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 237 } // namespace | 237 } // namespace |
| 238 | 238 |
| 239 // PBXObjectClass ------------------------------------------------------------- | 239 // PBXObjectClass ------------------------------------------------------------- |
| 240 | 240 |
| 241 const char* ToString(PBXObjectClass cls) { | 241 const char* ToString(PBXObjectClass cls) { |
| 242 switch (cls) { | 242 switch (cls) { |
| 243 case PBXAggregateTargetClass: | 243 case PBXAggregateTargetClass: |
| 244 return "PBXAggregateTarget"; | 244 return "PBXAggregateTarget"; |
| 245 case PBXBuildFileClass: | 245 case PBXBuildFileClass: |
| 246 return "PBXBuildFile"; | 246 return "PBXBuildFile"; |
| 247 case PBXContainerItemProxyClass: |
| 248 return "PBXContainerItemProxy"; |
| 247 case PBXFileReferenceClass: | 249 case PBXFileReferenceClass: |
| 248 return "PBXFileReference"; | 250 return "PBXFileReference"; |
| 249 case PBXFrameworksBuildPhaseClass: | 251 case PBXFrameworksBuildPhaseClass: |
| 250 return "PBXFrameworksBuildPhase"; | 252 return "PBXFrameworksBuildPhase"; |
| 251 case PBXGroupClass: | 253 case PBXGroupClass: |
| 252 return "PBXGroup"; | 254 return "PBXGroup"; |
| 253 case PBXNativeTargetClass: | 255 case PBXNativeTargetClass: |
| 254 return "PBXNativeTarget"; | 256 return "PBXNativeTarget"; |
| 255 case PBXProjectClass: | 257 case PBXProjectClass: |
| 256 return "PBXProject"; | 258 return "PBXProject"; |
| 257 case PBXShellScriptBuildPhaseClass: | 259 case PBXShellScriptBuildPhaseClass: |
| 258 return "PBXShellScriptBuildPhase"; | 260 return "PBXShellScriptBuildPhase"; |
| 259 case PBXSourcesBuildPhaseClass: | 261 case PBXSourcesBuildPhaseClass: |
| 260 return "PBXSourcesBuildPhase"; | 262 return "PBXSourcesBuildPhase"; |
| 263 case PBXTargetDependencyClass: |
| 264 return "PBXTargetDependency"; |
| 261 case XCBuildConfigurationClass: | 265 case XCBuildConfigurationClass: |
| 262 return "XCBuildConfiguration"; | 266 return "XCBuildConfiguration"; |
| 263 case XCConfigurationListClass: | 267 case XCConfigurationListClass: |
| 264 return "XCConfigurationList"; | 268 return "XCConfigurationList"; |
| 265 } | 269 } |
| 266 NOTREACHED(); | 270 NOTREACHED(); |
| 267 return nullptr; | 271 return nullptr; |
| 268 } | 272 } |
| 269 | 273 |
| 270 // PBXObjectVisitor ----------------------------------------------------------- | 274 // PBXObjectVisitor ----------------------------------------------------------- |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 316 : configurations_(new XCConfigurationList(config_name, attributes, this)), | 320 : configurations_(new XCConfigurationList(config_name, attributes, this)), |
| 317 name_(name) { | 321 name_(name) { |
| 318 if (!shell_script.empty()) { | 322 if (!shell_script.empty()) { |
| 319 build_phases_.push_back( | 323 build_phases_.push_back( |
| 320 base::MakeUnique<PBXShellScriptBuildPhase>(name, shell_script)); | 324 base::MakeUnique<PBXShellScriptBuildPhase>(name, shell_script)); |
| 321 } | 325 } |
| 322 } | 326 } |
| 323 | 327 |
| 324 PBXTarget::~PBXTarget() {} | 328 PBXTarget::~PBXTarget() {} |
| 325 | 329 |
| 330 void PBXTarget::AddDependency(std::unique_ptr<PBXTargetDependency> dependency) { |
| 331 DCHECK(dependency); |
| 332 dependencies_.push_back(std::move(dependency)); |
| 333 } |
| 334 |
| 326 std::string PBXTarget::Name() const { | 335 std::string PBXTarget::Name() const { |
| 327 return name_; | 336 return name_; |
| 328 } | 337 } |
| 329 | 338 |
| 330 void PBXTarget::Visit(PBXObjectVisitor& visitor) { | 339 void PBXTarget::Visit(PBXObjectVisitor& visitor) { |
| 331 PBXObject::Visit(visitor); | 340 PBXObject::Visit(visitor); |
| 332 configurations_->Visit(visitor); | 341 configurations_->Visit(visitor); |
| 333 for (const auto& build_phase : build_phases_) { | 342 for (const auto& dependency : dependencies_) |
| 343 dependency->Visit(visitor); |
| 344 for (const auto& build_phase : build_phases_) |
| 334 build_phase->Visit(visitor); | 345 build_phase->Visit(visitor); |
| 335 } | |
| 336 } | 346 } |
| 337 | 347 |
| 338 // PBXAggregateTarget --------------------------------------------------------- | 348 // PBXAggregateTarget --------------------------------------------------------- |
| 339 | 349 |
| 340 PBXAggregateTarget::PBXAggregateTarget(const std::string& name, | 350 PBXAggregateTarget::PBXAggregateTarget(const std::string& name, |
| 341 const std::string& shell_script, | 351 const std::string& shell_script, |
| 342 const std::string& config_name, | 352 const std::string& config_name, |
| 343 const PBXAttributes& attributes) | 353 const PBXAttributes& attributes) |
| 344 : PBXTarget(name, shell_script, config_name, attributes) {} | 354 : PBXTarget(name, shell_script, config_name, attributes) {} |
| 345 | 355 |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 392 PrintProperty(out, rules, "fileRef", file_reference_); | 402 PrintProperty(out, rules, "fileRef", file_reference_); |
| 393 if (compiler_flag_ == CompilerFlags::HELP) { | 403 if (compiler_flag_ == CompilerFlags::HELP) { |
| 394 std::map<std::string, std::string> settings = { | 404 std::map<std::string, std::string> settings = { |
| 395 {"COMPILER_FLAGS", "--help"}, | 405 {"COMPILER_FLAGS", "--help"}, |
| 396 }; | 406 }; |
| 397 PrintProperty(out, rules, "settings", settings); | 407 PrintProperty(out, rules, "settings", settings); |
| 398 } | 408 } |
| 399 out << "};\n"; | 409 out << "};\n"; |
| 400 } | 410 } |
| 401 | 411 |
| 412 // PBXContainerItemProxy ------------------------------------------------------ |
| 413 PBXContainerItemProxy::PBXContainerItemProxy(const PBXProject* project, |
| 414 const PBXTarget* target) |
| 415 : project_(project), target_(target) {} |
| 416 |
| 417 PBXContainerItemProxy::~PBXContainerItemProxy() {} |
| 418 |
| 419 PBXObjectClass PBXContainerItemProxy::Class() const { |
| 420 return PBXContainerItemProxyClass; |
| 421 } |
| 422 |
| 423 void PBXContainerItemProxy::Visit(PBXObjectVisitor& visitor) { |
| 424 PBXObject::Visit(visitor); |
| 425 } |
| 426 |
| 427 std::string PBXContainerItemProxy::Name() const { |
| 428 return "PBXContainerItemProxy"; |
| 429 } |
| 430 |
| 431 void PBXContainerItemProxy::Print(std::ostream& out, unsigned indent) const { |
| 432 const std::string indent_str(indent, '\t'); |
| 433 const IndentRules rules = {true, 0}; |
| 434 out << indent_str << Reference() << " = {"; |
| 435 PrintProperty(out, rules, "isa", ToString(Class())); |
| 436 PrintProperty(out, rules, "containerPortal", project_); |
| 437 PrintProperty(out, rules, "proxyType", 1u); |
| 438 PrintProperty(out, rules, "remoteGlobalIDString", target_); |
| 439 PrintProperty(out, rules, "remoteInfo", target_->Name()); |
| 440 out << indent_str << "};\n"; |
| 441 } |
| 442 |
| 402 // PBXFileReference ----------------------------------------------------------- | 443 // PBXFileReference ----------------------------------------------------------- |
| 403 | 444 |
| 404 PBXFileReference::PBXFileReference(const std::string& name, | 445 PBXFileReference::PBXFileReference(const std::string& name, |
| 405 const std::string& path, | 446 const std::string& path, |
| 406 const std::string& type) | 447 const std::string& type) |
| 407 : name_(name), path_(path), type_(type) {} | 448 : name_(name), path_(path), type_(type) {} |
| 408 | 449 |
| 409 PBXFileReference::~PBXFileReference() {} | 450 PBXFileReference::~PBXFileReference() {} |
| 410 | 451 |
| 411 PBXObjectClass PBXFileReference::Class() const { | 452 PBXObjectClass PBXFileReference::Class() const { |
| (...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 597 } | 638 } |
| 598 | 639 |
| 599 void PBXNativeTarget::Print(std::ostream& out, unsigned indent) const { | 640 void PBXNativeTarget::Print(std::ostream& out, unsigned indent) const { |
| 600 const std::string indent_str(indent, '\t'); | 641 const std::string indent_str(indent, '\t'); |
| 601 const IndentRules rules = {false, indent + 1}; | 642 const IndentRules rules = {false, indent + 1}; |
| 602 out << indent_str << Reference() << " = {\n"; | 643 out << indent_str << Reference() << " = {\n"; |
| 603 PrintProperty(out, rules, "isa", ToString(Class())); | 644 PrintProperty(out, rules, "isa", ToString(Class())); |
| 604 PrintProperty(out, rules, "buildConfigurationList", configurations_); | 645 PrintProperty(out, rules, "buildConfigurationList", configurations_); |
| 605 PrintProperty(out, rules, "buildPhases", build_phases_); | 646 PrintProperty(out, rules, "buildPhases", build_phases_); |
| 606 PrintProperty(out, rules, "buildRules", EmptyPBXObjectVector()); | 647 PrintProperty(out, rules, "buildRules", EmptyPBXObjectVector()); |
| 607 PrintProperty(out, rules, "dependencies", EmptyPBXObjectVector()); | 648 PrintProperty(out, rules, "dependencies", dependencies_); |
| 608 PrintProperty(out, rules, "name", name_); | 649 PrintProperty(out, rules, "name", name_); |
| 609 PrintProperty(out, rules, "productName", product_name_); | 650 PrintProperty(out, rules, "productName", product_name_); |
| 610 PrintProperty(out, rules, "productReference", product_reference_); | 651 PrintProperty(out, rules, "productReference", product_reference_); |
| 611 PrintProperty(out, rules, "productType", product_type_); | 652 PrintProperty(out, rules, "productType", product_type_); |
| 612 out << indent_str << "};\n"; | 653 out << indent_str << "};\n"; |
| 613 } | 654 } |
| 614 | 655 |
| 615 // PBXProject ----------------------------------------------------------------- | 656 // PBXProject ----------------------------------------------------------------- |
| 616 | 657 |
| 617 PBXProject::PBXProject(const std::string& name, | 658 PBXProject::PBXProject(const std::string& name, |
| (...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 836 const std::string indent_str(indent, '\t'); | 877 const std::string indent_str(indent, '\t'); |
| 837 const IndentRules rules = {false, indent + 1}; | 878 const IndentRules rules = {false, indent + 1}; |
| 838 out << indent_str << Reference() << " = {\n"; | 879 out << indent_str << Reference() << " = {\n"; |
| 839 PrintProperty(out, rules, "isa", ToString(Class())); | 880 PrintProperty(out, rules, "isa", ToString(Class())); |
| 840 PrintProperty(out, rules, "buildActionMask", 0x7fffffffu); | 881 PrintProperty(out, rules, "buildActionMask", 0x7fffffffu); |
| 841 PrintProperty(out, rules, "files", files_); | 882 PrintProperty(out, rules, "files", files_); |
| 842 PrintProperty(out, rules, "runOnlyForDeploymentPostprocessing", 0u); | 883 PrintProperty(out, rules, "runOnlyForDeploymentPostprocessing", 0u); |
| 843 out << indent_str << "};\n"; | 884 out << indent_str << "};\n"; |
| 844 } | 885 } |
| 845 | 886 |
| 887 PBXTargetDependency::PBXTargetDependency( |
| 888 const PBXTarget* target, |
| 889 std::unique_ptr<PBXContainerItemProxy> container_item_proxy) |
| 890 : target_(target), container_item_proxy_(std::move(container_item_proxy)) {} |
| 891 |
| 892 PBXTargetDependency::~PBXTargetDependency() {} |
| 893 |
| 894 PBXObjectClass PBXTargetDependency::Class() const { |
| 895 return PBXTargetDependencyClass; |
| 896 } |
| 897 std::string PBXTargetDependency::Name() const { |
| 898 return "PBXTargetDependency"; |
| 899 } |
| 900 void PBXTargetDependency::Visit(PBXObjectVisitor& visitor) { |
| 901 PBXObject::Visit(visitor); |
| 902 container_item_proxy_->Visit(visitor); |
| 903 } |
| 904 void PBXTargetDependency::Print(std::ostream& out, unsigned indent) const { |
| 905 const std::string indent_str(indent, '\t'); |
| 906 const IndentRules rules = {false, indent + 1}; |
| 907 out << indent_str << Reference() << " = {\n"; |
| 908 PrintProperty(out, rules, "isa", ToString(Class())); |
| 909 PrintProperty(out, rules, "target", target_); |
| 910 PrintProperty(out, rules, "targetProxy", container_item_proxy_); |
| 911 out << indent_str << "};\n"; |
| 912 } |
| 913 |
| 846 // XCBuildConfiguration ------------------------------------------------------- | 914 // XCBuildConfiguration ------------------------------------------------------- |
| 847 | 915 |
| 848 XCBuildConfiguration::XCBuildConfiguration(const std::string& name, | 916 XCBuildConfiguration::XCBuildConfiguration(const std::string& name, |
| 849 const PBXAttributes& attributes) | 917 const PBXAttributes& attributes) |
| 850 : attributes_(attributes), name_(name) {} | 918 : attributes_(attributes), name_(name) {} |
| 851 | 919 |
| 852 XCBuildConfiguration::~XCBuildConfiguration() {} | 920 XCBuildConfiguration::~XCBuildConfiguration() {} |
| 853 | 921 |
| 854 PBXObjectClass XCBuildConfiguration::Class() const { | 922 PBXObjectClass XCBuildConfiguration::Class() const { |
| 855 return XCBuildConfigurationClass; | 923 return XCBuildConfigurationClass; |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 905 const std::string indent_str(indent, '\t'); | 973 const std::string indent_str(indent, '\t'); |
| 906 const IndentRules rules = {false, indent + 1}; | 974 const IndentRules rules = {false, indent + 1}; |
| 907 out << indent_str << Reference() << " = {\n"; | 975 out << indent_str << Reference() << " = {\n"; |
| 908 PrintProperty(out, rules, "isa", ToString(Class())); | 976 PrintProperty(out, rules, "isa", ToString(Class())); |
| 909 PrintProperty(out, rules, "buildConfigurations", configurations_); | 977 PrintProperty(out, rules, "buildConfigurations", configurations_); |
| 910 PrintProperty(out, rules, "defaultConfigurationIsVisible", 1u); | 978 PrintProperty(out, rules, "defaultConfigurationIsVisible", 1u); |
| 911 PrintProperty(out, rules, "defaultConfigurationName", | 979 PrintProperty(out, rules, "defaultConfigurationName", |
| 912 configurations_[0]->Name()); | 980 configurations_[0]->Name()); |
| 913 out << indent_str << "};\n"; | 981 out << indent_str << "};\n"; |
| 914 } | 982 } |
| OLD | NEW |