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 594 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
605 sources_->set_is_source(true); | 605 sources_->set_is_source(true); |
606 products_ = static_cast<PBXGroup*>(main_group_->AddChild( | 606 products_ = static_cast<PBXGroup*>(main_group_->AddChild( |
607 base::MakeUnique<PBXGroup>(std::string(), "Product"))); | 607 base::MakeUnique<PBXGroup>(std::string(), "Product"))); |
608 main_group_->AddChild(base::MakeUnique<PBXGroup>(std::string(), "Build")); | 608 main_group_->AddChild(base::MakeUnique<PBXGroup>(std::string(), "Build")); |
609 | 609 |
610 configurations_.reset(new XCConfigurationList(config_name, attributes, this)); | 610 configurations_.reset(new XCConfigurationList(config_name, attributes, this)); |
611 } | 611 } |
612 | 612 |
613 PBXProject::~PBXProject() {} | 613 PBXProject::~PBXProject() {} |
614 | 614 |
| 615 void PBXProject::AddSourceFileToIndexingTarget( |
| 616 const std::string& navigator_path, |
| 617 const std::string& source_path) { |
| 618 if (!target_for_indexing_) { |
| 619 AddIndexingTarget(); |
| 620 } |
| 621 AddSourceFile(navigator_path, source_path, target_for_indexing_); |
| 622 } |
| 623 |
615 void PBXProject::AddSourceFile(const std::string& navigator_path, | 624 void PBXProject::AddSourceFile(const std::string& navigator_path, |
616 const std::string& source_path) { | 625 const std::string& source_path, |
| 626 PBXNativeTarget* target) { |
617 PBXFileReference* file_reference = | 627 PBXFileReference* file_reference = |
618 sources_->AddSourceFile(navigator_path, source_path); | 628 sources_->AddSourceFile(navigator_path, source_path); |
619 base::StringPiece ext = FindExtension(&source_path); | 629 base::StringPiece ext = FindExtension(&source_path); |
620 if (!IsSourceFileForIndexing(ext)) | 630 if (!IsSourceFileForIndexing(ext)) |
621 return; | 631 return; |
622 | 632 |
623 if (!target_for_indexing_) { | 633 DCHECK(target); |
624 PBXAttributes attributes; | 634 target->AddFileForIndexing(file_reference); |
625 attributes["EXECUTABLE_PREFIX"] = ""; | |
626 attributes["HEADER_SEARCH_PATHS"] = sources_->path(); | |
627 attributes["PRODUCT_NAME"] = name_; | |
628 | |
629 PBXFileReference* product_reference = static_cast<PBXFileReference*>( | |
630 products_->AddChild(base::MakeUnique<PBXFileReference>( | |
631 std::string(), name_, "compiled.mach-o.executable"))); | |
632 | |
633 const char product_type[] = "com.apple.product-type.tool"; | |
634 targets_.push_back(base::MakeUnique<PBXNativeTarget>( | |
635 name_, std::string(), config_name_, attributes, product_type, name_, | |
636 product_reference)); | |
637 target_for_indexing_ = static_cast<PBXNativeTarget*>(targets_.back().get()); | |
638 } | |
639 | |
640 DCHECK(target_for_indexing_); | |
641 target_for_indexing_->AddFileForIndexing(file_reference); | |
642 } | 635 } |
643 | 636 |
644 void PBXProject::AddAggregateTarget(const std::string& name, | 637 void PBXProject::AddAggregateTarget(const std::string& name, |
645 const std::string& shell_script) { | 638 const std::string& shell_script) { |
646 PBXAttributes attributes; | 639 PBXAttributes attributes; |
647 attributes["CODE_SIGNING_REQUIRED"] = "NO"; | 640 attributes["CODE_SIGNING_REQUIRED"] = "NO"; |
648 attributes["CONFIGURATION_BUILD_DIR"] = "."; | 641 attributes["CONFIGURATION_BUILD_DIR"] = "."; |
649 attributes["PRODUCT_NAME"] = name; | 642 attributes["PRODUCT_NAME"] = name; |
650 | 643 |
651 targets_.push_back(base::MakeUnique<PBXAggregateTarget>( | 644 targets_.push_back(base::MakeUnique<PBXAggregateTarget>( |
652 name, shell_script, config_name_, attributes)); | 645 name, shell_script, config_name_, attributes)); |
653 } | 646 } |
654 | 647 |
| 648 void PBXProject::AddIndexingTarget() { |
| 649 DCHECK(!target_for_indexing_); |
| 650 PBXAttributes attributes; |
| 651 attributes["EXECUTABLE_PREFIX"] = ""; |
| 652 attributes["HEADER_SEARCH_PATHS"] = sources_->path(); |
| 653 attributes["PRODUCT_NAME"] = name_; |
| 654 |
| 655 PBXFileReference* product_reference = static_cast<PBXFileReference*>( |
| 656 products_->AddChild(base::MakeUnique<PBXFileReference>( |
| 657 std::string(), name_, "compiled.mach-o.executable"))); |
| 658 |
| 659 const char product_type[] = "com.apple.product-type.tool"; |
| 660 targets_.push_back(base::MakeUnique<PBXNativeTarget>( |
| 661 name_, std::string(), config_name_, attributes, product_type, name_, |
| 662 product_reference)); |
| 663 target_for_indexing_ = static_cast<PBXNativeTarget*>(targets_.back().get()); |
| 664 } |
| 665 |
655 void PBXProject::AddNativeTarget(const std::string& name, | 666 void PBXProject::AddNativeTarget(const std::string& name, |
656 const std::string& type, | 667 const std::string& type, |
657 const std::string& output_name, | 668 const std::string& output_name, |
658 const std::string& output_type, | 669 const std::string& output_type, |
659 const std::string& shell_script) { | 670 const std::string& shell_script) { |
660 base::StringPiece ext = FindExtension(&output_name); | 671 base::StringPiece ext = FindExtension(&output_name); |
661 PBXFileReference* product = static_cast<PBXFileReference*>( | 672 PBXFileReference* product = static_cast<PBXFileReference*>( |
662 products_->AddChild(base::MakeUnique<PBXFileReference>( | 673 products_->AddChild(base::MakeUnique<PBXFileReference>( |
663 std::string(), output_name, | 674 std::string(), output_name, |
664 type.empty() ? GetSourceType(ext) : type))); | 675 type.empty() ? GetSourceType(ext) : type))); |
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
866 const std::string indent_str(indent, '\t'); | 877 const std::string indent_str(indent, '\t'); |
867 const IndentRules rules = {false, indent + 1}; | 878 const IndentRules rules = {false, indent + 1}; |
868 out << indent_str << Reference() << " = {\n"; | 879 out << indent_str << Reference() << " = {\n"; |
869 PrintProperty(out, rules, "isa", ToString(Class())); | 880 PrintProperty(out, rules, "isa", ToString(Class())); |
870 PrintProperty(out, rules, "buildConfigurations", configurations_); | 881 PrintProperty(out, rules, "buildConfigurations", configurations_); |
871 PrintProperty(out, rules, "defaultConfigurationIsVisible", 1u); | 882 PrintProperty(out, rules, "defaultConfigurationIsVisible", 1u); |
872 PrintProperty(out, rules, "defaultConfigurationName", | 883 PrintProperty(out, rules, "defaultConfigurationName", |
873 configurations_[0]->Name()); | 884 configurations_[0]->Name()); |
874 out << indent_str << "};\n"; | 885 out << indent_str << "};\n"; |
875 } | 886 } |
OLD | NEW |