Skip to content

Commit 4aa8d78

Browse files
authored
Bring back experimental-sdk as deprecated for compatibility (#7512)
There are enough users of this command and corresponding options on `swift build` in the wild. These should be deprecated first before removing.
1 parent b0b652c commit 4aa8d78

File tree

9 files changed

+76
-3
lines changed

9 files changed

+76
-3
lines changed

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,12 @@ Note: This is in reverse chronological order, so newer entries are added to the
33
Swift 6.0
44
-----------
55

6+
* [#7507]
7+
8+
`swift experimental-sdk` command is deprecated with `swift sdk` command replacing it. `--experimental-swift-sdk` and
9+
`--experimental-swift-sdks-path` options on `swift build` are deprecated with replacements that don't have the
10+
`experimental` prefix.
11+
612
* [#7202]
713

814
Package manifests can now access information about the Git repository the given package is in via the context object's
@@ -403,3 +409,4 @@ Swift 3.0
403409
[#7118]: https://github.com/apple/swift-package-manager/pull/7118
404410
[#7201]: https://github.com/apple/swift-package-manager/pull/7201
405411
[#7202]: https://github.com/apple/swift-package-manager/pull/7202
412+
[#7505]: https://github.com/apple/swift-package-manager/pull/7507

Package.swift

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -533,6 +533,12 @@ let package = Package(
533533
dependencies: ["Commands", "SwiftSDKCommand"],
534534
exclude: ["CMakeLists.txt"]
535535
),
536+
.executableTarget(
537+
/** Deprecated command superseded by `swift-sdk` */
538+
name: "swift-experimental-sdk",
539+
dependencies: ["Commands", "SwiftSDKCommand"],
540+
exclude: ["CMakeLists.txt"]
541+
),
536542
.executableTarget(
537543
/** Runs package tests */
538544
name: "swift-test",

Sources/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ add_subdirectory(SPMLLBuild)
3232
add_subdirectory(SPMSQLite3)
3333
add_subdirectory(swift-bootstrap)
3434
add_subdirectory(swift-build)
35+
add_subdirectory(swift-experimental-sdk)
3536
add_subdirectory(swift-sdk)
3637
add_subdirectory(swift-package)
3738
add_subdirectory(swift-run)

Sources/CoreCommands/Options.swift

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,9 @@ package struct LocationOptions: ParsableArguments {
111111
@Option(name: .customLong("destination"), help: .hidden, completion: .directory)
112112
package var customCompileDestination: AbsolutePath?
113113

114+
@Option(name: .customLong("experimental-swift-sdks-path"), help: .hidden, completion: .directory)
115+
package var deprecatedSwiftSDKsDirectory: AbsolutePath?
116+
114117
/// Path to the directory containing installed Swift SDKs.
115118
@Option(
116119
name: .customLong("swift-sdks-path"),
@@ -410,6 +413,9 @@ package struct BuildOptions: ParsableArguments {
410413
)
411414
package var architectures: [String] = []
412415

416+
@Option(name: .customLong("experimental-swift-sdk"), help: .hidden)
417+
package var deprecatedSwiftSDKSelector: String?
418+
413419
/// Filter for selecting a specific Swift SDK to build with.
414420
@Option(
415421
name: .customLong("swift-sdk"),

Sources/CoreCommands/SwiftCommandState.swift

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -350,8 +350,13 @@ package final class SwiftCommandState {
350350
fileSystem: fileSystem
351351
)
352352
self.sharedCacheDirectory = try getSharedCacheDirectory(options: options, fileSystem: fileSystem)
353+
if options.locations.deprecatedSwiftSDKsDirectory != nil {
354+
self.observabilityScope.emit(
355+
warning: "`--experimental-swift-sdks-path` is deprecated and will be removed in a future version of SwiftPM. Use `--swift-sdks-path` instead."
356+
)
357+
}
353358
self.sharedSwiftSDKsDirectory = try fileSystem.getSharedSwiftSDKsDirectory(
354-
explicitDirectory: options.locations.swiftSDKsDirectory
359+
explicitDirectory: options.locations.swiftSDKsDirectory ?? options.locations.deprecatedSwiftSDKsDirectory
355360
)
356361

357362
// set global process logging handler
@@ -820,14 +825,20 @@ package final class SwiftCommandState {
820825
do {
821826
let hostToolchain = try _hostToolchain.get()
822827
hostSwiftSDK = hostToolchain.swiftSDK
828+
829+
if options.build.deprecatedSwiftSDKSelector != nil {
830+
self.observabilityScope.emit(
831+
warning: "`--experimental-swift-sdk` is deprecated and will be removed in a future version of SwiftPM. Use `--swift-sdk` instead."
832+
)
833+
}
823834
swiftSDK = try SwiftSDK.deriveTargetSwiftSDK(
824835
hostSwiftSDK: hostSwiftSDK,
825836
hostTriple: hostToolchain.targetTriple,
826837
customCompileDestination: options.locations.customCompileDestination,
827838
customCompileTriple: options.build.customCompileTriple,
828839
customCompileToolchain: options.build.customCompileToolchain,
829840
customCompileSDK: options.build.customCompileSDK,
830-
swiftSDKSelector: options.build.swiftSDKSelector,
841+
swiftSDKSelector: options.build.swiftSDKSelector ?? options.build.deprecatedSwiftSDKSelector,
831842
architectures: options.build.architectures,
832843
store: store,
833844
observabilityScope: self.observabilityScope,
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# This source file is part of the Swift open source project
2+
#
3+
# Copyright (c) 2023 Apple Inc. and the Swift project authors
4+
# Licensed under Apache License v2.0 with Runtime Library Exception
5+
#
6+
# See http://swift.org/LICENSE.txt for license information
7+
# See http://swift.org/CONTRIBUTORS.txt for Swift project authors
8+
9+
add_executable(swift-experimental-sdk
10+
Entrypoint.swift)
11+
target_link_libraries(swift-experimental-sdk PRIVATE
12+
SwiftSDKCommand)
13+
14+
target_compile_options(swift-experimental-sdk PRIVATE
15+
-parse-as-library)
16+
17+
install(TARGETS swift-experimental-sdk
18+
RUNTIME DESTINATION bin)
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
//===----------------------------------------------------------------------===//
2+
//
3+
// This source file is part of the Swift open source project
4+
//
5+
// Copyright (c) 2023 Apple Inc. and the Swift project authors
6+
// Licensed under Apache License v2.0 with Runtime Library Exception
7+
//
8+
// See http://swift.org/LICENSE.txt for license information
9+
// See http://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
10+
//
11+
//===----------------------------------------------------------------------===//
12+
13+
import SwiftSDKCommand
14+
15+
@main
16+
struct Entrypoint {
17+
static func main() async {
18+
print("warning: `swift experimental-sdk` command is deprecated and will be removed in a future version of SwiftPM. Use `swift sdk` instead.")
19+
await SwiftSDKCommand.main()
20+
}
21+
}

Sources/swift-package-manager/SwiftPM.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,9 @@ struct SwiftPM {
4141
await SwiftPackageCommand.main()
4242
case "swift-build":
4343
await SwiftBuildCommand.main()
44+
case "swift-experimental-sdk":
45+
print("warning: `swift experimental-sdk` command is deprecated and will be removed in a future version of SwiftPM. Use `swift sdk` instead.")
46+
fallthrough
4447
case "swift-sdk":
4548
await SwiftSDKCommand.main()
4649
case "swift-test":

Utilities/bootstrap

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -435,7 +435,7 @@ def install_swiftpm(prefix, args):
435435
# Install the swift-package-manager tool and create symlinks to it.
436436
cli_tool_dest = os.path.join(prefix, "bin")
437437
install_binary(args, "swift-package-manager", os.path.join(cli_tool_dest, "swift-package"), destination_is_directory=False)
438-
for tool in ["swift-build", "swift-test", "swift-run", "swift-package-collection", "swift-package-registry", "swift-sdk"]:
438+
for tool in ["swift-build", "swift-test", "swift-run", "swift-package-collection", "swift-package-registry", "swift-sdk", "swift-experimental-sdk"]:
439439
src = "swift-package"
440440
dest = os.path.join(cli_tool_dest, tool)
441441
note("Creating tool symlink from %s to %s" % (src, dest))

0 commit comments

Comments
 (0)