Skip to content

Bring back experimental-sdk as deprecated for compatibility #7512

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@ Note: This is in reverse chronological order, so newer entries are added to the
Swift 6.0
-----------

* [#7507]

`swift experimental-sdk` command is deprecated with `swift sdk` command replacing it. `--experimental-swift-sdk` and
`--experimental-swift-sdks-path` options on `swift build` are deprecated with replacements that don't have the
`experimental` prefix.

* [#7202]

Package manifests can now access information about the Git repository the given package is in via the context object's
Expand Down Expand Up @@ -403,3 +409,4 @@ Swift 3.0
[#7118]: https://github.com/apple/swift-package-manager/pull/7118
[#7201]: https://github.com/apple/swift-package-manager/pull/7201
[#7202]: https://github.com/apple/swift-package-manager/pull/7202
[#7505]: https://github.com/apple/swift-package-manager/pull/7507
6 changes: 6 additions & 0 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -533,6 +533,12 @@ let package = Package(
dependencies: ["Commands", "SwiftSDKCommand"],
exclude: ["CMakeLists.txt"]
),
.executableTarget(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unfortunate we need to keep the executable here :(

/** Deprecated command superseded by `swift-sdk` */
name: "swift-experimental-sdk",
dependencies: ["Commands", "SwiftSDKCommand"],
exclude: ["CMakeLists.txt"]
),
.executableTarget(
/** Runs package tests */
name: "swift-test",
Expand Down
1 change: 1 addition & 0 deletions Sources/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ add_subdirectory(SPMLLBuild)
add_subdirectory(SPMSQLite3)
add_subdirectory(swift-bootstrap)
add_subdirectory(swift-build)
add_subdirectory(swift-experimental-sdk)
add_subdirectory(swift-sdk)
add_subdirectory(swift-package)
add_subdirectory(swift-run)
Expand Down
6 changes: 6 additions & 0 deletions Sources/CoreCommands/Options.swift
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,9 @@ package struct LocationOptions: ParsableArguments {
@Option(name: .customLong("destination"), help: .hidden, completion: .directory)
package var customCompileDestination: AbsolutePath?

@Option(name: .customLong("experimental-swift-sdks-path"), help: .hidden, completion: .directory)
package var deprecatedSwiftSDKsDirectory: AbsolutePath?

/// Path to the directory containing installed Swift SDKs.
@Option(
name: .customLong("swift-sdks-path"),
Expand Down Expand Up @@ -410,6 +413,9 @@ package struct BuildOptions: ParsableArguments {
)
package var architectures: [String] = []

@Option(name: .customLong("experimental-swift-sdk"), help: .hidden)
package var deprecatedSwiftSDKSelector: String?

/// Filter for selecting a specific Swift SDK to build with.
@Option(
name: .customLong("swift-sdk"),
Expand Down
15 changes: 13 additions & 2 deletions Sources/CoreCommands/SwiftCommandState.swift
Original file line number Diff line number Diff line change
Expand Up @@ -350,8 +350,13 @@ package final class SwiftCommandState {
fileSystem: fileSystem
)
self.sharedCacheDirectory = try getSharedCacheDirectory(options: options, fileSystem: fileSystem)
if options.locations.deprecatedSwiftSDKsDirectory != nil {
self.observabilityScope.emit(
warning: "`--experimental-swift-sdks-path` is deprecated and will be removed in a future version of SwiftPM. Use `--swift-sdks-path` instead."
)
}
self.sharedSwiftSDKsDirectory = try fileSystem.getSharedSwiftSDKsDirectory(
explicitDirectory: options.locations.swiftSDKsDirectory
explicitDirectory: options.locations.swiftSDKsDirectory ?? options.locations.deprecatedSwiftSDKsDirectory
)

// set global process logging handler
Expand Down Expand Up @@ -820,14 +825,20 @@ package final class SwiftCommandState {
do {
let hostToolchain = try _hostToolchain.get()
hostSwiftSDK = hostToolchain.swiftSDK

if options.build.deprecatedSwiftSDKSelector != nil {
self.observabilityScope.emit(
warning: "`--experimental-swift-sdk` is deprecated and will be removed in a future version of SwiftPM. Use `--swift-sdk` instead."
)
}
swiftSDK = try SwiftSDK.deriveTargetSwiftSDK(
hostSwiftSDK: hostSwiftSDK,
hostTriple: hostToolchain.targetTriple,
customCompileDestination: options.locations.customCompileDestination,
customCompileTriple: options.build.customCompileTriple,
customCompileToolchain: options.build.customCompileToolchain,
customCompileSDK: options.build.customCompileSDK,
swiftSDKSelector: options.build.swiftSDKSelector,
swiftSDKSelector: options.build.swiftSDKSelector ?? options.build.deprecatedSwiftSDKSelector,
architectures: options.build.architectures,
store: store,
observabilityScope: self.observabilityScope,
Expand Down
18 changes: 18 additions & 0 deletions Sources/swift-experimental-sdk/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# This source file is part of the Swift open source project
#
# Copyright (c) 2023 Apple Inc. and the Swift project authors
# Licensed under Apache License v2.0 with Runtime Library Exception
#
# See http://swift.org/LICENSE.txt for license information
# See http://swift.org/CONTRIBUTORS.txt for Swift project authors

add_executable(swift-experimental-sdk
Entrypoint.swift)
target_link_libraries(swift-experimental-sdk PRIVATE
SwiftSDKCommand)

target_compile_options(swift-experimental-sdk PRIVATE
-parse-as-library)

install(TARGETS swift-experimental-sdk
RUNTIME DESTINATION bin)
21 changes: 21 additions & 0 deletions Sources/swift-experimental-sdk/Entrypoint.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
//===----------------------------------------------------------------------===//
//
// This source file is part of the Swift open source project
//
// Copyright (c) 2023 Apple Inc. and the Swift project authors
// Licensed under Apache License v2.0 with Runtime Library Exception
//
// See http://swift.org/LICENSE.txt for license information
// See http://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
//
//===----------------------------------------------------------------------===//

import SwiftSDKCommand

@main
struct Entrypoint {
static func main() async {
print("warning: `swift experimental-sdk` command is deprecated and will be removed in a future version of SwiftPM. Use `swift sdk` instead.")
await SwiftSDKCommand.main()
}
}
3 changes: 3 additions & 0 deletions Sources/swift-package-manager/SwiftPM.swift
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ struct SwiftPM {
await SwiftPackageCommand.main()
case "swift-build":
await SwiftBuildCommand.main()
case "swift-experimental-sdk":
print("warning: `swift experimental-sdk` command is deprecated and will be removed in a future version of SwiftPM. Use `swift sdk` instead.")
fallthrough
case "swift-sdk":
await SwiftSDKCommand.main()
case "swift-test":
Expand Down
2 changes: 1 addition & 1 deletion Utilities/bootstrap
Original file line number Diff line number Diff line change
Expand Up @@ -435,7 +435,7 @@ def install_swiftpm(prefix, args):
# Install the swift-package-manager tool and create symlinks to it.
cli_tool_dest = os.path.join(prefix, "bin")
install_binary(args, "swift-package-manager", os.path.join(cli_tool_dest, "swift-package"), destination_is_directory=False)
for tool in ["swift-build", "swift-test", "swift-run", "swift-package-collection", "swift-package-registry", "swift-sdk"]:
for tool in ["swift-build", "swift-test", "swift-run", "swift-package-collection", "swift-package-registry", "swift-sdk", "swift-experimental-sdk"]:
src = "swift-package"
dest = os.path.join(cli_tool_dest, tool)
note("Creating tool symlink from %s to %s" % (src, dest))
Expand Down