@@ -1410,13 +1410,13 @@ final class BuildPlanTests: XCTestCase {
14101410        args +=  [ " -O0 " ,  " -DSWIFT_PACKAGE=1 " ,  " -DDEBUG=1 " ] 
14111411        args +=  [ " -fblocks " ] 
14121412        #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+         ] 
14141418        #endif 
14151419        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- 
14201420        args +=  [ hostTriple. isWindows ( )  ?  " -gdwarf "  :  " -g " ] 
14211421
14221422        if  hostTriple. isLinux ( )  { 
@@ -1439,7 +1439,11 @@ final class BuildPlanTests: XCTestCase {
14391439        args +=  [ " -O0 " ,  " -DSWIFT_PACKAGE=1 " ,  " -DDEBUG=1 " ] 
14401440        args +=  [ " -fblocks " ] 
14411441        #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+         ] 
14431447        #endif 
14441448        args +=  [ 
14451449            " -I " ,  Pkg . appending ( components:  " Sources " ,  " exe " ,  " include " ) . pathString, 
@@ -1448,9 +1452,6 @@ final class BuildPlanTests: XCTestCase {
14481452            " -I " ,  ExtPkg . appending ( components:  " Sources " ,  " extlib " ,  " include " ) . pathString, 
14491453            " -fmodule-map-file= \( buildPath. appending ( components:  " extlib.build " ,  " module.modulemap " ) ) " , 
14501454        ] 
1451-         #if os(macOS) // FIXME(5473) - support modules on non-Apple platforms 
1452-         args +=  [ " -fmodules-cache-path= \( buildPath. appending ( components:  " ModuleCache " ) ) " ] 
1453-         #endif 
14541455        args +=  [ hostTriple. isWindows ( )  ?  " -gdwarf "  :  " -g " ] 
14551456
14561457        if  hostTriple. isLinux ( )  { 
@@ -1796,12 +1797,13 @@ final class BuildPlanTests: XCTestCase {
17961797        args +=  [ " -O0 " ,  " -DSWIFT_PACKAGE=1 " ,  " -DDEBUG=1 " ] 
17971798        args +=  [ " -fblocks " ] 
17981799        #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+         ] 
18001805        #endif 
18011806        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 
18051807        args +=  [ hostTriple. isWindows ( )  ?  " -gdwarf "  :  " -g " ] 
18061808
18071809        if  hostTriple. isLinux ( )  { 
@@ -1999,6 +2001,115 @@ final class BuildPlanTests: XCTestCase {
19992001        } 
20002002    } 
20012003
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+ 
20022113    func  testREPLArguments( )  throws  { 
20032114        let  Dep  =  AbsolutePath ( " /Dep " ) 
20042115        let  fs  =  InMemoryFileSystem ( 
@@ -3035,12 +3146,13 @@ final class BuildPlanTests: XCTestCase {
30353146        expectedExeBasicArgs +=  [ " -target " ,  defaultTargetTriple] 
30363147        expectedExeBasicArgs +=  [ " -O0 " ,  " -DSWIFT_PACKAGE=1 " ,  " -DDEBUG=1 " ,  " -fblocks " ] 
30373148        #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+         ] 
30393154        #endif 
30403155        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 
30443156
30453157        expectedExeBasicArgs +=  [ triple. isWindows ( )  ?  " -gdwarf "  :  " -g " ] 
30463158
0 commit comments