@@ -114,7 +114,9 @@ final class BuildPlanTests: XCTestCase {
114
114
" -emit-executable " ,
115
115
" @/path/to/build/debug/exe.product/Objects.LinkFileList " ,
116
116
" -Xlinker " , " -rpath " , " -Xlinker " , " /fake/path/lib/swift/macosx " ,
117
- " -target " , " x86_64-apple-macosx10.10 " ,
117
+ " -target " , " x86_64-apple-macosx10.10 " , " -Xlinker " , " -add_ast_path " ,
118
+ " -Xlinker " , " /path/to/build/debug/exe.swiftmodule " , " -Xlinker " , " -add_ast_path " ,
119
+ " -Xlinker " , " /path/to/build/debug/lib.swiftmodule " ,
118
120
]
119
121
#else
120
122
let linkArguments = [
@@ -461,6 +463,7 @@ final class BuildPlanTests: XCTestCase {
461
463
" @/path/to/build/debug/exe.product/Objects.LinkFileList " ,
462
464
" -Xlinker " , " -rpath " , " -Xlinker " , " /fake/path/lib/swift/macosx " ,
463
465
" -target " , " x86_64-apple-macosx10.10 " ,
466
+ " -Xlinker " , " -add_ast_path " , " -Xlinker " , " /path/to/build/debug/exe.swiftmodule " ,
464
467
] )
465
468
#else
466
469
XCTAssertEqual ( try result. buildProduct ( for: " exe " ) . linkArguments ( ) , [
@@ -604,6 +607,8 @@ final class BuildPlanTests: XCTestCase {
604
607
" @/path/to/build/debug/PkgPackageTests.product/Objects.LinkFileList " ,
605
608
" -Xlinker " , " -rpath " , " -Xlinker " , " /fake/path/lib/swift/macosx " ,
606
609
" -target " , " x86_64-apple-macosx10.10 " ,
610
+ " -Xlinker " , " -add_ast_path " , " -Xlinker " , " /path/to/build/debug/FooTests.swiftmodule " ,
611
+ " -Xlinker " , " -add_ast_path " , " -Xlinker " , " /path/to/build/debug/Foo.swiftmodule " ,
607
612
] )
608
613
#else
609
614
XCTAssertEqual ( try result. buildProduct ( for: " PkgPackageTests " ) . linkArguments ( ) , [
@@ -656,6 +661,7 @@ final class BuildPlanTests: XCTestCase {
656
661
" @/path/to/build/debug/exe.product/Objects.LinkFileList " ,
657
662
" -Xlinker " , " -rpath " , " -Xlinker " , " /fake/path/lib/swift/macosx " ,
658
663
" -target " , " x86_64-apple-macosx10.10 " ,
664
+ " -Xlinker " , " -add_ast_path " , " -Xlinker " , " /path/to/build/debug/exe.swiftmodule " ,
659
665
] )
660
666
#else
661
667
XCTAssertEqual ( try result. buildProduct ( for: " exe " ) . linkArguments ( ) , [
@@ -749,6 +755,7 @@ final class BuildPlanTests: XCTestCase {
749
755
" @/path/to/build/debug/Foo.product/Objects.LinkFileList " ,
750
756
" -Xlinker " , " -rpath " , " -Xlinker " , " /fake/path/lib/swift/macosx " ,
751
757
" -target " , " x86_64-apple-macosx10.10 " ,
758
+ " -Xlinker " , " -add_ast_path " , " -Xlinker " , " /path/to/build/debug/Foo.swiftmodule "
752
759
] )
753
760
754
761
XCTAssertEqual ( barLinkArgs, [
@@ -757,6 +764,7 @@ final class BuildPlanTests: XCTestCase {
757
764
" -module-name " , " Bar_Baz " , " -emit-library " ,
758
765
" @/path/to/build/debug/Bar-Baz.product/Objects.LinkFileList " ,
759
766
" -target " , " x86_64-apple-macosx10.10 " ,
767
+ " -Xlinker " , " -add_ast_path " , " -Xlinker " , " /path/to/build/debug/Bar.swiftmodule "
760
768
] )
761
769
#else
762
770
XCTAssertEqual ( fooLinkArgs, [
@@ -824,6 +832,7 @@ final class BuildPlanTests: XCTestCase {
824
832
" -emit-library " ,
825
833
" @/path/to/build/debug/lib.product/Objects.LinkFileList " ,
826
834
" -target " , " x86_64-apple-macosx10.10 " ,
835
+ " -Xlinker " , " -add_ast_path " , " -Xlinker " , " /path/to/build/debug/lib.swiftmodule " ,
827
836
]
828
837
#else
829
838
let linkArguments = [
@@ -1393,7 +1402,7 @@ final class BuildPlanTests: XCTestCase {
1393
1402
XCTAssertMatch ( exe, [ . anySequence, " -DFOO " , " -framework " , " CoreData " , . end] )
1394
1403
1395
1404
let linkExe = try result. buildProduct ( for: " exe " ) . linkArguments ( )
1396
- XCTAssertMatch ( linkExe, [ . anySequence, " -lsqlite3 " , " -llibz " , " -framework " , " CoreData " , " -Ilfoo " , " -L " , " lbar " , . end ] )
1405
+ XCTAssertMatch ( linkExe, [ . anySequence, " -lsqlite3 " , " -llibz " , " -framework " , " CoreData " , " -Ilfoo " , " -L " , " lbar " , . anySequence ] )
1397
1406
}
1398
1407
}
1399
1408
@@ -1665,6 +1674,60 @@ final class BuildPlanTests: XCTestCase {
1665
1674
""" ) )
1666
1675
}
1667
1676
}
1677
+
1678
+ func testModulewrap( ) throws {
1679
+ let fs = InMemoryFileSystem ( emptyFiles:
1680
+ " /Pkg/Sources/exe/main.swift " ,
1681
+ " /Pkg/Sources/lib/lib.swift "
1682
+ )
1683
+
1684
+ let diagnostics = DiagnosticsEngine ( )
1685
+ let graph = loadPackageGraph ( root: " /Pkg " , fs: fs, diagnostics: diagnostics,
1686
+ manifests: [
1687
+ Manifest . createV4Manifest (
1688
+ name: " Pkg " ,
1689
+ path: " /Pkg " ,
1690
+ url: " /Pkg " ,
1691
+ targets: [
1692
+ TargetDescription ( name: " exe " , dependencies: [ " lib " ] ) ,
1693
+ TargetDescription ( name: " lib " , dependencies: [ ] ) ,
1694
+ ]
1695
+ ) ,
1696
+ ]
1697
+ )
1698
+ XCTAssertNoDiagnostics ( diagnostics)
1699
+
1700
+ let result = BuildPlanResult ( plan: try BuildPlan (
1701
+ buildParameters: mockBuildParameters ( destinationTriple: . x86_64Linux) ,
1702
+ graph: graph, diagnostics: diagnostics, fileSystem: fs)
1703
+ )
1704
+
1705
+ let objects = try result. buildProduct ( for: " exe " ) . objects
1706
+ XCTAssertTrue ( objects. contains ( AbsolutePath ( " /path/to/build/debug/exe.build/exe.swiftmodule.o " ) ) , objects. description)
1707
+ XCTAssertTrue ( objects. contains ( AbsolutePath ( " /path/to/build/debug/lib.build/lib.swiftmodule.o " ) ) , objects. description)
1708
+
1709
+ mktmpdir { path in
1710
+ let yaml = path. appending ( component: " debug.yaml " )
1711
+ let llbuild = LLBuildManifestGenerator ( result. plan, client: " swift-build " )
1712
+ try llbuild. generateManifest ( at: yaml)
1713
+ let contents = try localFileSystem. readFileContents ( yaml) . description
1714
+ XCTAssertMatch ( contents, . contains( """
1715
+ " /path/to/build/debug/exe.build/exe.swiftmodule.o " :
1716
+ tool: shell
1717
+ description: " Wrapping AST for exe for debugging "
1718
+ inputs: [ " /path/to/build/debug/exe.swiftmodule " ]
1719
+ outputs: [ " /path/to/build/debug/exe.build/exe.swiftmodule.o " ]
1720
+ args: [ " /fake/path/to/swiftc " , " -modulewrap " , " /path/to/build/debug/exe.swiftmodule " , " -o " , " /path/to/build/debug/exe.build/exe.swiftmodule.o " ]
1721
+
1722
+ " /path/to/build/debug/lib.build/lib.swiftmodule.o " :
1723
+ tool: shell
1724
+ description: " Wrapping AST for lib for debugging "
1725
+ inputs: [ " /path/to/build/debug/lib.swiftmodule " ]
1726
+ outputs: [ " /path/to/build/debug/lib.build/lib.swiftmodule.o " ]
1727
+ args: [ " /fake/path/to/swiftc " , " -modulewrap " , " /path/to/build/debug/lib.swiftmodule " , " -o " , " /path/to/build/debug/lib.build/lib.swiftmodule.o " ]
1728
+ """ ) )
1729
+ }
1730
+ }
1668
1731
}
1669
1732
1670
1733
// MARK:- Test Helpers
0 commit comments