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