Skip to content

Commit 584f181

Browse files
committed
[Explicit Module Builds] Add another shim for backwards-compatibility with API currently used by SwiftPM to communicate external build artifacts
1 parent b3fc65a commit 584f181

File tree

2 files changed

+20
-8
lines changed

2 files changed

+20
-8
lines changed

Sources/SwiftDriver/Driver/Driver.swift

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -321,7 +321,10 @@ public struct Driver {
321321
diagnosticsEngine: DiagnosticsEngine = DiagnosticsEngine(handlers: [Driver.stderrDiagnosticsHandler]),
322322
fileSystem: FileSystem = localFileSystem,
323323
executor: DriverExecutor,
324+
// FIXME: Duplication with externalBuildArtifacts and externalTargetModulePathMap
325+
// is a temporary backwards-compatibility shim to help transition SwiftPM to the new API
324326
externalBuildArtifacts: ExternalBuildArtifacts? = nil,
327+
externalTargetModulePathMap: ExternalTargetModulePathMap? = nil,
325328
interModuleDependencyOracle: InterModuleDependencyOracle? = nil
326329
) throws {
327330
self.env = env
@@ -330,7 +333,11 @@ public struct Driver {
330333
self.diagnosticEngine = diagnosticsEngine
331334
self.executor = executor
332335

333-
self.externalBuildArtifacts = externalBuildArtifacts
336+
if let externalArtifacts = externalBuildArtifacts {
337+
self.externalBuildArtifacts = externalArtifacts
338+
} else if let externalTargetPaths = externalTargetModulePathMap {
339+
self.externalBuildArtifacts = (externalTargetPaths, [:])
340+
}
334341

335342
if case .subcommand = try Self.invocationRunMode(forArgs: args).mode {
336343
throw Error.subcommandPassedToDriver
@@ -399,8 +406,8 @@ public struct Driver {
399406
}
400407
}
401408
}
402-
403-
do {
409+
410+
do {
404411
let outputFileMap: OutputFileMap?
405412
// Initialize an empty output file map, which will be populated when we start creating jobs.
406413
if let outputFileMapArg = parsedOptions.getLastArgument(.outputFileMap)?.asSingle {
@@ -410,12 +417,14 @@ public struct Driver {
410417
} catch {
411418
throw Error.unableToLoadOutputFileMap(outputFileMapArg)
412419
}
420+
} else {
421+
outputFileMap = nil
422+
}
413423

414-
if let workingDirectory = self.workingDirectory {
415-
self.outputFileMap = outputFileMap?.resolveRelativePaths(relativeTo: workingDirectory)
416-
} else {
417-
self.outputFileMap = outputFileMap
418-
}
424+
if let workingDirectory = self.workingDirectory {
425+
self.outputFileMap = outputFileMap?.resolveRelativePaths(relativeTo: workingDirectory)
426+
} else {
427+
self.outputFileMap = outputFileMap
419428
}
420429
}
421430

Sources/SwiftDriver/Explicit Module Builds/ExplicitDependencyBuildPlanner.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ import Foundation
1515

1616
/// A map from a module identifier to a path to its .swiftmodule file.
1717
public typealias ExternalTargetModulePathMap = [ModuleDependencyId: AbsolutePath]
18+
19+
// FIXME: ExternalBuildArtifacts is a temporary backwards-compatibility shim
20+
// to help transition SwiftPM to the new API.
1821
/// A tuple all external artifacts a build system may pass in as input to the explicit build of the current module
1922
/// Consists of a map of externally-built targets, and a map of all previously discovered/scanned modules.
2023
public typealias ExternalBuildArtifacts = (ExternalTargetModulePathMap, ModuleInfoMap)

0 commit comments

Comments
 (0)