@@ -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,81 @@ 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 BuildPlan (
1955
+ buildParameters: mockBuildParameters ( ) ,
1956
+ graph: graph,
1957
+ fileSystem: fs,
1958
+ observabilityScope: observability. topScope
1959
+ )
1960
+ let result = try BuildPlanResult ( plan: plan)
1961
+
1962
+ // Cxx module
1963
+ do {
1964
+ try XCTAssertMatch (
1965
+ result. target ( for: " cxxLib " ) . clangTarget ( ) . symbolGraphExtractArguments ( ) ,
1966
+ [ . anySequence, " -cxx-interoperability-mode=default " , " -Xcc " , " -std=c++20 " , . anySequence]
1967
+ )
1968
+ }
1969
+
1970
+ // Swift module directly importing cxx module
1971
+ do {
1972
+ try XCTAssertMatch (
1973
+ result. target ( for: " swiftLib " ) . swiftTarget ( ) . compileArguments ( ) ,
1974
+ [ . anySequence, " -cxx-interoperability-mode=default " , " -Xcc " , " -std=c++20 " , . anySequence]
1975
+ )
1976
+ try XCTAssertMatch (
1977
+ result. target ( for: " swiftLib " ) . swiftTarget ( ) . symbolGraphExtractArguments ( ) ,
1978
+ [ . anySequence, " -cxx-interoperability-mode=default " , " -Xcc " , " -std=c++20 " , . anySequence]
1979
+ )
1980
+ }
1981
+
1982
+ // Swift module transitively importing cxx module
1983
+ do {
1984
+ try XCTAssertMatch (
1985
+ result. target ( for: " swiftLib2 " ) . swiftTarget ( ) . compileArguments ( ) ,
1986
+ [ . anySequence, " -cxx-interoperability-mode=default " , " -Xcc " , " -std=c++20 " , . anySequence]
1987
+ )
1988
+ try XCTAssertMatch (
1989
+ result. target ( for: " swiftLib2 " ) . swiftTarget ( ) . symbolGraphExtractArguments ( ) ,
1990
+ [ . anySequence, " -cxx-interoperability-mode=default " , " -Xcc " , " -std=c++20 " , . anySequence]
1991
+ )
1992
+ }
1993
+ }
1994
+
1897
1995
func testREPLArguments( ) throws {
1898
1996
let Dep = AbsolutePath ( " /Dep " )
1899
1997
let fs = InMemoryFileSystem (
0 commit comments