@@ -237,13 +237,14 @@ extension Driver {
237
237
}
238
238
239
239
mutating func addFrontendSupplementaryOutputArguments( commandLine: inout [ Job . ArgTemplate ] ,
240
- primaryInputOutputPairs: [ InputOutputPair ] ) throws -> [ TypedVirtualPath ] {
241
- var flaggedInputOutputPairs : [ ( flag: String , InputOutputPair ) ] = [ ]
240
+ primaryInputs: [ TypedVirtualPath ] ,
241
+ inputOutputMap: [ TypedVirtualPath : TypedVirtualPath ] ) throws -> [ TypedVirtualPath ] {
242
+ var flaggedInputOutputPairs : [ ( flag: String , input: TypedVirtualPath ? , output: TypedVirtualPath ) ] = [ ]
242
243
243
244
/// Add output of a particular type, if needed.
244
245
func addOutputOfType(
245
246
outputType: FileType , finalOutputPath: VirtualPath ? ,
246
- primaryPair : InputOutputPair ? , flag: String
247
+ input : TypedVirtualPath ? , flag: String
247
248
) {
248
249
// If there is no final output, there's nothing to do.
249
250
guard let finalOutputPath = finalOutputPath else { return }
@@ -255,125 +256,127 @@ extension Driver {
255
256
// Compute the output path based on the input path (if there is one), or
256
257
// use the final output.
257
258
let outputPath : VirtualPath
258
- if let pair = primaryPair , let input = pair . input {
259
+ if let input = input {
259
260
if let outputFileMapPath = outputFileMap? . existingOutput ( inputFile: input. file, outputType: outputType) {
260
261
outputPath = outputFileMapPath
261
- } else if compilerOutputType != nil {
262
+ } else if let output = inputOutputMap [ input ] , compilerOutputType != nil {
262
263
// Alongside primary output
263
- outputPath = pair . output. file. replacingExtension ( with: outputType)
264
+ outputPath = output. file. replacingExtension ( with: outputType)
264
265
} else {
265
266
outputPath = . temporary( RelativePath ( input. file. basenameWithoutExt. appendingFileTypeExtension ( outputType) ) )
266
267
}
267
268
} else {
268
269
outputPath = finalOutputPath
269
270
}
270
271
271
- flaggedInputOutputPairs. append ( ( flag: flag, InputOutputPair ( input: primaryPair ? . input, output: TypedVirtualPath ( file: outputPath, type: outputType) ) ) )
272
+ flaggedInputOutputPairs. append ( ( flag: flag, input: input, output: TypedVirtualPath ( file: outputPath, type: outputType) ) )
272
273
}
273
274
274
275
/// Add all of the outputs needed for a given input.
275
- func addAllOutputsFor( primaryPair : InputOutputPair ? ) {
276
+ func addAllOutputsFor( input : TypedVirtualPath ? ) {
276
277
if !forceEmitModuleInSingleInvocation {
277
278
addOutputOfType (
278
279
outputType: . swiftModule,
279
280
finalOutputPath: moduleOutputInfo. output? . outputPath,
280
- primaryPair : primaryPair ,
281
+ input : input ,
281
282
flag: " -emit-module-path " )
282
283
addOutputOfType (
283
284
outputType: . swiftDocumentation,
284
285
finalOutputPath: moduleDocOutputPath,
285
- primaryPair : primaryPair ,
286
+ input : input ,
286
287
flag: " -emit-module-doc-path " )
287
288
addOutputOfType (
288
289
outputType: . swiftSourceInfoFile,
289
290
finalOutputPath: moduleSourceInfoPath,
290
- primaryPair : primaryPair ,
291
+ input : input ,
291
292
flag: " -emit-module-source-info-path " )
292
293
addOutputOfType (
293
294
outputType: . dependencies,
294
295
finalOutputPath: dependenciesFilePath,
295
- primaryPair : primaryPair ,
296
+ input : input ,
296
297
flag: " -emit-dependencies-path " )
297
298
}
298
299
299
300
addOutputOfType (
300
301
outputType: . yamlOptimizationRecord,
301
302
finalOutputPath: optimizationRecordPath,
302
- primaryPair : primaryPair ,
303
+ input : input ,
303
304
flag: " -save-optimization-record-path " )
304
305
305
306
addOutputOfType (
306
307
outputType: . diagnostics,
307
308
finalOutputPath: serializedDiagnosticsFilePath,
308
- primaryPair : primaryPair ,
309
+ input : input ,
309
310
flag: " -serialize-diagnostics-path " )
310
311
311
312
#if false
312
313
// FIXME: handle -update-code
313
- addOutputOfType ( outputType: . remap, input: input. file , flag: " -emit-remap-file-path " )
314
+ addOutputOfType ( outputType: . remap, input: input, flag: " -emit-remap-file-path " )
314
315
#endif
315
316
}
316
317
317
318
if compilerMode. usesPrimaryFileInputs {
318
- for pair in primaryInputOutputPairs {
319
- addAllOutputsFor ( primaryPair : pair )
319
+ for input in primaryInputs {
320
+ addAllOutputsFor ( input : input )
320
321
}
321
322
} else {
322
- addAllOutputsFor ( primaryPair : nil )
323
+ addAllOutputsFor ( input : nil )
323
324
324
325
// Outputs that only make sense when the whole module is processed
325
326
// together.
326
327
addOutputOfType (
327
328
outputType: . objcHeader,
328
329
finalOutputPath: objcGeneratedHeaderPath,
329
- primaryPair : nil ,
330
+ input : nil ,
330
331
flag: " -emit-objc-header-path " )
331
332
332
333
addOutputOfType (
333
334
outputType: . swiftInterface,
334
335
finalOutputPath: swiftInterfacePath,
335
- primaryPair : nil ,
336
+ input : nil ,
336
337
flag: " -emit-module-interface-path " )
337
338
338
339
addOutputOfType (
339
340
outputType: . tbd,
340
341
finalOutputPath: tbdPath,
341
- primaryPair : nil ,
342
+ input : nil ,
342
343
flag: " -emit-tbd-path " )
343
344
}
344
345
345
346
// Question: outputs.count > fileListThreshold makes sense, but c++ does the following:
346
- if primaryInputOutputPairs . count * FileType. allCases. count > fileListThreshold {
347
+ if primaryInputs . count * FileType. allCases. count > fileListThreshold {
347
348
var entries = [ VirtualPath: [ FileType: VirtualPath] ] ( )
348
- for pair in primaryInputOutputPairs {
349
- addEntry ( & entries, for: pair)
349
+ for input in primaryInputs {
350
+ if let output = inputOutputMap [ input] {
351
+ addEntry ( & entries, input: input, output: output)
352
+ }
350
353
}
351
- for output in flaggedInputOutputPairs {
352
- addEntry ( & entries, for : output. 1 )
354
+ for flaggedPair in flaggedInputOutputPairs {
355
+ addEntry ( & entries, input : flaggedPair . input , output: flaggedPair . output )
353
356
}
354
357
let outputFileMap = OutputFileMap ( entries: entries)
355
358
let path = RelativePath ( createTemporaryFileName ( prefix: " supplementaryOutputs " ) )
356
359
commandLine. appendFlag ( . supplementaryOutputFileMap)
357
360
commandLine. appendPath ( . fileList( path, . outputFileMap( outputFileMap) ) )
358
361
} else {
359
- for output in flaggedInputOutputPairs {
362
+ for flaggedPair in flaggedInputOutputPairs {
360
363
// Add the appropriate flag.
361
- commandLine. appendFlag ( output . flag)
362
- commandLine. appendPath ( output . 1 . output. file)
364
+ commandLine. appendFlag ( flaggedPair . flag)
365
+ commandLine. appendPath ( flaggedPair . output. file)
363
366
}
364
367
}
365
368
366
- return flaggedInputOutputPairs. map { $0. 1 . output }
369
+ return flaggedInputOutputPairs. map { $0. output }
367
370
}
368
371
369
- func addEntry( _ entries: inout [ VirtualPath : [ FileType : VirtualPath ] ] , for pair : InputOutputPair ) {
372
+ func addEntry( _ entries: inout [ VirtualPath : [ FileType : VirtualPath ] ] , input : TypedVirtualPath ? , output : TypedVirtualPath ) {
370
373
let entryInput : VirtualPath
371
- if let input = pair . input? . file, input != OutputFileMap . singleInputKey {
374
+ if let input = input? . file, input != OutputFileMap . singleInputKey {
372
375
entryInput = input
373
376
} else {
374
377
entryInput = inputFiles [ 0 ] . file
375
378
}
376
- entries [ entryInput, default: [ : ] ] [ pair . output. type] = pair . output. file
379
+ entries [ entryInput, default: [ : ] ] [ output. type] = output. file
377
380
}
378
381
379
382
/// Adds all dependencies required for an explicit module build
0 commit comments