@@ -1713,13 +1713,36 @@ final class BuildPlanTests: XCTestCase {
1713
1713
)
1714
1714
)
1715
1715
1716
+ // Assert compile args for swift modules importing cxx modules
1716
1717
let swiftInteropLib = try result. target ( for: " swiftInteropLib " ) . swiftTarget ( ) . compileArguments ( )
1717
1718
XCTAssertMatch (
1718
1719
swiftInteropLib,
1719
1720
[ . anySequence, " -cxx-interoperability-mode=default " , " -Xcc " , " -std=c++1z " , . anySequence]
1720
1721
)
1721
1722
let swiftLib = try result. target ( for: " swiftLib " ) . swiftTarget ( ) . compileArguments ( )
1722
1723
XCTAssertNoMatch ( swiftLib, [ . anySequence, " -Xcc " , " -std=c++1z " , . anySequence] )
1724
+
1725
+ // Assert symbolgraph-extract args for swift modules importing cxx modules
1726
+ do {
1727
+ let swiftInteropLib = try result. target ( for: " swiftInteropLib " ) . swiftTarget ( ) . compileArguments ( )
1728
+ XCTAssertMatch (
1729
+ swiftInteropLib,
1730
+ [ . anySequence, " -cxx-interoperability-mode=default " , " -Xcc " , " -std=c++1z " , . anySequence]
1731
+ )
1732
+ let swiftLib = try result. target ( for: " swiftLib " ) . swiftTarget ( ) . compileArguments ( )
1733
+ XCTAssertNoMatch ( swiftLib, [ . anySequence, " -Xcc " , " -std=c++1z " , . anySequence] )
1734
+ }
1735
+
1736
+ // Assert symbolgraph-extract args for cxx modules
1737
+ do {
1738
+ let swiftInteropLib = try result. target ( for: " swiftInteropLib " ) . swiftTarget ( ) . compileArguments ( )
1739
+ XCTAssertMatch (
1740
+ swiftInteropLib,
1741
+ [ . anySequence, " -cxx-interoperability-mode=default " , " -Xcc " , " -std=c++1z " , . anySequence]
1742
+ )
1743
+ let swiftLib = try result. target ( for: " swiftLib " ) . swiftTarget ( ) . compileArguments ( )
1744
+ XCTAssertNoMatch ( swiftLib, [ . anySequence, " -Xcc " , " -std=c++1z " , . anySequence] )
1745
+ }
1723
1746
}
1724
1747
1725
1748
func testSwiftCMixed( ) throws {
@@ -1892,6 +1915,88 @@ final class BuildPlanTests: XCTestCase {
1892
1915
] )
1893
1916
}
1894
1917
1918
+ func testSwiftSettings_interoperabilityMode_cxx( ) throws {
1919
+ let Pkg : AbsolutePath = " /Pkg "
1920
+
1921
+ let fs : FileSystem = InMemoryFileSystem (
1922
+ emptyFiles:
1923
+ Pkg . appending ( components: " Sources " , " cxxLib " , " lib.cpp " ) . pathString,
1924
+ Pkg . appending ( components: " Sources " , " cxxLib " , " include " , " lib.h " ) . pathString,
1925
+ Pkg . appending ( components: " Sources " , " swiftLib " , " lib.swift " ) . pathString,
1926
+ Pkg . appending ( components: " Sources " , " swiftLib2 " , " lib2.swift " ) . pathString
1927
+ )
1928
+
1929
+ let observability = ObservabilitySystem . makeForTesting ( )
1930
+ let graph = try loadModulesGraph (
1931
+ fileSystem: fs,
1932
+ manifests: [
1933
+ Manifest . createRootManifest (
1934
+ displayName: " Pkg " ,
1935
+ path: . init( validating: Pkg . pathString) ,
1936
+ cxxLanguageStandard: " c++20 " ,
1937
+ targets: [
1938
+ TargetDescription ( name: " cxxLib " , dependencies: [ ] ) ,
1939
+ TargetDescription (
1940
+ name: " swiftLib " ,
1941
+ dependencies: [ " cxxLib " ] ,
1942
+ settings: [ . init( tool: . swift, kind: . interoperabilityMode( . Cxx) ) ]
1943
+ ) ,
1944
+ TargetDescription ( name: " swiftLib2 " , dependencies: [ " swiftLib " ] ) ,
1945
+ ]
1946
+ ) ,
1947
+ ] ,
1948
+ observabilityScope: observability. topScope
1949
+ )
1950
+ XCTAssertNoDiagnostics ( observability. diagnostics)
1951
+
1952
+ let plan = try mockBuildPlan (
1953
+ graph: graph,
1954
+ fileSystem: fs,
1955
+ observabilityScope: observability. topScope
1956
+ )
1957
+ let result = try BuildPlanResult ( plan: plan)
1958
+
1959
+ // Cxx module
1960
+ do {
1961
+ try XCTAssertMatch (
1962
+ result. target ( for: " cxxLib " ) . clangTarget ( ) . symbolGraphExtractArguments ( ) ,
1963
+ [ . anySequence, " -cxx-interoperability-mode=default " , " -Xcc " , " -std=c++20 " , . anySequence]
1964
+ )
1965
+ }
1966
+
1967
+ // Swift module directly importing cxx module
1968
+ do {
1969
+ try XCTAssertMatch (
1970
+ result. target ( for: " swiftLib " ) . swiftTarget ( ) . compileArguments ( ) ,
1971
+ [ . anySequence, " -cxx-interoperability-mode=default " , " -Xcc " , " -std=c++20 " , . anySequence]
1972
+ )
1973
+ try XCTAssertMatch (
1974
+ result. target ( for: " swiftLib " ) . swiftTarget ( ) . symbolGraphExtractArguments ( ) ,
1975
+ [ . anySequence, " -cxx-interoperability-mode=default " , " -Xcc " , " -std=c++20 " , . anySequence]
1976
+ )
1977
+ }
1978
+
1979
+ // Swift module transitively importing cxx module
1980
+ do {
1981
+ try XCTAssertNoMatch (
1982
+ result. target ( for: " swiftLib2 " ) . swiftTarget ( ) . compileArguments ( ) ,
1983
+ [ . anySequence, " -cxx-interoperability-mode=default " , . anySequence]
1984
+ )
1985
+ try XCTAssertNoMatch (
1986
+ result. target ( for: " swiftLib2 " ) . swiftTarget ( ) . compileArguments ( ) ,
1987
+ [ . anySequence, " -Xcc " , " -std=c++20 " , . anySequence]
1988
+ )
1989
+ try XCTAssertNoMatch (
1990
+ result. target ( for: " swiftLib2 " ) . swiftTarget ( ) . symbolGraphExtractArguments ( ) ,
1991
+ [ . anySequence, " -cxx-interoperability-mode=default " , . anySequence]
1992
+ )
1993
+ try XCTAssertNoMatch (
1994
+ result. target ( for: " swiftLib2 " ) . swiftTarget ( ) . symbolGraphExtractArguments ( ) ,
1995
+ [ . anySequence, " -Xcc " , " -std=c++20 " , . anySequence]
1996
+ )
1997
+ }
1998
+ }
1999
+
1895
2000
func testREPLArguments( ) throws {
1896
2001
let Dep = AbsolutePath ( " /Dep " )
1897
2002
let fs = InMemoryFileSystem (
0 commit comments