(source, type, pbxp, xct)
| 520 | |
| 521 | |
| 522 | def AddSourceToTarget(source, type, pbxp, xct): |
| 523 | # TODO(mark): Perhaps source_extensions and library_extensions can be made a |
| 524 | # little bit fancier. |
| 525 | source_extensions = ["c", "cc", "cpp", "cxx", "m", "mm", "s", "swift"] |
| 526 | |
| 527 | # .o is conceptually more of a "source" than a "library," but Xcode thinks |
| 528 | # of "sources" as things to compile and "libraries" (or "frameworks") as |
| 529 | # things to link with. Adding an object file to an Xcode target's frameworks |
| 530 | # phase works properly. |
| 531 | library_extensions = ["a", "dylib", "framework", "o"] |
| 532 | |
| 533 | basename = posixpath.basename(source) |
| 534 | (_root, ext) = posixpath.splitext(basename) |
| 535 | if ext: |
| 536 | ext = ext[1:].lower() |
| 537 | |
| 538 | if ext in source_extensions and type != "none": |
| 539 | xct.SourcesPhase().AddFile(source) |
| 540 | elif ext in library_extensions and type != "none": |
| 541 | xct.FrameworksPhase().AddFile(source) |
| 542 | else: |
| 543 | # Files that aren't added to a sources or frameworks build phase can still |
| 544 | # go into the project file, just not as part of a build phase. |
| 545 | pbxp.AddOrGetFileInRootGroup(source) |
| 546 | |
| 547 | |
| 548 | def AddResourceToTarget(resource, pbxp, xct): |
no test coverage detected