Skip to content

Commit b39174f

Browse files
authored
Revert "Remove deprecated externalBuildArtifacts API."
1 parent c753f64 commit b39174f

File tree

2 files changed

+23
-7
lines changed

2 files changed

+23
-7
lines changed

Sources/SwiftDriver/Driver/Driver.swift

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -343,10 +343,9 @@ public struct Driver {
343343
/// expand response files, etc. By default this is the local filesystem.
344344
/// - Parameter executor: Used by the driver to execute jobs. The default argument
345345
/// 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.
350349
public init(
351350
args: [String],
352351
env: [String: String] = ProcessEnv.vars,
@@ -355,6 +354,9 @@ public struct Driver {
355354
executor: DriverExecutor,
356355
integratedDriver: Bool = true,
357356
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,
358360
externalTargetModulePathMap: ExternalTargetModulePathMap? = nil,
359361
interModuleDependencyOracle: InterModuleDependencyOracle? = nil
360362
) throws {
@@ -365,6 +367,12 @@ public struct Driver {
365367
self.diagnosticEngine = diagnosticsEngine
366368
self.executor = executor
367369

370+
if let externalArtifacts = externalBuildArtifacts {
371+
self.externalBuildArtifacts = externalArtifacts
372+
} else if let externalTargetPaths = externalTargetModulePathMap {
373+
self.externalBuildArtifacts = (externalTargetPaths, [:])
374+
}
375+
368376
if case .subcommand = try Self.invocationRunMode(forArgs: args).mode {
369377
throw Error.subcommandPassedToDriver
370378
}
@@ -455,6 +463,14 @@ public struct Driver {
455463
self.interModuleDependencyOracle = dependencyOracle
456464
} else {
457465
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+
}
458474
}
459475

460476
self.fileListThreshold = try Self.computeFileListThreshold(&self.parsedOptions, diagnosticsEngine: diagnosticsEngine)

Tests/SwiftDriverTests/ExplicitModuleBuildTests.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ final class ExplicitModuleBuildTests: XCTestCase {
166166
let scanLibPath = try Driver.getScanLibPath(of: driver.toolchain,
167167
hostTriple: driver.hostTriple,
168168
env: ProcessEnv.vars)
169-
let _ = try dependencyOracle
169+
try dependencyOracle
170170
.verifyOrCreateScannerInstance(fileSystem: localFileSystem,
171171
swiftScanLibPath: scanLibPath)
172172
try dependencyOracle.mergeModules(from: moduleDependencyGraph)
@@ -246,12 +246,12 @@ final class ExplicitModuleBuildTests: XCTestCase {
246246
"test.swift", "-module-name", "A", "-g"]
247247

248248
var driver = try Driver(args: commandLine, executor: executor,
249-
externalTargetModulePathMap: targetModulePathMap,
249+
externalBuildArtifacts: (targetModulePathMap, [:]),
250250
interModuleDependencyOracle: dependencyOracle)
251251
let scanLibPath = try Driver.getScanLibPath(of: driver.toolchain,
252252
hostTriple: driver.hostTriple,
253253
env: ProcessEnv.vars)
254-
let _ = try dependencyOracle
254+
try dependencyOracle
255255
.verifyOrCreateScannerInstance(fileSystem: localFileSystem,
256256
swiftScanLibPath: scanLibPath)
257257

0 commit comments

Comments
 (0)