Skip to content

Commit 717cca3

Browse files
authored
[5.9] Rename "CC Destination" to "Swift SDK" (#6425)
"Cross-compilation destination" is a very verbose name. "Swift SDK" (note that this is distinct from just plain "SDK" used in other contexts) is a nicer alternative. Not all of the types and functions were renamed yet, especially `Destination`, which has been present in the codebase for long time. Renaming that type will be potentially source-breaking for libSwiftPM clients. This change is focused on updating user-visible strings and renaming types and functions that were only recently added. CLI subcommands were renamed accordingly.
1 parent bfc1d18 commit 717cca3

30 files changed

+198
-193
lines changed

Package.swift

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -409,8 +409,8 @@ let package = Package(
409409
),
410410

411411
.target(
412-
/** Interacts with cross-compilation destinations */
413-
name: "CrossCompilationDestinationsTool",
412+
/** Interacts with Swift SDKs used for cross-compilation */
413+
name: "SwiftSDKTool",
414414
dependencies: [
415415
.product(name: "ArgumentParser", package: "swift-argument-parser"),
416416
"Basics",
@@ -480,9 +480,9 @@ let package = Package(
480480
exclude: ["CMakeLists.txt"]
481481
),
482482
.executableTarget(
483-
/** Interacts with cross-compilation destinations */
484-
name: "swift-experimental-destination",
485-
dependencies: ["Commands", "CrossCompilationDestinationsTool"],
483+
/** Interacts with Swift SDKs used for cross-compilation */
484+
name: "swift-experimental-sdk",
485+
dependencies: ["Commands", "SwiftSDKTool"],
486486
exclude: ["CMakeLists.txt"]
487487
),
488488
.executableTarget(
@@ -508,7 +508,7 @@ let package = Package(
508508
dependencies: [
509509
"Basics",
510510
"Commands",
511-
"CrossCompilationDestinationsTool",
511+
"SwiftSDKTool",
512512
"PackageCollectionsTool",
513513
"PackageRegistryTool"
514514
],

Sources/Basics/FileSystem/FileSystem+Extensions.swift

Lines changed: 23 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -224,65 +224,63 @@ extension FileSystem {
224224
}
225225
}
226226

227-
// MARK: - cross-compilation destinations
227+
// MARK: - Swift SDKs
228228

229-
private let crossCompilationDestinationsDirectoryName = "destinations"
229+
private let swiftSDKsDirectoryName = "swift-sdks"
230230

231231
extension FileSystem {
232-
/// SwiftPM cross-compilation destinations directory (if exists)
233-
public var swiftPMCrossCompilationDestinationsDirectory: AbsolutePath {
232+
/// Path to Swift SDKs directory (if exists)
233+
public var swiftSDKsDirectory: AbsolutePath {
234234
get throws {
235235
if let path = try idiomaticSwiftPMDirectory {
236-
return path.appending(component: crossCompilationDestinationsDirectoryName)
236+
return path.appending(component: swiftSDKsDirectoryName)
237237
} else {
238-
return try dotSwiftPMCrossCompilationDestinationsDirectory
238+
return try dotSwiftPMSwiftSDKsDirectory
239239
}
240240
}
241241
}
242242

243-
fileprivate var dotSwiftPMCrossCompilationDestinationsDirectory: AbsolutePath {
243+
fileprivate var dotSwiftPMSwiftSDKsDirectory: AbsolutePath {
244244
get throws {
245-
return try dotSwiftPM.appending(component: crossCompilationDestinationsDirectoryName)
245+
return try dotSwiftPM.appending(component: swiftSDKsDirectoryName)
246246
}
247247
}
248248

249-
public func getSharedCrossCompilationDestinationsDirectory(
250-
explicitDirectory: AbsolutePath?
251-
) throws -> AbsolutePath? {
252-
if let explicitDestinationsDirectory = explicitDirectory {
249+
public func getSharedSwiftSDKsDirectory(explicitDirectory: AbsolutePath?) throws -> AbsolutePath? {
250+
if let explicitDirectory {
253251
// Create the explicit SDKs path if necessary
254-
if !exists(explicitDestinationsDirectory) {
255-
try createDirectory(explicitDestinationsDirectory, recursive: true)
252+
if !exists(explicitDirectory) {
253+
try createDirectory(explicitDirectory, recursive: true)
256254
}
257-
return explicitDestinationsDirectory
255+
return explicitDirectory
258256
} else {
259-
return try swiftPMCrossCompilationDestinationsDirectory
257+
return try swiftSDKsDirectory
260258
}
261259
}
262260

263-
public func getOrCreateSwiftPMCrossCompilationDestinationsDirectory() throws -> AbsolutePath {
264-
let idiomaticDestinationsDirectory = try swiftPMCrossCompilationDestinationsDirectory
261+
public func getOrCreateSwiftPMSwiftSDKsDirectory() throws -> AbsolutePath {
262+
let idiomaticSwiftSDKDirectory = try swiftSDKsDirectory
265263

266264
// Create idiomatic if necessary
267-
if !exists(idiomaticDestinationsDirectory) {
268-
try createDirectory(idiomaticDestinationsDirectory, recursive: true)
265+
if !exists(idiomaticSwiftSDKDirectory) {
266+
try createDirectory(idiomaticSwiftSDKDirectory, recursive: true)
269267
}
270268
// Create ~/.swiftpm if necessary
271269
if !exists(try dotSwiftPM) {
272270
try createDirectory(dotSwiftPM, recursive: true)
273271
}
274-
// Create ~/.swiftpm/destinations symlink if necessary
272+
// Create ~/.swiftpm/swift-sdks symlink if necessary
275273
// locking ~/.swiftpm to protect from concurrent access
276274
try withLock(on: dotSwiftPM, type: .exclusive) {
277-
if !exists(try dotSwiftPMCrossCompilationDestinationsDirectory, followSymlink: false) {
275+
if !exists(try dotSwiftPMSwiftSDKsDirectory, followSymlink: false) {
278276
try createSymbolicLink(
279-
dotSwiftPMCrossCompilationDestinationsDirectory,
280-
pointingAt: idiomaticDestinationsDirectory,
277+
dotSwiftPMSwiftSDKsDirectory,
278+
pointingAt: idiomaticSwiftSDKDirectory,
281279
relative: false
282280
)
283281
}
284282
}
285-
return idiomaticDestinationsDirectory
283+
return idiomaticSwiftSDKDirectory
286284
}
287285
}
288286

Sources/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ add_subdirectory(Build)
1212
add_subdirectory(Commands)
1313
add_subdirectory(CompilerPluginSupport)
1414
add_subdirectory(CoreCommands)
15-
add_subdirectory(CrossCompilationDestinationsTool)
15+
add_subdirectory(SwiftSDKTool)
1616
add_subdirectory(DriverSupport)
1717
add_subdirectory(LLBuildManifest)
1818
add_subdirectory(PackageCollections)
@@ -35,7 +35,7 @@ add_subdirectory(SPMBuildCore)
3535
add_subdirectory(SPMLLBuild)
3636
add_subdirectory(swift-bootstrap)
3737
add_subdirectory(swift-build)
38-
add_subdirectory(swift-experimental-destination)
38+
add_subdirectory(swift-experimental-sdk)
3939
add_subdirectory(swift-package)
4040
add_subdirectory(swift-package-collection)
4141
add_subdirectory(swift-package-registry)

Sources/CoreCommands/Options.swift

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -107,8 +107,9 @@ public struct LocationOptions: ParsableArguments {
107107
@Option(name: .customLong("destination"), help: .hidden, completion: .directory)
108108
public var customCompileDestination: AbsolutePath?
109109

110-
@Option(name: .customLong("experimental-destinations-path"), help: .hidden, completion: .directory)
111-
public var crossCompilationDestinationsDirectory: AbsolutePath?
110+
/// Path to the directory containing installed Swift SDKs.
111+
@Option(name: .customLong("experimental-swift-sdks-path"), help: .hidden, completion: .directory)
112+
public var swiftSDKsDirectory: AbsolutePath?
112113

113114
@Option(
114115
name: .customLong("pkg-config-path"),
@@ -398,9 +399,9 @@ public struct BuildOptions: ParsableArguments {
398399
)
399400
public var architectures: [String] = []
400401

401-
/// Path to the compilation destination describing JSON file.
402-
@Option(name: .customLong("experimental-destination-selector"), help: .hidden)
403-
public var crossCompilationDestinationSelector: String?
402+
/// Filter for selecting a specific Swift SDK to build with.
403+
@Option(name: .customLong("experimental-swift-sdk"), help: .hidden)
404+
public var swiftSDKSelector: String?
404405

405406
/// Which compile-time sanitizers should be enabled.
406407
@Option(

Sources/CoreCommands/SwiftTool.swift

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ public final class SwiftTool {
209209
public let sharedConfigurationDirectory: AbsolutePath?
210210

211211
/// Path to the cross-compilation destinations directory.
212-
public let sharedCrossCompilationDestinationsDirectory: AbsolutePath?
212+
public let sharedSwiftSDKsDirectory: AbsolutePath?
213213

214214
/// Cancellator to handle cancellation of outstanding work when handling SIGINT
215215
public let cancellator: Cancellator
@@ -336,10 +336,9 @@ public final class SwiftTool {
336336
fileSystem: fileSystem
337337
)
338338
self.sharedCacheDirectory = try getSharedCacheDirectory(options: options, fileSystem: fileSystem)
339-
self.sharedCrossCompilationDestinationsDirectory = try fileSystem
340-
.getSharedCrossCompilationDestinationsDirectory(
341-
explicitDirectory: options.locations.crossCompilationDestinationsDirectory
342-
)
339+
self.sharedSwiftSDKsDirectory = try fileSystem.getSharedSwiftSDKsDirectory(
340+
explicitDirectory: options.locations.swiftSDKsDirectory
341+
)
343342

344343
// set global process logging handler
345344
Process.loggingHandler = { self.observabilityScope.emit(debug: $0) }
@@ -744,11 +743,11 @@ public final class SwiftTool {
744743
let targetDestination = Destination.defaultDestination(for: triple, host: hostDestination)
745744
{
746745
destination = targetDestination
747-
} else if let destinationSelector = options.build.crossCompilationDestinationSelector {
748-
destination = try DestinationBundle.selectDestination(
749-
fromBundlesAt: sharedCrossCompilationDestinationsDirectory,
746+
} else if let swiftSDKSelector = options.build.swiftSDKSelector {
747+
destination = try SwiftSDKBundle.selectBundle(
748+
fromBundlesAt: sharedSwiftSDKsDirectory,
750749
fileSystem: fileSystem,
751-
matching: destinationSelector,
750+
matching: swiftSDKSelector,
752751
hostTriple: hostTriple,
753752
observabilityScope: observabilityScope
754753
)

Sources/PackageModel/ArtifactsArchiveMetadata.swift

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,14 @@ public struct ArtifactsArchiveMetadata: Equatable {
3838
}
3939

4040
// In the future we are likely to extend the ArtifactsArchive file format to carry other types of artifacts beyond
41-
// executables and cross-compilation destinations. Additional fields may be required to support these new artifact
41+
// executables and Swift SDKs. Additional fields may be required to support these new artifact
4242
// types e.g. headers path for libraries. This can also support resource-only artifacts as well. For example,
4343
// 3d models along with associated textures, or fonts, etc.
4444
public enum ArtifactType: String, RawRepresentable, Decodable {
4545
case executable
46+
case swiftSDK
47+
48+
// Can't be marked as formally deprecated as we still need to use this value for warning users.
4649
case crossCompilationDestination
4750
}
4851

Sources/PackageModel/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,6 @@ add_library(PackageModel
1313
BuildFlags.swift
1414
BuildSettings.swift
1515
Destination.swift
16-
DestinationConfigurationStore.swift
17-
DestinationBundle.swift
1816
Diagnostics.swift
1917
IdentityResolver.swift
2018
Manifest/Manifest.swift
@@ -44,6 +42,8 @@ add_library(PackageModel
4442
Sources.swift
4543
SupportedLanguageExtension.swift
4644
SwiftLanguageVersion.swift
45+
SwiftSDKConfigurationStore.swift
46+
SwiftSDKBundle.swift
4747
Target.swift
4848
Toolchain.swift
4949
ToolchainConfiguration.swift

Sources/PackageModel/Destination.swift

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -63,33 +63,33 @@ extension DestinationError: CustomStringConvertible {
6363
return problem
6464
case .invalidBundleName(let name):
6565
return """
66-
invalid bundle name `\(name)`, unpacked destination bundles are expected to have `.artifactbundle` extension
66+
invalid bundle name `\(name)`, unpacked Swift SDK bundles are expected to have `.artifactbundle` extension
6767
"""
6868
case .noDestinationsDecoded(let path):
69-
return "no valid destinations were decoded from a destination file at path `\(path)`"
69+
return "no valid Swift SDKs were decoded from a destination file at path `\(path)`"
7070
case .pathIsNotDirectory(let path):
7171
return "path expected to be a directory is not a directory or doesn't exist: `\(path)`"
7272
case .unserializableDestination:
7373
return """
74-
destination couldn't be serialized with the latest serialization schema, potentially because it \
75-
was deserialized from an earlier incompatible schema version or initialized manually with missing \
74+
Swift SDK configuration couldn't be serialized with the latest serialization schema, potentially because \
75+
it was deserialized from an earlier incompatible schema version or initialized manually with missing \
7676
properties required for initialization
7777
"""
7878
case .destinationNotFound(let artifactID, let buildTimeTriple, let runTimeTriple):
7979
return """
80-
destination with ID `\(artifactID)`, build-time triple \(buildTimeTriple), and run-time triple \
80+
Swift SDK with ID `\(artifactID)`, build-time triple \(buildTimeTriple), and run-time triple \
8181
\(runTimeTriple) is not currently installed.
8282
"""
8383
case .destinationBundleAlreadyInstalled(let bundleName):
8484
return """
85-
destination artifact bundle with name `\(bundleName)` is already installed. Can't install a new bundle \
85+
Swift SDK bundle with name `\(bundleName)` is already installed. Can't install a new bundle \
8686
with the same name.
8787
"""
8888
case .destinationArtifactAlreadyInstalled(let installedBundleName, let newBundleName, let artifactID):
8989
return """
90-
A destination with artifact ID `\(artifactID)` is already included in an installed bundle with name \
90+
A Swift SDK with artifact ID `\(artifactID)` is already included in an installed bundle with name \
9191
`\(installedBundleName)`. Can't install a new bundle `\(newBundleName)` with this artifact, artifact IDs \
92-
are expected to be unique across all installed bundles.
92+
are expected to be unique across all installed Swift SDK bundles.
9393
"""
9494
}
9595
}

0 commit comments

Comments
 (0)