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

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

Issue 2574333002: [Refactor Xcode Objects] Enable generating per file '--help' compiler flag (Closed)
Patch Set: Rebase Created 3 years, 12 months 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
« no previous file with comments | « tools/gn/xcode_object.h ('k') | tools/gn/xcode_writer.cc » ('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 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
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 CompilerFlags compiler_flag)
370 : file_reference_(file_reference),
371 build_phase_(build_phase),
372 compiler_flag_(compiler_flag) {
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 (compiler_flag_ == CompilerFlags::HELP) {
394 std::map<std::string, std::string> settings = {
395 {"COMPILER_FLAGS", "--help"},
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 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
556 DCHECK(product_reference_); 565 DCHECK(product_reference_);
557 build_phases_.push_back(base::WrapUnique(new PBXSourcesBuildPhase)); 566 build_phases_.push_back(base::WrapUnique(new PBXSourcesBuildPhase));
558 source_build_phase_ = 567 source_build_phase_ =
559 static_cast<PBXSourcesBuildPhase*>(build_phases_.back().get()); 568 static_cast<PBXSourcesBuildPhase*>(build_phases_.back().get());
560 569
561 build_phases_.push_back(base::WrapUnique(new PBXFrameworksBuildPhase)); 570 build_phases_.push_back(base::WrapUnique(new PBXFrameworksBuildPhase));
562 } 571 }
563 572
564 PBXNativeTarget::~PBXNativeTarget() {} 573 PBXNativeTarget::~PBXNativeTarget() {}
565 574
566 void PBXNativeTarget::AddFileForIndexing( 575 void PBXNativeTarget::AddFileForIndexing(const PBXFileReference* file_reference,
567 const PBXFileReference* file_reference) { 576 const CompilerFlags compiler_flag) {
568 DCHECK(file_reference); 577 DCHECK(file_reference);
569 source_build_phase_->AddBuildFile( 578 source_build_phase_->AddBuildFile(base::MakeUnique<PBXBuildFile>(
570 base::MakeUnique<PBXBuildFile>(file_reference, source_build_phase_)); 579 file_reference, source_build_phase_, compiler_flag));
571 } 580 }
572 581
573 PBXObjectClass PBXNativeTarget::Class() const { 582 PBXObjectClass PBXNativeTarget::Class() const {
574 return PBXNativeTargetClass; 583 return PBXNativeTargetClass;
575 } 584 }
576 585
577 void PBXNativeTarget::Print(std::ostream& out, unsigned indent) const { 586 void PBXNativeTarget::Print(std::ostream& out, unsigned indent) const {
578 const std::string indent_str(indent, '\t'); 587 const std::string indent_str(indent, '\t');
579 const IndentRules rules = {false, indent + 1}; 588 const IndentRules rules = {false, indent + 1};
580 out << indent_str << Reference() << " = {\n"; 589 out << indent_str << Reference() << " = {\n";
(...skipping 26 matching lines...) Expand all
607 base::MakeUnique<PBXGroup>(std::string(), "Product"))); 616 base::MakeUnique<PBXGroup>(std::string(), "Product")));
608 main_group_->AddChild(base::MakeUnique<PBXGroup>(std::string(), "Build")); 617 main_group_->AddChild(base::MakeUnique<PBXGroup>(std::string(), "Build"));
609 618
610 configurations_.reset(new XCConfigurationList(config_name, attributes, this)); 619 configurations_.reset(new XCConfigurationList(config_name, attributes, this));
611 } 620 }
612 621
613 PBXProject::~PBXProject() {} 622 PBXProject::~PBXProject() {}
614 623
615 void PBXProject::AddSourceFileToIndexingTarget( 624 void PBXProject::AddSourceFileToIndexingTarget(
616 const std::string& navigator_path, 625 const std::string& navigator_path,
617 const std::string& source_path) { 626 const std::string& source_path,
627 const CompilerFlags compiler_flag) {
618 if (!target_for_indexing_) { 628 if (!target_for_indexing_) {
619 AddIndexingTarget(); 629 AddIndexingTarget();
620 } 630 }
621 AddSourceFile(navigator_path, source_path, target_for_indexing_); 631 AddSourceFile(navigator_path, source_path, compiler_flag,
632 target_for_indexing_);
622 } 633 }
623 634
624 void PBXProject::AddSourceFile(const std::string& navigator_path, 635 void PBXProject::AddSourceFile(const std::string& navigator_path,
625 const std::string& source_path, 636 const std::string& source_path,
637 const CompilerFlags compiler_flag,
626 PBXNativeTarget* target) { 638 PBXNativeTarget* target) {
627 PBXFileReference* file_reference = 639 PBXFileReference* file_reference =
628 sources_->AddSourceFile(navigator_path, source_path); 640 sources_->AddSourceFile(navigator_path, source_path);
629 base::StringPiece ext = FindExtension(&source_path); 641 base::StringPiece ext = FindExtension(&source_path);
630 if (!IsSourceFileForIndexing(ext)) 642 if (!IsSourceFileForIndexing(ext))
631 return; 643 return;
632 644
633 DCHECK(target); 645 DCHECK(target);
634 target->AddFileForIndexing(file_reference); 646 target->AddFileForIndexing(file_reference, compiler_flag);
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 232 matching lines...) Expand 10 before | Expand all | Expand 10 after
877 const std::string indent_str(indent, '\t'); 889 const std::string indent_str(indent, '\t');
878 const IndentRules rules = {false, indent + 1}; 890 const IndentRules rules = {false, indent + 1};
879 out << indent_str << Reference() << " = {\n"; 891 out << indent_str << Reference() << " = {\n";
880 PrintProperty(out, rules, "isa", ToString(Class())); 892 PrintProperty(out, rules, "isa", ToString(Class()));
881 PrintProperty(out, rules, "buildConfigurations", configurations_); 893 PrintProperty(out, rules, "buildConfigurations", configurations_);
882 PrintProperty(out, rules, "defaultConfigurationIsVisible", 1u); 894 PrintProperty(out, rules, "defaultConfigurationIsVisible", 1u);
883 PrintProperty(out, rules, "defaultConfigurationName", 895 PrintProperty(out, rules, "defaultConfigurationName",
884 configurations_[0]->Name()); 896 configurations_[0]->Name());
885 out << indent_str << "};\n"; 897 out << indent_str << "};\n";
886 } 898 }
OLDNEW
« no previous file with comments | « tools/gn/xcode_object.h ('k') | tools/gn/xcode_writer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698