Chromium Code Reviews| 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 347 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 358 PrintProperty(out, rules, "buildPhases", build_phases_); | 358 PrintProperty(out, rules, "buildPhases", build_phases_); |
| 359 PrintProperty(out, rules, "dependencies", EmptyPBXObjectVector()); | 359 PrintProperty(out, rules, "dependencies", EmptyPBXObjectVector()); |
| 360 PrintProperty(out, rules, "name", name_); | 360 PrintProperty(out, rules, "name", name_); |
| 361 PrintProperty(out, rules, "productName", name_); | 361 PrintProperty(out, rules, "productName", name_); |
| 362 out << indent_str << "};\n"; | 362 out << indent_str << "};\n"; |
| 363 } | 363 } |
| 364 | 364 |
| 365 // PBXBuildFile --------------------------------------------------------------- | 365 // PBXBuildFile --------------------------------------------------------------- |
| 366 | 366 |
| 367 PBXBuildFile::PBXBuildFile(const PBXFileReference* file_reference, | 367 PBXBuildFile::PBXBuildFile(const PBXFileReference* file_reference, |
| 368 const PBXSourcesBuildPhase* build_phase) | 368 const PBXSourcesBuildPhase* build_phase, |
| 369 : file_reference_(file_reference), build_phase_(build_phase) { | 369 const HelpCompilerFlagEnabled help_flag_enabled) |
| 370 : file_reference_(file_reference), | |
| 371 build_phase_(build_phase), | |
| 372 help_flag_enabled_(help_flag_enabled) { | |
| 370 DCHECK(file_reference_); | 373 DCHECK(file_reference_); |
| 371 DCHECK(build_phase_); | 374 DCHECK(build_phase_); |
| 372 } | 375 } |
| 373 | 376 |
| 374 PBXBuildFile::~PBXBuildFile() {} | 377 PBXBuildFile::~PBXBuildFile() {} |
| 375 | 378 |
| 376 PBXObjectClass PBXBuildFile::Class() const { | 379 PBXObjectClass PBXBuildFile::Class() const { |
| 377 return PBXBuildFileClass; | 380 return PBXBuildFileClass; |
| 378 } | 381 } |
| 379 | 382 |
| 380 std::string PBXBuildFile::Name() const { | 383 std::string PBXBuildFile::Name() const { |
| 381 return file_reference_->Name() + " in " + build_phase_->Name(); | 384 return file_reference_->Name() + " in " + build_phase_->Name(); |
| 382 } | 385 } |
| 383 | 386 |
| 384 void PBXBuildFile::Print(std::ostream& out, unsigned indent) const { | 387 void PBXBuildFile::Print(std::ostream& out, unsigned indent) const { |
| 385 const std::string indent_str(indent, '\t'); | 388 const std::string indent_str(indent, '\t'); |
| 386 const IndentRules rules = {true, 0}; | 389 const IndentRules rules = {true, 0}; |
| 387 out << indent_str << Reference() << " = {"; | 390 out << indent_str << Reference() << " = {"; |
| 388 PrintProperty(out, rules, "isa", ToString(Class())); | 391 PrintProperty(out, rules, "isa", ToString(Class())); |
| 389 PrintProperty(out, rules, "fileRef", file_reference_); | 392 PrintProperty(out, rules, "fileRef", file_reference_); |
| 393 if (help_flag_enabled_ == HelpCompilerFlagEnabled::HELP_FLAG_ENABLED) { | |
| 394 std::map<std::string, std::string> settings = { | |
| 395 {"COMPILER_FLAGS", "-h"}, | |
|
justincohen
2016/12/14 20:00:17
Is it -h or --help ?
liaoyuke
2016/12/14 20:29:23
Thank you for catching it! I meant to type "-help"
liaoyuke
2016/12/14 20:29:23
Done.
| |
| 396 }; | |
| 397 PrintProperty(out, rules, "settings", settings); | |
| 398 } | |
| 390 out << "};\n"; | 399 out << "};\n"; |
| 391 } | 400 } |
| 392 | 401 |
| 393 // PBXFileReference ----------------------------------------------------------- | 402 // PBXFileReference ----------------------------------------------------------- |
| 394 | 403 |
| 395 PBXFileReference::PBXFileReference(const std::string& name, | 404 PBXFileReference::PBXFileReference(const std::string& name, |
| 396 const std::string& path, | 405 const std::string& path, |
| 397 const std::string& type) | 406 const std::string& type) |
| 398 : name_(name), path_(path), type_(type) {} | 407 : name_(name), path_(path), type_(type) {} |
| 399 | 408 |
| (...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 553 build_phases_.push_back(base::WrapUnique(new PBXSourcesBuildPhase)); | 562 build_phases_.push_back(base::WrapUnique(new PBXSourcesBuildPhase)); |
| 554 source_build_phase_ = | 563 source_build_phase_ = |
| 555 static_cast<PBXSourcesBuildPhase*>(build_phases_.back().get()); | 564 static_cast<PBXSourcesBuildPhase*>(build_phases_.back().get()); |
| 556 | 565 |
| 557 build_phases_.push_back(base::WrapUnique(new PBXFrameworksBuildPhase)); | 566 build_phases_.push_back(base::WrapUnique(new PBXFrameworksBuildPhase)); |
| 558 } | 567 } |
| 559 | 568 |
| 560 PBXNativeTarget::~PBXNativeTarget() {} | 569 PBXNativeTarget::~PBXNativeTarget() {} |
| 561 | 570 |
| 562 void PBXNativeTarget::AddFileForIndexing( | 571 void PBXNativeTarget::AddFileForIndexing( |
| 563 const PBXFileReference* file_reference) { | 572 const PBXFileReference* file_reference, |
| 573 const PBXBuildFile::HelpCompilerFlagEnabled help_flag_enabled) { | |
| 564 DCHECK(file_reference); | 574 DCHECK(file_reference); |
| 565 source_build_phase_->AddBuildFile( | 575 source_build_phase_->AddBuildFile(base::MakeUnique<PBXBuildFile>( |
| 566 base::MakeUnique<PBXBuildFile>(file_reference, source_build_phase_)); | 576 file_reference, source_build_phase_, help_flag_enabled)); |
| 567 } | 577 } |
| 568 | 578 |
| 569 PBXObjectClass PBXNativeTarget::Class() const { | 579 PBXObjectClass PBXNativeTarget::Class() const { |
| 570 return PBXNativeTargetClass; | 580 return PBXNativeTargetClass; |
| 571 } | 581 } |
| 572 | 582 |
| 573 void PBXNativeTarget::Print(std::ostream& out, unsigned indent) const { | 583 void PBXNativeTarget::Print(std::ostream& out, unsigned indent) const { |
| 574 const std::string indent_str(indent, '\t'); | 584 const std::string indent_str(indent, '\t'); |
| 575 const IndentRules rules = {false, indent + 1}; | 585 const IndentRules rules = {false, indent + 1}; |
| 576 out << indent_str << Reference() << " = {\n"; | 586 out << indent_str << Reference() << " = {\n"; |
| (...skipping 23 matching lines...) Expand all Loading... | |
| 600 main_group_->AddChild(base::MakeUnique<PBXGroup>(source_path, "Source"))); | 610 main_group_->AddChild(base::MakeUnique<PBXGroup>(source_path, "Source"))); |
| 601 products_ = static_cast<PBXGroup*>(main_group_->AddChild( | 611 products_ = static_cast<PBXGroup*>(main_group_->AddChild( |
| 602 base::MakeUnique<PBXGroup>(std::string(), "Product"))); | 612 base::MakeUnique<PBXGroup>(std::string(), "Product"))); |
| 603 main_group_->AddChild(base::MakeUnique<PBXGroup>(std::string(), "Build")); | 613 main_group_->AddChild(base::MakeUnique<PBXGroup>(std::string(), "Build")); |
| 604 | 614 |
| 605 configurations_.reset(new XCConfigurationList(config_name, attributes, this)); | 615 configurations_.reset(new XCConfigurationList(config_name, attributes, this)); |
| 606 } | 616 } |
| 607 | 617 |
| 608 PBXProject::~PBXProject() {} | 618 PBXProject::~PBXProject() {} |
| 609 | 619 |
| 610 void PBXProject::AddSourceFile(const std::string& source_path) { | 620 void PBXProject::AddSourceFile( |
| 621 const std::string& source_path, | |
| 622 const PBXBuildFile::HelpCompilerFlagEnabled help_flag_enabled) { | |
| 611 PBXFileReference* file_reference = sources_->AddSourceFile(source_path); | 623 PBXFileReference* file_reference = sources_->AddSourceFile(source_path); |
| 612 base::StringPiece ext = FindExtension(&source_path); | 624 base::StringPiece ext = FindExtension(&source_path); |
| 613 if (!IsSourceFileForIndexing(ext)) | 625 if (!IsSourceFileForIndexing(ext)) |
| 614 return; | 626 return; |
| 615 | 627 |
| 616 if (!target_for_indexing_) { | 628 if (!target_for_indexing_) { |
| 617 PBXAttributes attributes; | 629 PBXAttributes attributes; |
| 618 attributes["EXECUTABLE_PREFIX"] = ""; | 630 attributes["EXECUTABLE_PREFIX"] = ""; |
| 619 attributes["HEADER_SEARCH_PATHS"] = sources_->path(); | 631 attributes["HEADER_SEARCH_PATHS"] = sources_->path(); |
| 620 attributes["PRODUCT_NAME"] = name_; | 632 attributes["PRODUCT_NAME"] = name_; |
| 621 | 633 |
| 622 PBXFileReference* product_reference = static_cast<PBXFileReference*>( | 634 PBXFileReference* product_reference = static_cast<PBXFileReference*>( |
| 623 products_->AddChild(base::MakeUnique<PBXFileReference>( | 635 products_->AddChild(base::MakeUnique<PBXFileReference>( |
| 624 std::string(), name_, "compiled.mach-o.executable"))); | 636 std::string(), name_, "compiled.mach-o.executable"))); |
| 625 | 637 |
| 626 const char product_type[] = "com.apple.product-type.tool"; | 638 const char product_type[] = "com.apple.product-type.tool"; |
| 627 targets_.push_back(base::MakeUnique<PBXNativeTarget>( | 639 targets_.push_back(base::MakeUnique<PBXNativeTarget>( |
| 628 name_, std::string(), config_name_, attributes, product_type, name_, | 640 name_, std::string(), config_name_, attributes, product_type, name_, |
| 629 product_reference)); | 641 product_reference)); |
| 630 target_for_indexing_ = static_cast<PBXNativeTarget*>(targets_.back().get()); | 642 target_for_indexing_ = static_cast<PBXNativeTarget*>(targets_.back().get()); |
| 631 } | 643 } |
| 632 | 644 |
| 633 DCHECK(target_for_indexing_); | 645 DCHECK(target_for_indexing_); |
| 634 target_for_indexing_->AddFileForIndexing(file_reference); | 646 target_for_indexing_->AddFileForIndexing(file_reference, help_flag_enabled); |
| 635 } | 647 } |
| 636 | 648 |
| 637 void PBXProject::AddAggregateTarget(const std::string& name, | 649 void PBXProject::AddAggregateTarget(const std::string& name, |
| 638 const std::string& shell_script) { | 650 const std::string& shell_script) { |
| 639 PBXAttributes attributes; | 651 PBXAttributes attributes; |
| 640 attributes["CODE_SIGNING_REQUIRED"] = "NO"; | 652 attributes["CODE_SIGNING_REQUIRED"] = "NO"; |
| 641 attributes["CONFIGURATION_BUILD_DIR"] = "."; | 653 attributes["CONFIGURATION_BUILD_DIR"] = "."; |
| 642 attributes["PRODUCT_NAME"] = name; | 654 attributes["PRODUCT_NAME"] = name; |
| 643 | 655 |
| 644 targets_.push_back(base::MakeUnique<PBXAggregateTarget>( | 656 targets_.push_back(base::MakeUnique<PBXAggregateTarget>( |
| (...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 859 const std::string indent_str(indent, '\t'); | 871 const std::string indent_str(indent, '\t'); |
| 860 const IndentRules rules = {false, indent + 1}; | 872 const IndentRules rules = {false, indent + 1}; |
| 861 out << indent_str << Reference() << " = {\n"; | 873 out << indent_str << Reference() << " = {\n"; |
| 862 PrintProperty(out, rules, "isa", ToString(Class())); | 874 PrintProperty(out, rules, "isa", ToString(Class())); |
| 863 PrintProperty(out, rules, "buildConfigurations", configurations_); | 875 PrintProperty(out, rules, "buildConfigurations", configurations_); |
| 864 PrintProperty(out, rules, "defaultConfigurationIsVisible", 1u); | 876 PrintProperty(out, rules, "defaultConfigurationIsVisible", 1u); |
| 865 PrintProperty(out, rules, "defaultConfigurationName", | 877 PrintProperty(out, rules, "defaultConfigurationName", |
| 866 configurations_[0]->Name()); | 878 configurations_[0]->Name()); |
| 867 out << indent_str << "};\n"; | 879 out << indent_str << "};\n"; |
| 868 } | 880 } |
| OLD | NEW |