@@ -1408,13 +1408,13 @@ final class BuildPlanTests: XCTestCase {
1408
1408
args += [ " -O0 " , " -DSWIFT_PACKAGE=1 " , " -DDEBUG=1 " ]
1409
1409
args += [ " -fblocks " ]
1410
1410
#if os(macOS) // FIXME(5473) - support modules on non-Apple platforms
1411
- args += [ " -fmodules " , " -fmodule-name=extlib " ]
1411
+ args += [
1412
+ " -fmodules " ,
1413
+ " -fmodule-name=extlib " ,
1414
+ " -fmodules-cache-path= \( buildPath. appending ( components: " ModuleCache " ) ) " ,
1415
+ ]
1412
1416
#endif
1413
1417
args += [ " -I " , ExtPkg . appending ( components: " Sources " , " extlib " , " include " ) . pathString]
1414
- #if os(macOS) // FIXME(5473) - support modules on non-Apple platforms
1415
- args += [ " -fmodules-cache-path= \( buildPath. appending ( components: " ModuleCache " ) ) " ]
1416
- #endif
1417
-
1418
1418
args += [ hostTriple. isWindows ( ) ? " -gdwarf " : " -g " ]
1419
1419
1420
1420
if hostTriple. isLinux ( ) {
@@ -1437,7 +1437,11 @@ final class BuildPlanTests: XCTestCase {
1437
1437
args += [ " -O0 " , " -DSWIFT_PACKAGE=1 " , " -DDEBUG=1 " ]
1438
1438
args += [ " -fblocks " ]
1439
1439
#if os(macOS) // FIXME(5473) - support modules on non-Apple platforms
1440
- args += [ " -fmodules " , " -fmodule-name=exe " ]
1440
+ args += [
1441
+ " -fmodules " ,
1442
+ " -fmodule-name=exe " ,
1443
+ " -fmodules-cache-path= \( buildPath. appending ( components: " ModuleCache " ) ) " ,
1444
+ ]
1441
1445
#endif
1442
1446
args += [
1443
1447
" -I " , Pkg . appending ( components: " Sources " , " exe " , " include " ) . pathString,
@@ -1446,9 +1450,6 @@ final class BuildPlanTests: XCTestCase {
1446
1450
" -I " , ExtPkg . appending ( components: " Sources " , " extlib " , " include " ) . pathString,
1447
1451
" -fmodule-map-file= \( buildPath. appending ( components: " extlib.build " , " module.modulemap " ) ) " ,
1448
1452
]
1449
- #if os(macOS) // FIXME(5473) - support modules on non-Apple platforms
1450
- args += [ " -fmodules-cache-path= \( buildPath. appending ( components: " ModuleCache " ) ) " ]
1451
- #endif
1452
1453
args += [ hostTriple. isWindows ( ) ? " -gdwarf " : " -g " ]
1453
1454
1454
1455
if hostTriple. isLinux ( ) {
@@ -1794,12 +1795,13 @@ final class BuildPlanTests: XCTestCase {
1794
1795
args += [ " -O0 " , " -DSWIFT_PACKAGE=1 " , " -DDEBUG=1 " ]
1795
1796
args += [ " -fblocks " ]
1796
1797
#if os(macOS) // FIXME(5473) - support modules on non-Apple platforms
1797
- args += [ " -fmodules " , " -fmodule-name=lib " ]
1798
+ args += [
1799
+ " -fmodules " ,
1800
+ " -fmodule-name=lib " ,
1801
+ " -fmodules-cache-path= \( buildPath. appending ( components: " ModuleCache " ) ) " ,
1802
+ ]
1798
1803
#endif
1799
1804
args += [ " -I " , Pkg . appending ( components: " Sources " , " lib " , " include " ) . pathString]
1800
- #if os(macOS) // FIXME(5473) - support modules on non-Apple platforms
1801
- args += [ " -fmodules-cache-path= \( buildPath. appending ( components: " ModuleCache " ) ) " ]
1802
- #endif
1803
1805
args += [ hostTriple. isWindows ( ) ? " -gdwarf " : " -g " ]
1804
1806
1805
1807
if hostTriple. isLinux ( ) {
@@ -1997,6 +1999,115 @@ final class BuildPlanTests: XCTestCase {
1997
1999
}
1998
2000
}
1999
2001
2002
+ func test_symbolGraphExtract_arguments( ) throws {
2003
+ // ModuleGraph:
2004
+ // .
2005
+ // ├── A (Swift)
2006
+ // │ ├── B (Swift)
2007
+ // │ └── C (C)
2008
+ // └── D (C)
2009
+ // ├── B (Swift)
2010
+ // └── C (C)
2011
+
2012
+ let Pkg : AbsolutePath = " /Pkg "
2013
+ let fs : FileSystem = InMemoryFileSystem (
2014
+ emptyFiles:
2015
+ // A
2016
+ Pkg . appending ( components: " Sources " , " A " , " A.swift " ) . pathString,
2017
+ // B
2018
+ Pkg . appending ( components: " Sources " , " B " , " B.swift " ) . pathString,
2019
+ // C
2020
+ Pkg . appending ( components: " Sources " , " C " , " C.c " ) . pathString,
2021
+ Pkg . appending ( components: " Sources " , " C " , " include " , " C.h " ) . pathString,
2022
+ // D
2023
+ Pkg . appending ( components: " Sources " , " D " , " D.c " ) . pathString,
2024
+ Pkg . appending ( components: " Sources " , " D " , " include " , " D.h " ) . pathString
2025
+ )
2026
+
2027
+ let observability = ObservabilitySystem . makeForTesting ( )
2028
+ let graph = try loadModulesGraph (
2029
+ fileSystem: fs,
2030
+ manifests: [
2031
+ Manifest . createRootManifest (
2032
+ displayName: " Pkg " ,
2033
+ path: . init( validating: Pkg . pathString) ,
2034
+ targets: [
2035
+ TargetDescription ( name: " A " , dependencies: [ " B " , " C " ] ) ,
2036
+ TargetDescription ( name: " B " , dependencies: [ ] ) ,
2037
+ TargetDescription ( name: " C " , dependencies: [ ] ) ,
2038
+ TargetDescription ( name: " D " , dependencies: [ " B " , " C " ] ) ,
2039
+ ]
2040
+ ) ,
2041
+ ] ,
2042
+ observabilityScope: observability. topScope
2043
+ )
2044
+ XCTAssertNoDiagnostics ( observability. diagnostics)
2045
+
2046
+ let plan = try mockBuildPlan (
2047
+ graph: graph,
2048
+ fileSystem: fs,
2049
+ observabilityScope: observability. topScope
2050
+ )
2051
+
2052
+ let result = try BuildPlanResult ( plan: plan)
2053
+ let triple = result. plan. destinationBuildParameters. triple
2054
+
2055
+ func XCTAssertMatchesSubSequences(
2056
+ _ value: [ String ] ,
2057
+ _ patterns: [ StringPattern ] ... ,
2058
+ file: StaticString = #file,
2059
+ line: UInt = #line
2060
+ ) {
2061
+ for pattern in patterns {
2062
+ var pattern = pattern
2063
+ pattern. insert ( . anySequence, at: 0 )
2064
+ pattern. append ( . anySequence)
2065
+ XCTAssertMatch ( value, pattern, file: file, line: line)
2066
+ }
2067
+ }
2068
+
2069
+ // A
2070
+ do {
2071
+ try XCTAssertMatchesSubSequences (
2072
+ result. target ( for: " A " ) . symbolGraphExtractArguments ( ) ,
2073
+ // Swift Module dependencies
2074
+ [ " -I " , " /path/to/build/ \( triple) /debug/Modules " ] ,
2075
+ // C Module dependencies
2076
+ [ " -Xcc " , " -I " , " -Xcc " , " /Pkg/Sources/C/include " ] ,
2077
+ [ " -Xcc " , " -fmodule-map-file=/path/to/build/ \( triple) /debug/C.build/module.modulemap " ]
2078
+ )
2079
+ }
2080
+
2081
+ // D
2082
+ do {
2083
+ try XCTAssertMatchesSubSequences (
2084
+ result. target ( for: " D " ) . symbolGraphExtractArguments ( ) ,
2085
+ // Self Module
2086
+ [ " -I " , " /Pkg/Sources/D/include " ] ,
2087
+ [ " -Xcc " , " -fmodule-map-file=/path/to/build/ \( triple) /debug/D.build/module.modulemap " ] ,
2088
+
2089
+ // C Module dependencies
2090
+ [ " -Xcc " , " -I " , " -Xcc " , " /Pkg/Sources/C/include " ] ,
2091
+ [ " -Xcc " , " -fmodule-map-file=/path/to/build/ \( triple) /debug/C.build/module.modulemap " ] ,
2092
+
2093
+ // General Args
2094
+ [
2095
+ " -Xcc " , " -fmodules " ,
2096
+ " -Xcc " , " -fmodule-name=D " ,
2097
+ " -Xcc " , " -fmodules-cache-path=/path/to/build/ \( triple) /debug/ModuleCache " ,
2098
+ ]
2099
+ )
2100
+
2101
+ #if os(macOS)
2102
+ try XCTAssertMatchesSubSequences (
2103
+ result. target ( for: " D " ) . symbolGraphExtractArguments ( ) ,
2104
+ // Swift Module dependencies
2105
+ [ " -Xcc " , " -fmodule-map-file=/path/to/build/ \( triple) /debug/B.build/module.modulemap " ]
2106
+ )
2107
+ #endif
2108
+ }
2109
+ }
2110
+
2000
2111
func testREPLArguments( ) throws {
2001
2112
let Dep = AbsolutePath ( " /Dep " )
2002
2113
let fs = InMemoryFileSystem (
@@ -3033,12 +3144,13 @@ final class BuildPlanTests: XCTestCase {
3033
3144
expectedExeBasicArgs += [ " -target " , defaultTargetTriple]
3034
3145
expectedExeBasicArgs += [ " -O0 " , " -DSWIFT_PACKAGE=1 " , " -DDEBUG=1 " , " -fblocks " ]
3035
3146
#if os(macOS) // FIXME(5473) - support modules on non-Apple platforms
3036
- expectedExeBasicArgs += [ " -fmodules " , " -fmodule-name=exe " ]
3147
+ expectedExeBasicArgs += [
3148
+ " -fmodules " ,
3149
+ " -fmodule-name=exe " ,
3150
+ " -fmodules-cache-path= \( buildPath. appending ( components: " ModuleCache " ) ) "
3151
+ ]
3037
3152
#endif
3038
3153
expectedExeBasicArgs += [ " -I " , Pkg . appending ( components: " Sources " , " exe " , " include " ) . pathString]
3039
- #if os(macOS) // FIXME(5473) - support modules on non-Apple platforms
3040
- expectedExeBasicArgs += [ " -fmodules-cache-path= \( buildPath. appending ( components: " ModuleCache " ) ) " ]
3041
- #endif
3042
3154
3043
3155
expectedExeBasicArgs += [ triple. isWindows ( ) ? " -gdwarf " : " -g " ]
3044
3156
0 commit comments