Skip to content

Commit 287acd3

Browse files
committed
Reduce some API surface by using SPI and internal access levels.
1 parent 0b620cf commit 287acd3

20 files changed

+65
-65
lines changed

Sources/SwiftDriver/Driver/CompilerMode.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
//
1111
//===----------------------------------------------------------------------===//
1212
/// The mode of the compiler.
13-
public enum CompilerMode: Equatable {
13+
@_spi(Testing) public enum CompilerMode: Equatable {
1414
/// A standard compilation, using multiple frontend invocations and -primary-file.
1515
case standardCompile
1616

@@ -33,7 +33,7 @@ public enum CompilerMode: Equatable {
3333

3434
/// Information about batch mode, which is used to determine how to form
3535
/// the batches of jobs.
36-
public struct BatchModeInfo: Equatable {
36+
@_spi(Testing) public struct BatchModeInfo: Equatable {
3737
let seed: Int?
3838
let count: Int?
3939
let sizeLimit: Int?

Sources/SwiftDriver/Driver/DebugInfo.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
//===----------------------------------------------------------------------===//
1212

1313
/// The debug information produced by the driver.
14-
public struct DebugInfo {
14+
@_spi(Testing) public struct DebugInfo {
1515

1616
/// Describes the format used for debug information.
1717
public enum Format: String {

Sources/SwiftDriver/Driver/Driver.swift

Lines changed: 38 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -90,30 +90,30 @@ public struct Driver {
9090
public let env: [String: String]
9191

9292
/// The file system which we should interact with.
93-
public let fileSystem: FileSystem
93+
let fileSystem: FileSystem
9494

9595
/// Diagnostic engine for emitting warnings, errors, etc.
9696
public let diagnosticEngine: DiagnosticsEngine
9797

9898
/// The executor the driver uses to run jobs.
99-
public let executor: DriverExecutor
99+
let executor: DriverExecutor
100100

101101
/// The toolchain to use for resolution.
102-
public let toolchain: Toolchain
102+
@_spi(Testing) public let toolchain: Toolchain
103103

104104
/// Information about the target, as reported by the Swift frontend.
105-
let frontendTargetInfo: FrontendTargetInfo
105+
@_spi(Testing) public let frontendTargetInfo: FrontendTargetInfo
106106

107107
/// The target triple.
108-
public var targetTriple: Triple { frontendTargetInfo.target.triple }
108+
@_spi(Testing) public var targetTriple: Triple { frontendTargetInfo.target.triple }
109109

110110
/// The variant target triple.
111-
public var targetVariantTriple: Triple? {
111+
var targetVariantTriple: Triple? {
112112
frontendTargetInfo.targetVariant?.triple
113113
}
114114

115115
/// The kind of driver.
116-
public let driverKind: DriverKind
116+
let driverKind: DriverKind
117117

118118
/// The option table we're using.
119119
let optionTable: OptionTable
@@ -122,101 +122,101 @@ public struct Driver {
122122
var parsedOptions: ParsedOptions
123123

124124
/// Extra command-line arguments to pass to the Swift compiler.
125-
public let swiftCompilerPrefixArgs: [String]
125+
let swiftCompilerPrefixArgs: [String]
126126

127127
/// The working directory for the driver, if there is one.
128-
public let workingDirectory: AbsolutePath?
128+
let workingDirectory: AbsolutePath?
129129

130130
/// The set of input files
131-
public let inputFiles: [TypedVirtualPath]
131+
@_spi(Testing) public let inputFiles: [TypedVirtualPath]
132132

133133
/// The last time each input file was modified, recorded at the start of the build.
134-
public let recordedInputModificationDates: [TypedVirtualPath: Date]
134+
@_spi(Testing) public let recordedInputModificationDates: [TypedVirtualPath: Date]
135135

136136
/// The mapping from input files to output files for each kind.
137-
internal let outputFileMap: OutputFileMap?
137+
@_spi(Testing) public let outputFileMap: OutputFileMap?
138138

139139
/// The number of files required before making a file list.
140-
internal let fileListThreshold: Int
140+
let fileListThreshold: Int
141141

142142
/// Should use file lists for inputs (number of inputs exceeds `fileListThreshold`).
143-
public let shouldUseInputFileList: Bool
143+
let shouldUseInputFileList: Bool
144144

145145
/// VirtualPath for shared all sources file list. `nil` if unused.
146-
public let allSourcesFileList: VirtualPath?
146+
let allSourcesFileList: VirtualPath?
147147

148148
/// The mode in which the compiler will execute.
149-
public let compilerMode: CompilerMode
149+
@_spi(Testing) public let compilerMode: CompilerMode
150150

151151
/// The type of the primary output generated by the compiler.
152-
public let compilerOutputType: FileType?
152+
@_spi(Testing) public let compilerOutputType: FileType?
153153

154154
/// The type of the primary output generated by the linker.
155-
public let linkerOutputType: LinkOutputType?
155+
@_spi(Testing) public let linkerOutputType: LinkOutputType?
156156

157157
/// When > 0, the number of threads to use in a multithreaded build.
158-
public let numThreads: Int
158+
@_spi(Testing) public let numThreads: Int
159159

160160
/// The specified maximum number of parallel jobs to execute.
161-
public let numParallelJobs: Int?
161+
@_spi(Testing) public let numParallelJobs: Int?
162162

163163
/// The set of sanitizers that were requested
164-
public let enabledSanitizers: Set<Sanitizer>
164+
let enabledSanitizers: Set<Sanitizer>
165165

166166
/// The debug information to produce.
167-
public let debugInfo: DebugInfo
167+
@_spi(Testing) public let debugInfo: DebugInfo
168168

169169
// The information about the module to produce.
170-
public let moduleOutputInfo: ModuleOutputInfo
170+
@_spi(Testing) public let moduleOutputInfo: ModuleOutputInfo
171171

172172
/// Code & data for incremental compilation
173-
public let incrementalCompilationState: IncrementalCompilationState
173+
@_spi(Testing) public let incrementalCompilationState: IncrementalCompilationState
174174

175175
/// The path of the SDK.
176-
public var sdkPath: String? {
176+
var sdkPath: String? {
177177
frontendTargetInfo.paths.sdkPath
178178
}
179179

180180
/// The path to the imported Objective-C header.
181-
public let importedObjCHeader: VirtualPath?
181+
let importedObjCHeader: VirtualPath?
182182

183183
/// The path to the pch for the imported Objective-C header.
184-
public let bridgingPrecompiledHeader: VirtualPath?
184+
let bridgingPrecompiledHeader: VirtualPath?
185185

186186
/// Path to the dependencies file.
187-
public let dependenciesFilePath: VirtualPath?
187+
let dependenciesFilePath: VirtualPath?
188188

189189
/// Path to the reference dependencies (.swiftdeps) file.
190-
public let referenceDependenciesFilePath: VirtualPath?
190+
let referenceDependenciesFilePath: VirtualPath?
191191

192192
/// Path to the serialized diagnostics file.
193-
public let serializedDiagnosticsFilePath: VirtualPath?
193+
let serializedDiagnosticsFilePath: VirtualPath?
194194

195195
/// Path to the Objective-C generated header.
196-
public let objcGeneratedHeaderPath: VirtualPath?
196+
let objcGeneratedHeaderPath: VirtualPath?
197197

198198
/// Path to the loaded module trace file.
199-
public let loadedModuleTracePath: VirtualPath?
199+
let loadedModuleTracePath: VirtualPath?
200200

201201
/// Path to the TBD file (text-based dylib).
202-
public let tbdPath: VirtualPath?
202+
let tbdPath: VirtualPath?
203203

204204
/// Path to the module documentation file.
205-
public let moduleDocOutputPath: VirtualPath?
205+
let moduleDocOutputPath: VirtualPath?
206206

207207
/// Path to the Swift interface file.
208-
public let swiftInterfacePath: VirtualPath?
208+
let swiftInterfacePath: VirtualPath?
209209

210210
/// Path to the optimization record.
211-
public let optimizationRecordPath: VirtualPath?
211+
let optimizationRecordPath: VirtualPath?
212212

213213
/// Path to the Swift module source information file.
214-
public let moduleSourceInfoPath: VirtualPath?
214+
let moduleSourceInfoPath: VirtualPath?
215215

216216
/// If the driver should force emit module in a single invocation.
217217
///
218218
/// This will force the driver to first emit the module and then run compile jobs.
219-
public var forceEmitModuleInSingleInvocation: Bool = false
219+
var forceEmitModuleInSingleInvocation: Bool = false
220220

221221
/// Handler for constructing module build jobs using Explicit Module Builds.
222222
/// Constructed during the planning phase only when all modules will be prebuilt and treated

Sources/SwiftDriver/Driver/ModuleOutputInfo.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
//===----------------------------------------------------------------------===//
1212

1313
/// The information about module output produced by the driver.
14-
public struct ModuleOutputInfo {
14+
@_spi(Testing) public struct ModuleOutputInfo {
1515

1616
/// How should the Swift module output be handled?
1717
public enum ModuleOutput: Equatable {

Sources/SwiftDriver/Driver/OutputFileMap.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ public struct OutputFileMap: Hashable, Codable {
7171
}
7272

7373
/// Load the output file map at the given path.
74-
public static func load(
74+
@_spi(Testing) public static func load(
7575
fileSystem: FileSystem,
7676
file: VirtualPath,
7777
diagnosticEngine: DiagnosticsEngine

Sources/SwiftDriver/Driver/ToolExecutionDelegate.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ import Glibc
2323
#endif
2424

2525
/// Delegate for printing execution information on the command-line.
26-
public struct ToolExecutionDelegate: JobExecutionDelegate {
26+
struct ToolExecutionDelegate: JobExecutionDelegate {
2727
public enum Mode {
2828
case verbose
2929
case parsableOutput

Sources/SwiftDriver/Execution/ParsableOutput.swift

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
import Foundation
1414

15-
public struct ParsableMessage {
15+
@_spi(Testing) public struct ParsableMessage {
1616
public enum Kind {
1717
case began(BeganMessage)
1818
case finished(FinishedMessage)
@@ -39,7 +39,7 @@ public struct ParsableMessage {
3939
}
4040
}
4141

42-
public struct BeganMessage: Encodable {
42+
@_spi(Testing) public struct BeganMessage: Encodable {
4343
public struct Output: Encodable {
4444
public let type: String
4545
public let path: String
@@ -79,7 +79,7 @@ public struct BeganMessage: Encodable {
7979
}
8080
}
8181

82-
public struct FinishedMessage: Encodable {
82+
@_spi(Testing) public struct FinishedMessage: Encodable {
8383
let exitStatus: Int
8484
let pid: Int
8585
let output: String?
@@ -103,7 +103,7 @@ public struct FinishedMessage: Encodable {
103103
}
104104
}
105105

106-
public struct SignalledMessage: Encodable {
106+
@_spi(Testing) public struct SignalledMessage: Encodable {
107107
let pid: Int
108108
let output: String?
109109
let errorMessage: String
@@ -124,7 +124,7 @@ public struct SignalledMessage: Encodable {
124124
}
125125
}
126126

127-
extension ParsableMessage: Encodable {
127+
@_spi(Testing) extension ParsableMessage: Encodable {
128128
enum CodingKeys: CodingKey {
129129
case name
130130
case kind

Sources/SwiftDriver/Incremental Compilation/IncrementalCompilationState.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import TSCBasic
1313
import Foundation
1414
import SwiftOptions
1515

16-
public struct IncrementalCompilationState {
16+
@_spi(Testing) public struct IncrementalCompilationState {
1717
public let showIncrementalBuildDecisions: Bool
1818
public let enableIncrementalBuild: Bool
1919
public let buildRecordPath: VirtualPath?

Sources/SwiftDriver/Incremental Compilation/SourceFileDependencyGraph.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
//===----------------------------------------------------------------------===//
1212
import Foundation
1313

14-
public struct SourceFileDependencyGraph {
14+
@_spi(Testing) public struct SourceFileDependencyGraph {
1515
public static let sourceFileProvidesInterfaceSequenceNumber: Int = 0
1616
public static let sourceFileProvidesImplementationSequenceNumber: Int = 1
1717

@@ -52,11 +52,11 @@ public struct SourceFileDependencyGraph {
5252
}
5353
}
5454

55-
public enum DeclAspect: UInt64 {
55+
@_spi(Testing) public enum DeclAspect: UInt64 {
5656
case interface, implementation
5757
}
5858

59-
public struct DependencyKey {
59+
@_spi(Testing) public struct DependencyKey {
6060
public enum Kind: UInt64 {
6161
case topLevel
6262
case nominal

Sources/SwiftDriver/Jobs/PrintTargetInfoJob.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ extension SwiftVersion: Codable {
6262
}
6363

6464
/// Describes information about the target as provided by the Swift frontend.
65-
public struct FrontendTargetInfo: Codable {
65+
@_spi(Testing) public struct FrontendTargetInfo: Codable {
6666
struct CompatibilityLibrary: Codable {
6767
enum Filter: String, Codable {
6868
case all

Sources/SwiftDriver/Toolchains/DarwinToolchain.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import SwiftOptions
1717
/// Toolchain for Darwin-based platforms, such as macOS and iOS.
1818
///
1919
/// FIXME: This class is not thread-safe.
20-
public final class DarwinToolchain: Toolchain {
20+
@_spi(Testing) public final class DarwinToolchain: Toolchain {
2121
public let env: [String: String]
2222

2323
/// Doubles as path cache and point for overriding normal lookup

Sources/SwiftDriver/Toolchains/GenericUnixToolchain.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
import TSCBasic
1313

1414
/// Toolchain for Unix-like systems.
15-
public final class GenericUnixToolchain: Toolchain {
15+
@_spi(Testing) public final class GenericUnixToolchain: Toolchain {
1616
public let env: [String: String]
1717

1818
/// The executor used to run processes used to find tools and retrieve target info.

Sources/SwiftDriver/Toolchains/Toolchain.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ public enum Tool {
2727

2828
/// Describes a toolchain, which includes information about compilers, linkers
2929
/// and other tools required to build Swift code.
30-
public protocol Toolchain {
30+
@_spi(Testing) public protocol Toolchain {
3131
init(env: [String: String], executor: DriverExecutor, fileSystem: FileSystem)
3232

3333
var env: [String: String] { get }
@@ -178,6 +178,6 @@ extension Toolchain {
178178
) throws {}
179179
}
180180

181-
public enum ToolchainError: Swift.Error {
181+
@_spi(Testing) public enum ToolchainError: Swift.Error {
182182
case unableToFind(tool: String)
183183
}

Sources/SwiftDriver/Utilities/DOTJobGraphSerializer.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
import TSCBasic
1313

1414
/// Serializes the job graph to a .dot file
15-
public struct DOTJobGraphSerializer {
15+
@_spi(Testing) public struct DOTJobGraphSerializer {
1616
var kindCounter = [Job.Kind: Int]()
1717
var hasEmittedStyling = Set<String>()
1818
let jobs: [Job]

Sources/SwiftDriver/Utilities/PredictableRandomNumberGenerator.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
/// The generator uses the [xoshiro256**](http://prng.di.unimi.it/xoshiro256starstar.c)
1717
/// algorithm to produce its output. It is initialized using the
1818
/// [splitmix64](http://prng.di.unimi.it/splitmix64.c) algorithm.
19-
public struct PredictableRandomNumberGenerator: RandomNumberGenerator {
19+
@_spi(Testing) public struct PredictableRandomNumberGenerator: RandomNumberGenerator {
2020

2121
var state: (UInt64, UInt64, UInt64, UInt64)
2222

Tests/SwiftDriverTests/AssertDiagnosticsTests.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
//===----------------------------------------------------------------------===//
1212

1313
import XCTest
14-
import SwiftDriver
14+
@_spi(Testing) import SwiftDriver
1515

1616
// Yes, these are meta-tests! `assertDiagnostics(do:)` and friends are
1717
// complicated enough to warrant a few tests of their own. To test that they

Tests/SwiftDriverTests/IncrementalCompilationTests.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
//===----------------------------------------------------------------------===//
1212
import XCTest
1313

14-
import SwiftDriver
14+
@_spi(Testing) import SwiftDriver
1515

1616
final class IncrementalCompilationTests: XCTestCase {
1717
func testInputInfoMapReading() throws {

Tests/SwiftDriverTests/JobExecutorTests.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import XCTest
1313
import TSCBasic
1414
import TSCUtility
1515

16-
import SwiftDriver
16+
@_spi(Testing) import SwiftDriver
1717

1818
extension Job.ArgTemplate: ExpressibleByStringLiteral {
1919
public init(stringLiteral value: String) {

Tests/SwiftDriverTests/ParsableMessageTests.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
import XCTest
1313
import Foundation
1414

15-
import SwiftDriver
15+
@_spi(Testing) import SwiftDriver
1616

1717
final class ParsableMessageTests: XCTestCase {
1818
func testBeganMessage() throws {

0 commit comments

Comments
 (0)