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