@@ -343,10 +343,9 @@ public struct Driver {
343
343
/// expand response files, etc. By default this is the local filesystem.
344
344
/// - Parameter executor: Used by the driver to execute jobs. The default argument
345
345
/// is present to streamline testing, it shouldn't be used in production.
346
- /// - Parameter externalTargetModulePathMap: All external artifacts a build system may pass in as input to the explicit
347
- /// build of the current module. Consists of a map of externally-built targets, and their corresponding binary modules.
348
- /// - Parameter interModuleDependencyOracle: A dependency oracle instance, re-used in multiple-target builds
349
- /// to make use of caching of common dependency scanning queries
346
+ /// - Parameter externalBuildArtifacts: All external artifacts a build system may pass in as input to the explicit
347
+ /// build of the current module. Consists of a map of externally-built targets, and a map of all previously
348
+ /// discovered/scanned modules.
350
349
public init (
351
350
args: [ String ] ,
352
351
env: [ String : String ] = ProcessEnv . vars,
@@ -355,6 +354,9 @@ public struct Driver {
355
354
executor: DriverExecutor ,
356
355
integratedDriver: Bool = true ,
357
356
compilerExecutableDir: AbsolutePath ? = nil ,
357
+ // FIXME: Duplication with externalBuildArtifacts and externalTargetModulePathMap
358
+ // is a temporary backwards-compatibility shim to help transition SwiftPM to the new API
359
+ externalBuildArtifacts: ExternalBuildArtifacts ? = nil ,
358
360
externalTargetModulePathMap: ExternalTargetModulePathMap ? = nil ,
359
361
interModuleDependencyOracle: InterModuleDependencyOracle ? = nil
360
362
) throws {
@@ -365,6 +367,12 @@ public struct Driver {
365
367
self . diagnosticEngine = diagnosticsEngine
366
368
self . executor = executor
367
369
370
+ if let externalArtifacts = externalBuildArtifacts {
371
+ self . externalBuildArtifacts = externalArtifacts
372
+ } else if let externalTargetPaths = externalTargetModulePathMap {
373
+ self . externalBuildArtifacts = ( externalTargetPaths, [ : ] )
374
+ }
375
+
368
376
if case . subcommand = try Self . invocationRunMode ( forArgs: args) . mode {
369
377
throw Error . subcommandPassedToDriver
370
378
}
@@ -455,6 +463,14 @@ public struct Driver {
455
463
self . interModuleDependencyOracle = dependencyOracle
456
464
} else {
457
465
self . interModuleDependencyOracle = InterModuleDependencyOracle ( )
466
+
467
+ // This is a shim for backwards-compatibility with ModuleInfoMap-based API
468
+ // used by SwiftPM
469
+ if let externalArtifacts = externalBuildArtifacts {
470
+ if !externalArtifacts. 1 . isEmpty {
471
+ try self . interModuleDependencyOracle. mergeModules ( from: externalArtifacts. 1 )
472
+ }
473
+ }
458
474
}
459
475
460
476
self . fileListThreshold = try Self . computeFileListThreshold ( & self . parsedOptions, diagnosticsEngine: diagnosticsEngine)
0 commit comments