Skip to content

Commit 436c2c9

Browse files
dschaefer2pmattosbkhouristmontgomerykateinoigakukun
authored
6.2 merge main 0602 (#8754)
Merge main at 4dce989 using `git merge -X theirs origin/main` `git diff origin/main HEAD` is minimal. ``` diff --git a/Package.swift b/Package.swift index 9fbb315..a372459 100644 --- a/Package.swift +++ b/Package.swift @@ -1038,7 +1038,7 @@ func swiftSyntaxDependencies(_ names: [String]) -> [Target.Dependency] { // this right now. /// When not using local dependencies, the branch to use for llbuild and TSC repositories. -let relatedDependenciesBranch = "main" +let relatedDependenciesBranch = "release/6.2" if ProcessInfo.processInfo.environment["SWIFTPM_LLBUILD_FWK"] == nil { if ProcessInfo.processInfo.environment["SWIFTCI_USE_LOCAL_DEPS"] == nil { ``` --------- Co-authored-by: Paulo Mattos <[email protected]> Co-authored-by: Bassam (Sam) Khouri <[email protected]> Co-authored-by: Stuart Montgomery <[email protected]> Co-authored-by: Yuta Saito <[email protected]> Co-authored-by: nate-chandler <[email protected]> Co-authored-by: Max Desiatov <[email protected]> Co-authored-by: 3405691582 <[email protected]> Co-authored-by: Chris McGee <[email protected]> Co-authored-by: Dave Inglis <[email protected]> Co-authored-by: Jonathan Grynspan <[email protected]> Co-authored-by: Jake Petroules <[email protected]> Co-authored-by: Shawn Hyam <[email protected]> Co-authored-by: Paul LeMarquand <[email protected]> Co-authored-by: Pavel Yaskevich <[email protected]> Co-authored-by: johnbute <[email protected]> Co-authored-by: John Bute <[email protected]> Co-authored-by: Joseph Heck <[email protected]> Co-authored-by: kcieplak <[email protected]> Co-authored-by: Bri Peticca <[email protected]> Co-authored-by: Matt Seaman <[email protected]> Co-authored-by: Yury Yurevich <[email protected]> Co-authored-by: Anthony Latsis <[email protected]> Co-authored-by: Bri Peticca <[email protected]> Co-authored-by: Louis Qian <[email protected]> Co-authored-by: Ben Barham <[email protected]> Co-authored-by: Rauhul Varma <[email protected]> Co-authored-by: Pavel Yaskevich <[email protected]> Co-authored-by: Owen Voorhees <[email protected]> Co-authored-by: Sam Khouri <[email protected]> Co-authored-by: Franz Busch <[email protected]> Co-authored-by: Robin Kunde <[email protected]> Co-authored-by: Dave Inglis <[email protected]> Co-authored-by: Anthony Latsis <[email protected]> Co-authored-by: Doug Gregor <[email protected]> Co-authored-by: Alexis Laferrière <[email protected]> Co-authored-by: Andrew Hoos <[email protected]>
1 parent 3d3246b commit 436c2c9

File tree

195 files changed

+16805
-3052
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

195 files changed

+16805
-3052
lines changed

CODEOWNERS

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@
2424

2525
# The following lines are used by GitHub to automatically recommend reviewers.
2626

27-
Sources/XCBuildSupport/* @jakepetroules
28-
2927
* @jakepetroules @dschaefer2 @shawnhyam @bripeticca @plemarquand @owenv @bkhouri @cmcgee1024 @daveyc123
28+
29+
Sources/XCBuildSupport/* @jakepetroules
30+
Sources/Commands/PackageCommands/Migrate.swift @AnthonyLatsis @bnbarham @xedin @jakepetroules @dschaefer2 @shawnhyam @bripeticca @plemarquand @owenv @bkhouri @cmcgee1024 @daveyc123
31+
Sources/SwiftFixIt/* @AnthonyLatsis @bnbarham @xedin @jakepetroules @dschaefer2 @shawnhyam @bripeticca @plemarquand @owenv @bkhouri @cmcgee1024 @daveyc123
32+
Tests/SwiftFixItTests/* @AnthonyLatsis @bnbarham @xedin @jakepetroules @dschaefer2 @shawnhyam @bripeticca @plemarquand @owenv @bkhouri @cmcgee1024 @daveyc123

CONTRIBUTING.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -343,6 +343,8 @@ your contribution to Apple and the community, and agree by submitting the patch
343343
that your contributions are licensed under the [Swift
344344
license](https://swift.org/LICENSE.txt).
345345

346+
After a change is known not to cause regressions in the `main` branch, it may be considered for cherry-picking to the latest release branch depending on the release schedule. Cherry-picks require [a specific template to be followed](https://github.com/swiftlang/.github/blob/main/PULL_REQUEST_TEMPLATE/release.md) in PR description that consolidates information about the change necessary for inclusion in the release branch and provides risk evaluation for nominating the change.
347+
346348
## Continuous Integration
347349

348350
SwiftPM uses [swift-ci](https://ci.swift.org) infrastructure for its continuous integration testing. The bots can be triggered on pull-requests if you have commit access. Otherwise, ask one of the code owners to trigger them for you.

Documentation/Design/PackageManagerCommunityProposal.md

Lines changed: 0 additions & 311 deletions
This file was deleted.

Documentation/PackageRegistry/PackageRegistryUsage.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ Here is an example of a source control dependency:
137137

138138
```swift
139139
dependencies: [
140-
.package(id: "https://github.com/mona/LinkedList", .upToNextMajor(from: "1.0.0")),
140+
.package(url: "https://github.com/mona/LinkedList", .upToNextMajor(from: "1.0.0")),
141141
],
142142
```
143143

Documentation/PackageRegistry/Registry.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -560,7 +560,7 @@ Content-Disposition: attachment; filename="Package.swift"
560560
Content-Length: 361
561561
Content-Version: 1
562562
Link: <http://packages.example.com/mona/LinkedList/1.1.1/Package.swift?swift-version=4>; rel="alternate"; filename="[email protected]"; swift-tools-version="4.0",
563-
<http://packages.example.com/mona/LinkedList/1.1.1/Package.swift?swift-version=4.2>; rel="alternate"; filename="[email protected]"; swift-tools-version="4.0"
563+
<http://packages.example.com/mona/LinkedList/1.1.1/Package.swift?swift-version=4.2>; rel="alternate"; filename="[email protected]"; swift-tools-version="4.2"
564564
565565
// swift-tools-version:5.0
566566
import PackageDescription
Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,3 @@
1-
#if os(macOS) || os(iOS)
2-
import Darwin
3-
#elseif canImport(Glibc)
4-
import Glibc
5-
#elseif canImport(Musl)
6-
import Musl
7-
#elseif canImport(Bionic)
8-
import Bionic
9-
#endif
101

112
public extension Collection {
123
func shuffle() -> [Iterator.Element] {
@@ -24,15 +15,13 @@ public extension MutableCollection {
2415
guard c > 1 else { return }
2516

2617
for (firstUnshuffled, unshuffledCount) in zip(indices, stride(from: c, to: 1, by: -1)) {
27-
#if os(macOS) || os(iOS)
28-
let d = arc4random_uniform(numericCast(unshuffledCount))
29-
#else
30-
let d = numericCast(random()) % unshuffledCount
31-
#endif
32-
let i = index(firstUnshuffled, offsetBy: numericCast(d))
18+
var g = SystemRandomNumberGenerator()
19+
let d = Int.random(in: 1...unshuffledCount, using: &g)
20+
let i = index(firstUnshuffled, offsetBy: d)
3321
swapAt(firstUnshuffled, i)
3422
}
3523
}
3624
}
3725

26+
3827
public let shuffle = false

Fixtures/Miscellaneous/AtMainSupport/Package.swift

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,10 @@ let package = Package(
99
.executable(name: "SwiftExecMultiFile", targets: ["SwiftExecMultiFile"]),
1010
],
1111
targets: [
12-
.executableTarget(name: "ClangExecSingleFile"),
12+
.executableTarget(name: "ClangExecSingleFile",
13+
linkerSettings: [
14+
.linkedLibrary("swiftCore", .when(platforms: [.windows])), // for swift_addNewDSOImage
15+
]),
1316
.executableTarget(name: "SwiftExecSingleFile"),
1417
.executableTarget(name: "SwiftExecMultiFile"),
1518
]

Fixtures/Miscellaneous/EchoExecutable/Sources/secho/main.swift

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,12 @@
44
import Musl
55
#elseif canImport(Android)
66
import Android
7-
#else
7+
#elseif canImport(Darwin.C)
88
import Darwin.C
9+
#elseif canImport(ucrt)
10+
import ucrt
11+
let PATH_MAX = 260
12+
typealias Int = Int32
913
#endif
1014

1115
let cwd = getcwd(nil, Int(PATH_MAX))
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
echo sentinel
2+
echo %*
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"debugger": { "path": "echo.bat" },
3+
"testRunner": { "path": "echo.bat" },
4+
"schemaVersion" : "1.0",
5+
"rootPath" : "."
6+
}

Fixtures/Miscellaneous/PluginGeneratedResources/Package.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// swift-tools-version: 5.7
1+
// swift-tools-version: 6.0
22

33
import PackageDescription
44

Fixtures/Miscellaneous/PluginGeneratedResources/Plugins/Generator/plugin.swift

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,15 @@
11
import PackagePlugin
2+
import Foundation
23

34
#if os(Android)
45
let touchExe = "/system/bin/touch"
6+
let touchArgs: [String] = []
7+
#elseif os(Windows)
8+
let touchExe = "C:/Windows/System32/cmd.exe"
9+
let touchArgs = ["/c", "copy", "NUL"]
510
#else
611
let touchExe = "/usr/bin/touch"
12+
let touchArgs: [String] = []
713
#endif
814

915
@main
@@ -12,9 +18,9 @@ struct GeneratorPlugin: BuildToolPlugin {
1218
return [
1319
.prebuildCommand(
1420
displayName: "Generating empty file",
15-
executable: .init(touchExe),
16-
arguments: [context.pluginWorkDirectory.appending("best.txt")],
17-
outputFilesDirectory: context.pluginWorkDirectory
21+
executable: .init(fileURLWithPath: touchExe),
22+
arguments: touchArgs + [String(cString: (context.pluginWorkDirectoryURL.appending(path: "best.txt") as NSURL).fileSystemRepresentation)],
23+
outputFilesDirectory: context.pluginWorkDirectoryURL
1824
)
1925
]
2026
}

Fixtures/Miscellaneous/TestableExe/Package.swift

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,23 @@ let package = Package(
55
name: "TestableExe",
66
targets: [
77
.executableTarget(
8-
name: "TestableExe1"
8+
name: "TestableExe1",
9+
linkerSettings: [
10+
.linkedLibrary("swiftCore", .when(platforms: [.windows])), // for swift_addNewDSOImage
11+
]
912
),
1013
.executableTarget(
11-
name: "TestableExe2"
14+
name: "TestableExe2",
15+
linkerSettings: [
16+
.linkedLibrary("swiftCore", .when(platforms: [.windows])), // for swift_addNewDSOImage
17+
]
18+
1219
),
1320
.executableTarget(
14-
name: "TestableExe3"
21+
name: "TestableExe3",
22+
linkerSettings: [
23+
.linkedLibrary("swiftCore", .when(platforms: [.windows])), // for swift_addNewDSOImage
24+
]
1525
),
1626
.testTarget(
1727
name: "TestableExeTests",

Fixtures/Miscellaneous/TestableExe/Tests/TestableExeTests/TestableExeTests.swift

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,13 @@ import XCTest
55
import class Foundation.Bundle
66

77
final class TestableExeTests: XCTestCase {
8+
9+
#if os(Windows)
10+
let eol = "\r\n"
11+
#else
12+
let eol = "\n"
13+
#endif
14+
815
func testExample() throws {
916
// This is an example of a functional test case.
1017
// Use XCTAssert and related functions to verify your tests produce the correct
@@ -30,7 +37,7 @@ final class TestableExeTests: XCTestCase {
3037
process.waitUntilExit()
3138
var data = pipe.fileHandleForReading.readDataToEndOfFile()
3239
var output = String(data: data, encoding: .utf8)
33-
XCTAssertEqual(output, "Hello, world!\n")
40+
XCTAssertEqual(output, "Hello, world!\(eol)")
3441

3542
execPath = productsDirectory.appendingPathComponent("TestableExe2")
3643
process = Process()
@@ -41,7 +48,7 @@ final class TestableExeTests: XCTestCase {
4148
process.waitUntilExit()
4249
data = pipe.fileHandleForReading.readDataToEndOfFile()
4350
output = String(data: data, encoding: .utf8)
44-
XCTAssertEqual(output, "Hello, planet!\n")
51+
XCTAssertEqual(output, "Hello, planet!\(eol)")
4552

4653
execPath = productsDirectory.appendingPathComponent("TestableExe3")
4754
process = Process()
@@ -52,7 +59,7 @@ final class TestableExeTests: XCTestCase {
5259
process.waitUntilExit()
5360
data = pipe.fileHandleForReading.readDataToEndOfFile()
5461
output = String(data: data, encoding: .utf8)
55-
XCTAssertEqual(output, "Hello, universe!\n")
62+
XCTAssertEqual(output, "Hello, universe!\(eol)")
5663
}
5764

5865
/// Returns path to the built products directory.

Package.swift

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -945,6 +945,13 @@ let package = Package(
945945
dependencies: ["XCBuildSupport", "_InternalTestSupport", "_InternalBuildTestSupport"],
946946
exclude: ["Inputs/Foo.pc"]
947947
),
948+
.testTarget(
949+
name: "FunctionalPerformanceTests",
950+
dependencies: [
951+
"swift-package-manager",
952+
"_InternalTestSupport",
953+
]
954+
),
948955
// Examples (These are built to ensure they stay up to date with the API.)
949956
.executableTarget(
950957
name: "package-info",
@@ -963,19 +970,6 @@ package.targets.append(contentsOf: [
963970
])
964971
#endif
965972

966-
// Workaround SwiftPM's attempt to link in executables which does not work on all
967-
// platforms.
968-
#if !os(Windows)
969-
package.targets.append(contentsOf: [
970-
.testTarget(
971-
name: "FunctionalPerformanceTests",
972-
dependencies: [
973-
"swift-package-manager",
974-
"_InternalTestSupport",
975-
]
976-
),
977-
])
978-
979973
// rdar://101868275 "error: cannot find 'XCTAssertEqual' in scope" can affect almost any functional test, so we flat out
980974
// disable them all until we know what is going on
981975
if ProcessInfo.processInfo.environment["SWIFTCI_DISABLE_SDK_DEPENDENT_TESTS"] == nil {
@@ -988,7 +982,6 @@ if ProcessInfo.processInfo.environment["SWIFTCI_DISABLE_SDK_DEPENDENT_TESTS"] ==
988982
"_InternalTestSupport",
989983
]
990984
),
991-
992985
.executableTarget(
993986
name: "dummy-swiftc",
994987
dependencies: [
@@ -1019,7 +1012,6 @@ if ProcessInfo.processInfo.environment["SWIFTCI_DISABLE_SDK_DEPENDENT_TESTS"] ==
10191012
),
10201013
])
10211014
}
1022-
#endif
10231015

10241016

10251017
func swiftSyntaxDependencies(_ names: [String]) -> [Target.Dependency] {

Sources/Basics/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ add_library(Basics
6060
Netrc.swift
6161
Observability.swift
6262
OSSignpost.swift
63+
Process.swift
6364
ProgressAnimation/NinjaProgressAnimation.swift
6465
ProgressAnimation/PercentProgressAnimation.swift
6566
ProgressAnimation/ProgressAnimationProtocol.swift

Sources/Basics/Cancellator.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ public final class Cancellator: Cancellable, Sendable {
128128
self.register(name: "\(process.arguments.joined(separator: " "))", handler: process.terminate)
129129
}
130130

131-
#if !os(iOS) && !os(watchOS) && !os(tvOS)
131+
#if !canImport(Darwin) || os(macOS)
132132
public func register(_ process: Foundation.Process) -> RegistrationKey? {
133133
self.register(name: "\(process.description)", handler: process.terminate(timeout:))
134134
}
@@ -245,7 +245,7 @@ extension AsyncProcess {
245245
}
246246
}
247247

248-
#if !os(iOS) && !os(watchOS) && !os(tvOS)
248+
#if !canImport(Darwin) || os(macOS)
249249
extension Foundation.Process {
250250
fileprivate func terminate(timeout: DispatchTime) {
251251
guard self.isRunning else {

Sources/Basics/DispatchTimeInterval+Extensions.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ extension DispatchTimeInterval {
8686
return String(format: "%.2f", Double(value) / Double(1_000_000_000)) + "s"
8787
case .never:
8888
return "n/a"
89-
#if os(macOS) || os(iOS) || os(tvOS) || os(watchOS)
89+
#if canImport(Darwin)
9090
@unknown default:
9191
return "n/a"
9292
#endif

Sources/Basics/JSON+Extensions.swift

Lines changed: 3 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -15,64 +15,8 @@ import class Foundation.DateFormatter
1515
import class Foundation.JSONDecoder
1616
import class Foundation.JSONEncoder
1717

18-
#if os(macOS) || os(iOS) || os(tvOS) || os(watchOS)
19-
extension DateFormatter {
20-
public static let iso8601: DateFormatter = {
21-
let dateFormatter = DateFormatter()
22-
dateFormatter.dateFormat = "yyyy-MM-dd'T'HH:mm:ssZ"
23-
return dateFormatter
24-
}()
25-
}
26-
27-
extension JSONEncoder.DateEncodingStrategy {
28-
public static let customISO8601 = custom {
29-
var container = $1.singleValueContainer()
30-
try container.encode(DateFormatter.iso8601.string(from: $0))
31-
}
32-
}
33-
34-
extension JSONDecoder.DateDecodingStrategy {
35-
public static let customISO8601 = custom {
36-
let container = try $0.singleValueContainer()
37-
let string = try container.decode(String.self)
38-
if let date = DateFormatter.iso8601.date(from: string) {
39-
return date
40-
}
41-
throw DecodingError.dataCorruptedError(in: container, debugDescription: "Invalid date: \(string)")
42-
}
43-
}
44-
#endif
45-
46-
extension JSONEncoder.DateEncodingStrategy {
47-
public static var safeISO8601: JSONEncoder.DateEncodingStrategy {
48-
#if os(macOS) || os(iOS) || os(tvOS) || os(watchOS)
49-
if #available(macOS 10.12, iOS 10.0, watchOS 3.0, tvOS 10.0, *) {
50-
return .iso8601
51-
} else {
52-
return .customISO8601
53-
}
54-
#else
55-
return .iso8601
56-
#endif
57-
}
58-
}
59-
60-
extension JSONDecoder.DateDecodingStrategy {
61-
public static var safeISO8601: JSONDecoder.DateDecodingStrategy {
62-
#if os(macOS) || os(iOS) || os(tvOS) || os(watchOS)
63-
if #available(macOS 10.12, iOS 10.0, watchOS 3.0, tvOS 10.0, *) {
64-
return .iso8601
65-
} else {
66-
return .customISO8601
67-
}
68-
#else
69-
return .iso8601
70-
#endif
71-
}
72-
}
73-
7418
extension JSONDecoder {
75-
public static func makeWithDefaults(dateDecodingStrategy: DateDecodingStrategy = .safeISO8601) -> JSONDecoder {
19+
public static func makeWithDefaults(dateDecodingStrategy: DateDecodingStrategy = .iso8601) -> JSONDecoder {
7620
let decoder = JSONDecoder()
7721
decoder.dateDecodingStrategy = dateDecodingStrategy
7822
return decoder
@@ -82,7 +26,7 @@ extension JSONDecoder {
8226
extension JSONEncoder {
8327
public static func makeWithDefaults(
8428
prettified: Bool = true,
85-
dateEncodingStrategy: DateEncodingStrategy = .safeISO8601
29+
dateEncodingStrategy: DateEncodingStrategy = .iso8601
8630
) -> JSONEncoder {
8731
Self.makeWithDefaults(
8832
sortKeys: prettified,
@@ -96,19 +40,13 @@ extension JSONEncoder {
9640
sortKeys: Bool,
9741
prettyPrint: Bool,
9842
escapeSlashes: Bool,
99-
dateEncodingStrategy: DateEncodingStrategy = .safeISO8601
43+
dateEncodingStrategy: DateEncodingStrategy = .iso8601
10044
) -> JSONEncoder {
10145
let encoder = JSONEncoder()
10246
var outputFormatting: JSONEncoder.OutputFormatting = []
10347

10448
if sortKeys {
105-
#if os(macOS) || os(iOS) || os(tvOS) || os(watchOS)
106-
if #available(macOS 10.15, iOS 11.0, watchOS 4.0, tvOS 11.0, *) {
107-
outputFormatting.insert(.sortedKeys)
108-
}
109-
#else
11049
outputFormatting.insert(.sortedKeys)
111-
#endif
11250
}
11351
if prettyPrint {
11452
outputFormatting.insert(.prettyPrinted)

0 commit comments

Comments
 (0)