Skip to content

Commit b1d4dff

Browse files
authored
Merge pull request #126 from artemcm/EMB-VersionedPCM-Refactor
[Explicit Module Builds] Add support for versioned PCMs
2 parents 64f3fcb + 1629738 commit b1d4dff

11 files changed

+509
-249
lines changed

Sources/SwiftDriver/CMakeLists.txt

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,10 @@
77
# See http://swift.org/CONTRIBUTORS.txt for Swift project authors
88

99
add_library(SwiftDriver
10-
"Dependency Scanning/ModuleDependencyBuildGeneration.swift"
11-
"Dependency Scanning/InterModuleDependencyGraph.swift"
10+
"Explicit Module Builds/ClandModuleBuildJobCache.swift"
11+
"Explicit Module Builds/ExplicitModuleBuildHandler.swift"
12+
"Explicit Module Builds/InterModuleDependencyGraph.swift"
13+
"Explicit Module Builds/ModuleDependencyScanning.swift"
1214

1315
Driver/CompilerMode.swift
1416
Driver/DebugInfo.swift
@@ -17,7 +19,6 @@ add_library(SwiftDriver
1719
Driver/ModuleOutputInfo.swift
1820
Driver/OutputFileMap.swift
1921
Driver/ToolExecutionDelegate.swift
20-
Driver/ModuleDependencyScanning.swift
2122

2223
Execution/JobExecutor.swift
2324
Execution/ParsableOutput.swift

Sources/SwiftDriver/Dependency Scanning/ModuleDependencyBuildGeneration.swift

Lines changed: 0 additions & 160 deletions
This file was deleted.

Sources/SwiftDriver/Driver/Driver.swift

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ public struct Driver {
2626
case conflictingOptions(Option, Option)
2727
// Explicit Module Build Failures
2828
case malformedModuleDependency(String, String)
29+
case missingPCMArguments(String)
2930
case missingModuleDependency(String)
3031
case dependencyScanningFailure(Int, String)
3132

@@ -49,6 +50,8 @@ public struct Driver {
4950
// Explicit Module Build Failures
5051
case .malformedModuleDependency(let moduleName, let errorDescription):
5152
return "Malformed Module Dependency: \(moduleName), \(errorDescription)"
53+
case .missingPCMArguments(let moduleName):
54+
return "Missing extraPcmArgs to build Clang module: \(moduleName)"
5255
case .missingModuleDependency(let moduleName):
5356
return "Missing Module Dependency Info: \(moduleName)"
5457
case .dependencyScanningFailure(let code, let error):
@@ -169,10 +172,10 @@ public struct Driver {
169172
/// This will force the driver to first emit the module and then run compile jobs.
170173
public var forceEmitModuleInSingleInvocation: Bool = false
171174

172-
/// The module dependency graph, which is populated during the planning phase
173-
/// only when all modules will be prebuilt and treated as explicit by the
174-
/// various compilation jobs.
175-
public var interModuleDependencyGraph: InterModuleDependencyGraph? = nil
175+
/// Handler for constructing module build jobs using Explicit Module Builds.
176+
/// Constructed during the planning phase only when all modules will be prebuilt and treated
177+
/// as explicit by the various compilation jobs.
178+
public var explicitModuleBuildHandler: ExplicitModuleBuildHandler? = nil
176179

177180
/// Handler for emitting diagnostics to stderr.
178181
public static let stderrDiagnosticsHandler: DiagnosticsEngine.DiagnosticsHandler = { diagnostic in
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
//===----------------- ClangModuleBuildJobCache.swift ---------------------===//
2+
//
3+
// This source file is part of the Swift.org open source project
4+
//
5+
// Copyright (c) 2020 Apple Inc. and the Swift project authors
6+
// Licensed under Apache License v2.0 with Runtime Library Exception
7+
//
8+
// See https://swift.org/LICENSE.txt for license information
9+
// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
10+
//
11+
//===----------------------------------------------------------------------===//
12+
13+
/// Maps tuples (ModuleDependencyId, [String]), where [String] is an array of pcm build opitions,
14+
/// to the job used to build this module with these specified build options.
15+
struct ClangModuleBuildJobCache {
16+
17+
/// As tuples cannot be Hashable, wrap (ModuleDependencyId, [String]) into a struct pair
18+
private struct ModuleArgumentPair : Hashable {
19+
let moduleId: ModuleDependencyId
20+
let buildArgs: [String]
21+
}
22+
23+
private var cache: [ModuleArgumentPair: Job] = [:]
24+
25+
var allJobs: [Job] {
26+
return Array(cache.values)
27+
}
28+
29+
subscript(index: (ModuleDependencyId, [String])) -> Job? {
30+
get {
31+
return cache[ModuleArgumentPair(moduleId: index.0, buildArgs: index.1)]
32+
}
33+
set(newValue) {
34+
cache[ModuleArgumentPair(moduleId: index.0, buildArgs: index.1)] = newValue
35+
}
36+
}
37+
}
38+

0 commit comments

Comments
 (0)