@@ -226,7 +226,7 @@ public struct SwiftFrontendTool: ToolProtocol {
226226
227227/// Swift compiler llbuild tool.
228228public  struct  SwiftCompilerTool :  ToolProtocol  { 
229-     public  static  let  name :  String  =  " swift-compiler " 
229+     public  static  let  name :  String  =  " shell " 
230230
231231    public  static  let  numThreads :  Int  =  ProcessInfo . processInfo. activeProcessorCount
232232
@@ -244,6 +244,7 @@ public struct SwiftCompilerTool: ToolProtocol {
244244    public  var  sources :  [ AbsolutePath ] 
245245    public  var  isLibrary :  Bool 
246246    public  var  wholeModuleOptimization :  Bool 
247+     public  var  outputFileMapPath :  AbsolutePath 
247248
248249    init ( 
249250        inputs:  [ Node ] , 
@@ -258,7 +259,8 @@ public struct SwiftCompilerTool: ToolProtocol {
258259        otherArguments:  [ String ] , 
259260        sources:  [ AbsolutePath ] , 
260261        isLibrary:  Bool , 
261-         wholeModuleOptimization:  Bool 
262+         wholeModuleOptimization:  Bool , 
263+         outputFileMapPath:  AbsolutePath 
262264    )  { 
263265        self . inputs =  inputs
264266        self . outputs =  outputs
@@ -273,24 +275,43 @@ public struct SwiftCompilerTool: ToolProtocol {
273275        self . sources =  sources
274276        self . isLibrary =  isLibrary
275277        self . wholeModuleOptimization =  wholeModuleOptimization
278+         self . outputFileMapPath =  outputFileMapPath
276279    } 
277280
278-     public  func  write( to stream:  ManifestToolStream )  { 
279-         stream [ " executable " ]  =  executable
280-         stream [ " module-name " ]  =  moduleName
281-         if  let  moduleAliases { 
282-             // Format the key and value to pass to -module-alias flag
283-             let  formatted  =  moduleAliases. map  { $0. key +  " = "  +  $0. value} 
284-             stream [ " module-aliases " ]  =  formatted
281+     var  description :  String  { 
282+         return  " Compiling Swift Module ' \( moduleName) ' ( \( sources. count)  sources) " 
283+     } 
284+ 
285+     var  arguments :  [ String ]  { 
286+         var  arguments  =  [ 
287+             executable. pathString, 
288+             " -module-name " ,  moduleName, 
289+         ] 
290+         if  let  moduleAliases =  moduleAliases { 
291+             for  (original,  alias)  in  moduleAliases { 
292+                 arguments +=  [ " -module-alias  \( original) = \( alias) " ] 
293+             } 
294+         } 
295+         arguments +=  [ 
296+             " -incremental " , 
297+             " -emit-dependencies " , 
298+             " -emit-module " , 
299+             " -emit-module-path " ,  moduleOutputPath. pathString, 
300+             " -output-file-map " ,  outputFileMapPath. pathString, 
301+         ] 
302+         if  isLibrary { 
303+             arguments +=  [ " -parse-as-library " ] 
285304        } 
286-         stream [ " module-output-path " ]  =  moduleOutputPath
287-         stream [ " import-paths " ]  =  [ importPath] 
288-         stream [ " temps-path " ]  =  tempsPath
289-         stream [ " objects " ]  =  objects
290-         stream [ " other-args " ]  =  otherArguments
291-         stream [ " sources " ]  =  sources
292-         stream [ " is-library " ]  =  isLibrary
293-         stream [ " enable-whole-module-optimization " ]  =  wholeModuleOptimization
294-         stream [ " num-threads " ]  =  Self . numThreads
295-      } 
305+         if  wholeModuleOptimization { 
306+             arguments +=  [ " -whole-module-optimization " ,  " -num-threads " ,  " \( Self . numThreads) " ] 
307+         } 
308+         arguments +=  [ " -c " ]  +  sources. map  {  $0. pathString } 
309+         arguments +=  [ " -I " ,  importPath. pathString] 
310+         arguments +=  otherArguments
311+         return  arguments
312+     } 
313+ 
314+     public  func  write( to stream:  ManifestToolStream )  { 
315+         ShellTool ( description:  description,  inputs:  inputs,  outputs:  outputs,  arguments:  arguments) . write ( to:  stream) 
316+     } 
296317} 
0 commit comments