@@ -1727,13 +1727,36 @@ final class BuildPlanTests: XCTestCase {
1727
1727
)
1728
1728
)
1729
1729
1730
+ // Assert compile args for swift modules importing cxx modules
1730
1731
let swiftInteropLib = try result. target ( for: " swiftInteropLib " ) . swiftTarget ( ) . compileArguments ( )
1731
1732
XCTAssertMatch (
1732
1733
swiftInteropLib,
1733
1734
[ . anySequence, " -cxx-interoperability-mode=default " , " -Xcc " , " -std=c++1z " , . anySequence]
1734
1735
)
1735
1736
let swiftLib = try result. target ( for: " swiftLib " ) . swiftTarget ( ) . compileArguments ( )
1736
1737
XCTAssertNoMatch ( swiftLib, [ . anySequence, " -Xcc " , " -std=c++1z " , . anySequence] )
1738
+
1739
+ // Assert symbolgraph-extract args for swift modules importing cxx modules
1740
+ do {
1741
+ let swiftInteropLib = try result. target ( for: " swiftInteropLib " ) . swiftTarget ( ) . compileArguments ( )
1742
+ XCTAssertMatch (
1743
+ swiftInteropLib,
1744
+ [ . anySequence, " -cxx-interoperability-mode=default " , " -Xcc " , " -std=c++1z " , . anySequence]
1745
+ )
1746
+ let swiftLib = try result. target ( for: " swiftLib " ) . swiftTarget ( ) . compileArguments ( )
1747
+ XCTAssertNoMatch ( swiftLib, [ . anySequence, " -Xcc " , " -std=c++1z " , . anySequence] )
1748
+ }
1749
+
1750
+ // Assert symbolgraph-extract args for cxx modules
1751
+ do {
1752
+ let swiftInteropLib = try result. target ( for: " swiftInteropLib " ) . swiftTarget ( ) . compileArguments ( )
1753
+ XCTAssertMatch (
1754
+ swiftInteropLib,
1755
+ [ . anySequence, " -cxx-interoperability-mode=default " , " -Xcc " , " -std=c++1z " , . anySequence]
1756
+ )
1757
+ let swiftLib = try result. target ( for: " swiftLib " ) . swiftTarget ( ) . compileArguments ( )
1758
+ XCTAssertNoMatch ( swiftLib, [ . anySequence, " -Xcc " , " -std=c++1z " , . anySequence] )
1759
+ }
1737
1760
}
1738
1761
1739
1762
func testSwiftCMixed( ) throws {
@@ -1910,6 +1933,81 @@ final class BuildPlanTests: XCTestCase {
1910
1933
] )
1911
1934
}
1912
1935
1936
+ func testSwiftSettings_interoperabilityMode_cxx( ) throws {
1937
+ let Pkg : AbsolutePath = " /Pkg "
1938
+
1939
+ let fs : FileSystem = InMemoryFileSystem (
1940
+ emptyFiles:
1941
+ Pkg . appending ( components: " Sources " , " cxxLib " , " lib.cpp " ) . pathString,
1942
+ Pkg . appending ( components: " Sources " , " cxxLib " , " include " , " lib.h " ) . pathString,
1943
+ Pkg . appending ( components: " Sources " , " swiftLib " , " lib.swift " ) . pathString,
1944
+ Pkg . appending ( components: " Sources " , " swiftLib2 " , " lib2.swift " ) . pathString
1945
+ )
1946
+
1947
+ let observability = ObservabilitySystem . makeForTesting ( )
1948
+ let graph = try loadModulesGraph (
1949
+ fileSystem: fs,
1950
+ manifests: [
1951
+ Manifest . createRootManifest (
1952
+ displayName: " Pkg " ,
1953
+ path: . init( validating: Pkg . pathString) ,
1954
+ cxxLanguageStandard: " c++20 " ,
1955
+ targets: [
1956
+ TargetDescription ( name: " cxxLib " , dependencies: [ ] ) ,
1957
+ TargetDescription (
1958
+ name: " swiftLib " ,
1959
+ dependencies: [ " cxxLib " ] ,
1960
+ settings: [ . init( tool: . swift, kind: . interoperabilityMode( . Cxx) ) ]
1961
+ ) ,
1962
+ TargetDescription ( name: " swiftLib2 " , dependencies: [ " swiftLib " ] ) ,
1963
+ ]
1964
+ ) ,
1965
+ ] ,
1966
+ observabilityScope: observability. topScope
1967
+ )
1968
+ XCTAssertNoDiagnostics ( observability. diagnostics)
1969
+
1970
+ let plan = try BuildPlan (
1971
+ buildParameters: mockBuildParameters ( ) ,
1972
+ graph: graph,
1973
+ fileSystem: fs,
1974
+ observabilityScope: observability. topScope
1975
+ )
1976
+ let result = try BuildPlanResult ( plan: plan)
1977
+
1978
+ // Cxx module
1979
+ do {
1980
+ try XCTAssertMatch (
1981
+ result. target ( for: " cxxLib " ) . clangTarget ( ) . symbolGraphExtractArguments ( ) ,
1982
+ [ . anySequence, " -cxx-interoperability-mode=default " , " -Xcc " , " -std=c++20 " , . anySequence]
1983
+ )
1984
+ }
1985
+
1986
+ // Swift module directly importing cxx module
1987
+ do {
1988
+ try XCTAssertMatch (
1989
+ result. target ( for: " swiftLib " ) . swiftTarget ( ) . compileArguments ( ) ,
1990
+ [ . anySequence, " -cxx-interoperability-mode=default " , " -Xcc " , " -std=c++20 " , . anySequence]
1991
+ )
1992
+ try XCTAssertMatch (
1993
+ result. target ( for: " swiftLib " ) . swiftTarget ( ) . symbolGraphExtractArguments ( ) ,
1994
+ [ . anySequence, " -cxx-interoperability-mode=default " , " -Xcc " , " -std=c++20 " , . anySequence]
1995
+ )
1996
+ }
1997
+
1998
+ // Swift module transitively importing cxx module
1999
+ do {
2000
+ try XCTAssertMatch (
2001
+ result. target ( for: " swiftLib2 " ) . swiftTarget ( ) . compileArguments ( ) ,
2002
+ [ . anySequence, " -cxx-interoperability-mode=default " , " -Xcc " , " -std=c++20 " , . anySequence]
2003
+ )
2004
+ try XCTAssertMatch (
2005
+ result. target ( for: " swiftLib2 " ) . swiftTarget ( ) . symbolGraphExtractArguments ( ) ,
2006
+ [ . anySequence, " -cxx-interoperability-mode=default " , " -Xcc " , " -std=c++20 " , . anySequence]
2007
+ )
2008
+ }
2009
+ }
2010
+
1913
2011
func testREPLArguments( ) throws {
1914
2012
let Dep = AbsolutePath ( " /Dep " )
1915
2013
let fs = InMemoryFileSystem (
0 commit comments