@@ -249,13 +249,14 @@ extension Driver {
249249 }
250250
251251 mutating func addFrontendSupplementaryOutputArguments( commandLine: inout [ Job . ArgTemplate ] ,
252- primaryInputOutputPairs: [ InputOutputPair ] ) throws -> [ TypedVirtualPath ] {
253- var flaggedInputOutputPairs : [ ( flag: String , InputOutputPair ) ] = [ ]
252+ primaryInputs: [ TypedVirtualPath ] ,
253+ inputOutputMap: [ TypedVirtualPath : TypedVirtualPath ] ) throws -> [ TypedVirtualPath ] {
254+ var flaggedInputOutputPairs : [ ( flag: String , input: TypedVirtualPath ? , output: TypedVirtualPath ) ] = [ ]
254255
255256 /// Add output of a particular type, if needed.
256257 func addOutputOfType(
257258 outputType: FileType , finalOutputPath: VirtualPath ? ,
258- primaryPair : InputOutputPair ? , flag: String
259+ input : TypedVirtualPath ? , flag: String
259260 ) {
260261 // If there is no final output, there's nothing to do.
261262 guard let finalOutputPath = finalOutputPath else { return }
@@ -267,125 +268,127 @@ extension Driver {
267268 // Compute the output path based on the input path (if there is one), or
268269 // use the final output.
269270 let outputPath : VirtualPath
270- if let pair = primaryPair , let input = pair . input {
271+ if let input = input {
271272 if let outputFileMapPath = outputFileMap? . existingOutput ( inputFile: input. file, outputType: outputType) {
272273 outputPath = outputFileMapPath
273- } else if compilerOutputType != nil {
274+ } else if let output = inputOutputMap [ input ] , compilerOutputType != nil {
274275 // Alongside primary output
275- outputPath = pair . output. file. replacingExtension ( with: outputType)
276+ outputPath = output. file. replacingExtension ( with: outputType)
276277 } else {
277278 outputPath = . temporary( RelativePath ( input. file. basenameWithoutExt. appendingFileTypeExtension ( outputType) ) )
278279 }
279280 } else {
280281 outputPath = finalOutputPath
281282 }
282283
283- flaggedInputOutputPairs. append ( ( flag: flag, InputOutputPair ( input: primaryPair ? . input, output: TypedVirtualPath ( file: outputPath, type: outputType) ) ) )
284+ flaggedInputOutputPairs. append ( ( flag: flag, input: input, output: TypedVirtualPath ( file: outputPath, type: outputType) ) )
284285 }
285286
286287 /// Add all of the outputs needed for a given input.
287- func addAllOutputsFor( primaryPair : InputOutputPair ? ) {
288+ func addAllOutputsFor( input : TypedVirtualPath ? ) {
288289 if !forceEmitModuleInSingleInvocation {
289290 addOutputOfType (
290291 outputType: . swiftModule,
291292 finalOutputPath: moduleOutputInfo. output? . outputPath,
292- primaryPair : primaryPair ,
293+ input : input ,
293294 flag: " -emit-module-path " )
294295 addOutputOfType (
295296 outputType: . swiftDocumentation,
296297 finalOutputPath: moduleDocOutputPath,
297- primaryPair : primaryPair ,
298+ input : input ,
298299 flag: " -emit-module-doc-path " )
299300 addOutputOfType (
300301 outputType: . swiftSourceInfoFile,
301302 finalOutputPath: moduleSourceInfoPath,
302- primaryPair : primaryPair ,
303+ input : input ,
303304 flag: " -emit-module-source-info-path " )
304305 addOutputOfType (
305306 outputType: . dependencies,
306307 finalOutputPath: dependenciesFilePath,
307- primaryPair : primaryPair ,
308+ input : input ,
308309 flag: " -emit-dependencies-path " )
309310 }
310311
311312 addOutputOfType (
312313 outputType: . yamlOptimizationRecord,
313314 finalOutputPath: optimizationRecordPath,
314- primaryPair : primaryPair ,
315+ input : input ,
315316 flag: " -save-optimization-record-path " )
316317
317318 addOutputOfType (
318319 outputType: . diagnostics,
319320 finalOutputPath: serializedDiagnosticsFilePath,
320- primaryPair : primaryPair ,
321+ input : input ,
321322 flag: " -serialize-diagnostics-path " )
322323
323324 #if false
324325 // FIXME: handle -update-code
325- addOutputOfType ( outputType: . remap, input: input. file , flag: " -emit-remap-file-path " )
326+ addOutputOfType ( outputType: . remap, input: input, flag: " -emit-remap-file-path " )
326327 #endif
327328 }
328329
329330 if compilerMode. usesPrimaryFileInputs {
330- for pair in primaryInputOutputPairs {
331- addAllOutputsFor ( primaryPair : pair )
331+ for input in primaryInputs {
332+ addAllOutputsFor ( input : input )
332333 }
333334 } else {
334- addAllOutputsFor ( primaryPair : nil )
335+ addAllOutputsFor ( input : nil )
335336
336337 // Outputs that only make sense when the whole module is processed
337338 // together.
338339 addOutputOfType (
339340 outputType: . objcHeader,
340341 finalOutputPath: objcGeneratedHeaderPath,
341- primaryPair : nil ,
342+ input : nil ,
342343 flag: " -emit-objc-header-path " )
343344
344345 addOutputOfType (
345346 outputType: . swiftInterface,
346347 finalOutputPath: swiftInterfacePath,
347- primaryPair : nil ,
348+ input : nil ,
348349 flag: " -emit-module-interface-path " )
349350
350351 addOutputOfType (
351352 outputType: . tbd,
352353 finalOutputPath: tbdPath,
353- primaryPair : nil ,
354+ input : nil ,
354355 flag: " -emit-tbd-path " )
355356 }
356357
357358 // Question: outputs.count > fileListThreshold makes sense, but c++ does the following:
358- if primaryInputOutputPairs . count * FileType. allCases. count > fileListThreshold {
359+ if primaryInputs . count * FileType. allCases. count > fileListThreshold {
359360 var entries = [ VirtualPath: [ FileType: VirtualPath] ] ( )
360- for pair in primaryInputOutputPairs {
361- addEntry ( & entries, for: pair)
361+ for input in primaryInputs {
362+ if let output = inputOutputMap [ input] {
363+ addEntry ( & entries, input: input, output: output)
364+ }
362365 }
363- for output in flaggedInputOutputPairs {
364- addEntry ( & entries, for : output. 1 )
366+ for flaggedPair in flaggedInputOutputPairs {
367+ addEntry ( & entries, input : flaggedPair . input , output: flaggedPair . output )
365368 }
366369 let outputFileMap = OutputFileMap ( entries: entries)
367370 let path = RelativePath ( createTemporaryFileName ( prefix: " supplementaryOutputs " ) )
368371 commandLine. appendFlag ( . supplementaryOutputFileMap)
369372 commandLine. appendPath ( . fileList( path, . outputFileMap( outputFileMap) ) )
370373 } else {
371- for output in flaggedInputOutputPairs {
374+ for flaggedPair in flaggedInputOutputPairs {
372375 // Add the appropriate flag.
373- commandLine. appendFlag ( output . flag)
374- commandLine. appendPath ( output . 1 . output. file)
376+ commandLine. appendFlag ( flaggedPair . flag)
377+ commandLine. appendPath ( flaggedPair . output. file)
375378 }
376379 }
377380
378- return flaggedInputOutputPairs. map { $0. 1 . output }
381+ return flaggedInputOutputPairs. map { $0. output }
379382 }
380383
381- func addEntry( _ entries: inout [ VirtualPath : [ FileType : VirtualPath ] ] , for pair : InputOutputPair ) {
384+ func addEntry( _ entries: inout [ VirtualPath : [ FileType : VirtualPath ] ] , input : TypedVirtualPath ? , output : TypedVirtualPath ) {
382385 let entryInput : VirtualPath
383- if let input = pair . input? . file, input != OutputFileMap . singleInputKey {
386+ if let input = input? . file, input != OutputFileMap . singleInputKey {
384387 entryInput = input
385388 } else {
386389 entryInput = inputFiles [ 0 ] . file
387390 }
388- entries [ entryInput, default: [ : ] ] [ pair . output. type] = pair . output. file
391+ entries [ entryInput, default: [ : ] ] [ output. type] = output. file
389392 }
390393
391394 /// Adds all dependencies required for an explicit module build
0 commit comments