-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[6.0] Deprecate
experimental
Swift SDK CLI in favor of unprefixed c…
…ounterparts (#7515) Cherry-pick of #7512, #7507, and #7517. **Explanation**: Since [SE-0387](https://github.com/apple/swift-evolution/blob/main/proposals/0387-cross-compilation-destinations.md) was accepted and available in Swift 5.9 and Swift 5.10, it's time to deprecate relevant CLI with the `experimental` prefix. There are enough users of this command and corresponding options on `swift build` in the wild, which means those should be deprecated first before removing. **Scope**: isolated to `swift sdk` command and 2 Swift SDK options on `swift build`. **Risk**: low, these commands options have no impact on `swift build` outside of cross-compilation use cases. **Testing**: added new end-to-end tests in `SDKCommandTests` in #7517 cherry-picked here. **Issue**: N/A **Reviewer**: @bnbarham
- Loading branch information
1 parent
0b53c3c
commit eb2d5b3
Showing
16 changed files
with
229 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
// This empty file tells test fixture logic to copy this directory's content to the test case temp directory. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
# Swift SDKs Tool | ||
# Swift SDKs Command | ||
|
||
This module implements `swift experimental-sdk` command and its subcommands, which allow managing artifact | ||
This module implements `swift sdk` command and its subcommands, which allow managing artifact | ||
bundles used as Swift SDKs, as specified in [SE-0387](https://github.com/apple/swift-evolution/blob/main/proposals/0387-cross-compilation-destinations.md). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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-sdk | ||
Entrypoint.swift) | ||
target_link_libraries(swift-sdk PRIVATE | ||
SwiftSDKCommand) | ||
|
||
target_compile_options(swift-sdk PRIVATE | ||
-parse-as-library) | ||
|
||
install(TARGETS swift-sdk | ||
RUNTIME DESTINATION bin) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
//===----------------------------------------------------------------------===// | ||
// | ||
// 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 { | ||
await SwiftSDKCommand.main() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,122 @@ | ||
//===----------------------------------------------------------------------===// | ||
// | ||
// This source file is part of the Swift open source project | ||
// | ||
// Copyright (c) 2014-2024 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 Basics | ||
import Commands | ||
import SPMTestSupport | ||
import XCTest | ||
|
||
import class TSCBasic.Process | ||
import enum TSCBasic.ProcessEnv | ||
|
||
private let deprecationWarning = "warning: `swift experimental-sdk` command is deprecated and will be removed in a future version of SwiftPM. Use `swift sdk` instead." | ||
|
||
final class SDKCommandTests: CommandsTestCase { | ||
func testUsage() throws { | ||
for command in [SwiftPM.sdk, SwiftPM.experimentalSDK] { | ||
let stdout = try command.execute(["-help"]).stdout | ||
XCTAssert(stdout.contains("USAGE: swift sdk <subcommand>") || stdout.contains("USAGE: swift sdk [<subcommand>]"), "got stdout:\n" + stdout) | ||
} | ||
} | ||
|
||
func testVersion() throws { | ||
for command in [SwiftPM.sdk, SwiftPM.experimentalSDK] { | ||
let stdout = try command.execute(["--version"]).stdout | ||
XCTAssert(stdout.contains("Swift Package Manager"), "got stdout:\n" + stdout) | ||
} | ||
} | ||
|
||
func testInstallSDK() throws { | ||
for command in [SwiftPM.sdk, SwiftPM.experimentalSDK] { | ||
try fixture(name: "SwiftSDKs") { fixturePath in | ||
for bundle in ["test-sdk.artifactbundle.tar.gz", "test-sdk.artifactbundle.zip"] { | ||
var (stdout, stderr) = try command.execute( | ||
[ | ||
"install", | ||
"--swift-sdks-path", fixturePath.pathString, | ||
fixturePath.appending(bundle).pathString | ||
] | ||
) | ||
|
||
if command == .experimentalSDK { | ||
XCTAssertMatch(stdout, .contains(deprecationWarning)) | ||
} | ||
|
||
// We only expect tool's output on the stdout stream. | ||
XCTAssertMatch( | ||
stdout, | ||
.contains("\(bundle)` successfully installed as test-sdk.artifactbundle.") | ||
) | ||
|
||
XCTAssertEqual(stderr.count, 0) | ||
|
||
(stdout, stderr) = try command.execute( | ||
["list", "--swift-sdks-path", fixturePath.pathString]) | ||
|
||
if command == .experimentalSDK { | ||
XCTAssertMatch(stdout, .contains(deprecationWarning)) | ||
} | ||
|
||
// We only expect tool's output on the stdout stream. | ||
XCTAssertMatch(stdout, .contains("test-artifact")) | ||
XCTAssertEqual(stderr.count, 0) | ||
|
||
XCTAssertThrowsError(try command.execute( | ||
[ | ||
"install", | ||
"--swift-sdks-path", fixturePath.pathString, | ||
fixturePath.appending(bundle).pathString | ||
] | ||
)) { error in | ||
guard case SwiftPMError.executionFailure(_, _, let stderr) = error else { | ||
XCTFail() | ||
return | ||
} | ||
|
||
XCTAssertTrue( | ||
stderr.contains( | ||
"Error: Swift SDK bundle with name `test-sdk.artifactbundle` is already installed. Can't install a new bundle with the same name." | ||
), | ||
"got stderr: \(stderr)" | ||
) | ||
} | ||
|
||
if command == .experimentalSDK { | ||
XCTAssertMatch(stdout, .contains(deprecationWarning)) | ||
} | ||
|
||
(stdout, stderr) = try command.execute( | ||
["remove", "--swift-sdks-path", fixturePath.pathString, "test-artifact"]) | ||
|
||
if command == .experimentalSDK { | ||
XCTAssertMatch(stdout, .contains(deprecationWarning)) | ||
} | ||
|
||
// We only expect tool's output on the stdout stream. | ||
XCTAssertMatch(stdout, .contains("test-sdk.artifactbundle` was successfully removed from the file system.")) | ||
XCTAssertEqual(stderr.count, 0) | ||
|
||
(stdout, stderr) = try command.execute( | ||
["list", "--swift-sdks-path", fixturePath.pathString]) | ||
|
||
if command == .experimentalSDK { | ||
XCTAssertMatch(stdout, .contains(deprecationWarning)) | ||
} | ||
|
||
// We only expect tool's output on the stdout stream. | ||
XCTAssertNoMatch(stdout, .contains("test-artifact")) | ||
XCTAssertEqual(stderr.count, 0) | ||
} | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters