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_writer.h" | 5 #include "tools/gn/xcode_writer.h" |
6 | 6 |
7 #include <iomanip> | 7 #include <iomanip> |
8 #include <map> | 8 #include <map> |
9 #include <memory> | 9 #include <memory> |
10 #include <sstream> | 10 #include <sstream> |
(...skipping 414 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
425 | 425 |
426 main_project->AddNativeTarget( | 426 main_project->AddNativeTarget( |
427 target->label().name(), "compiled.mach-o.executable", | 427 target->label().name(), "compiled.mach-o.executable", |
428 target->output_name().empty() ? target->label().name() | 428 target->output_name().empty() ? target->label().name() |
429 : target->output_name(), | 429 : target->output_name(), |
430 "com.apple.product-type.tool", | 430 "com.apple.product-type.tool", |
431 GetBuildScript(target->label().name(), ninja_extra_args, | 431 GetBuildScript(target->label().name(), ninja_extra_args, |
432 env.get())); | 432 env.get())); |
433 break; | 433 break; |
434 | 434 |
435 case Target::CREATE_BUNDLE: | 435 case Target::CREATE_BUNDLE: { |
436 if (target->bundle_data().product_type().empty()) | 436 if (target->bundle_data().product_type().empty()) |
437 continue; | 437 continue; |
438 | 438 |
| 439 // Test files need to be known to Xcode for proper indexing and for |
| 440 // discovery of tests function for XCTest, but the compilation is done |
| 441 // via ninja and thus must prevent Xcode from linking object files via |
| 442 // this hack. |
| 443 PBXAttributes extra_attributes; |
| 444 if (IsXCTestModuleTarget(target)) { |
| 445 extra_attributes["OTHER_LDFLAGS"] = "-help"; |
| 446 extra_attributes["ONLY_ACTIVE_ARCH"] = "YES"; |
| 447 extra_attributes["DEBUG_INFORMATION_FORMAT"] = "dwarf"; |
| 448 } |
| 449 |
439 main_project->AddNativeTarget( | 450 main_project->AddNativeTarget( |
440 target->label().name(), std::string(), | 451 target->label().name(), std::string(), |
441 RebasePath(target->bundle_data() | 452 RebasePath(target->bundle_data() |
442 .GetBundleRootDirOutput(target->settings()) | 453 .GetBundleRootDirOutput(target->settings()) |
443 .value(), | 454 .value(), |
444 build_settings->build_dir()), | 455 build_settings->build_dir()), |
445 target->bundle_data().product_type(), | 456 target->bundle_data().product_type(), |
446 GetBuildScript(target->label().name(), ninja_extra_args, | 457 GetBuildScript(target->label().name(), ninja_extra_args, env.get()), |
447 env.get())); | 458 extra_attributes); |
448 break; | 459 break; |
| 460 } |
449 | 461 |
450 default: | 462 default: |
451 break; | 463 break; |
452 } | 464 } |
453 } | 465 } |
454 | 466 |
455 projects_.push_back(std::move(main_project)); | 467 projects_.push_back(std::move(main_project)); |
456 } | 468 } |
457 | 469 |
458 void XcodeWriter::CreateSourcesProject( | 470 void XcodeWriter::CreateSourcesProject( |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
561 for (auto* object : pair.second) { | 573 for (auto* object : pair.second) { |
562 object->Print(out, 2); | 574 object->Print(out, 2); |
563 } | 575 } |
564 out << "/* End " << ToString(pair.first) << " section */\n"; | 576 out << "/* End " << ToString(pair.first) << " section */\n"; |
565 } | 577 } |
566 | 578 |
567 out << "\t};\n" | 579 out << "\t};\n" |
568 << "\trootObject = " << project->Reference() << ";\n" | 580 << "\trootObject = " << project->Reference() << ";\n" |
569 << "}\n"; | 581 << "}\n"; |
570 } | 582 } |
OLD | NEW |