Skip to content

Commit c5589c8

Browse files
committed
Merge remote-tracking branch 'origin/main' into 6.2-merge-main
2 parents a67efeb + ba10e8a commit c5589c8

File tree

270 files changed

+12497
-5654
lines changed

Some content is hidden

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

270 files changed

+12497
-5654
lines changed

.swift-version

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
6.1.0

CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ if(FIND_PM_DEPS)
4545
find_package(SwiftASN1 CONFIG REQUIRED)
4646
find_package(SwiftCertificates CONFIG REQUIRED)
4747
find_package(SwiftCrypto CONFIG REQUIRED)
48+
find_package(SwiftBuild CONFIG REQUIRED)
4849
endif()
4950

5051
find_package(dispatch QUIET)

CODEOWNERS

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,4 +26,4 @@
2626

2727
Sources/XCBuildSupport/* @jakepetroules
2828

29-
* @bnbarham @MaxDesiatov @jakepetroules @xedin @dschaefer2 @shawnhyam @bripeticca @plemarquand @owenv @bkhouri @cmcgee1024 @daveyc123
29+
* @jakepetroules @dschaefer2 @shawnhyam @bripeticca @plemarquand @owenv @bkhouri @cmcgee1024 @daveyc123

CONTRIBUTING.md

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,13 @@ $> swift --version
8888
Apple Swift version 5.3
8989
```
9090

91-
Note: Alternatively use tools like [swiftly](https://www.swift.org/swiftly/documentation/swiftlydocs/) that help manage toolchains versions.
91+
Alternatively, there are tools like [swiftly](https://github.com/swiftlang/swiftly) that can install and manage toolchains automatically. This repository has a file called `.swift-version` that will keep swiftly at the current recommended version of the toolchain for best results. The `swiftly install` command ensures that SwiftPM's in-use toolchain is installed on your system and ready for you to do your development work with the usual swift commands.
92+
93+
```bash
94+
swiftly install
95+
swift build
96+
swift test
97+
```
9298

9399
## Local Development
94100

@@ -322,14 +328,15 @@ Note there are several Linux and Swift versions options to choose from, e.g.:
322328
2. Clone a working copy of your fork
323329
3. Create a new branch
324330
4. Make your code changes
325-
5. Try to keep your changes (when possible) below 200 lines of code.
326-
6. We use [SwiftFormat](https://www.github.com/nicklockwood/SwiftFormat) to enforce code style. Please install and run SwiftFormat before submitting your PR, ideally isolating formatting changes only to code changed for the original goal of the PR. This will keep the PR diff smaller.
327-
7. Commit (include the Radar link or GitHub issue id in the commit message if possible and a description your changes). Try to have only 1 commit in your PR (but, of course, if you add changes that can be helpful to be kept aside from the previous commit, make a new commit for them).
328-
8. Push the commit / branch to your fork
329-
9. Make a PR from your fork / branch to `apple: main`
330-
10. While creating your PR, make sure to follow the PR Template providing information about the motivation and highlighting the changes.
331-
11. Reviewers are going to be automatically added to your PR
332-
12. Pull requests will be merged by the maintainers after it passes CI testing and receives approval from one or more reviewers. Merge timing may be impacted by release schedule considerations.
331+
5. If a particular version of the Swift toolchain is needed then update the `.swift-version` file to that version (or use `swiftly use` to update it).
332+
6. Try to keep your changes (when possible) below 200 lines of code.
333+
7. We use [SwiftFormat](https://www.github.com/nicklockwood/SwiftFormat) to enforce code style. Please install and run SwiftFormat before submitting your PR, ideally isolating formatting changes only to code changed for the original goal of the PR. This will keep the PR diff smaller.
334+
8. Commit (include the Radar link or GitHub issue id in the commit message if possible and a description your changes). Try to have only 1 commit in your PR (but, of course, if you add changes that can be helpful to be kept aside from the previous commit, make a new commit for them).
335+
9. Push the commit / branch to your fork
336+
10. Make a PR from your fork / branch to `apple: main`
337+
11. While creating your PR, make sure to follow the PR Template providing information about the motivation and highlighting the changes.
338+
12. Reviewers are going to be automatically added to your PR
339+
13. Pull requests will be merged by the maintainers after it passes CI testing and receives approval from one or more reviewers. Merge timing may be impacted by release schedule considerations.
333340

334341
By submitting a pull request, you represent that you have the right to license
335342
your contribution to Apple and the community, and agree by submitting the patch

Fixtures/Miscellaneous/Plugins/MyBinaryToolPlugin/Binaries/MyVendedSourceGenBuildTool.artifactbundle/info.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@
1212
{
1313
"path": "mytool-linux/mytool",
1414
"supportedTriples": ["x86_64-unknown-linux-gnu"]
15+
},
16+
{
17+
"path": "mytool-windows/mytool.bat",
18+
"supportedTriples": ["x86_64-unknown-windows-msvc", "aarch64-unknown-windows-msvc"]
1519
}
1620
]
1721
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
@echo off
2+
3+
set verbose=false
4+
IF NOT "%1"=="" (
5+
IF "%1"=="--verbose" (
6+
SET verbose=true
7+
SHIFT
8+
)
9+
)
10+
11+
set input=%1
12+
set output=%2
13+
shift
14+
shift
15+
16+
17+
if "%verbose%" == "true" (
18+
echo "[mytool-windows] '%input%' '%output%'"
19+
)
20+
@echo on
21+
echo f | xcopy.exe /f "%input%" "%output%"
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
// swift-tools-version:5.8
2+
3+
import PackageDescription
4+
5+
let package = Package(
6+
name: "ExistentialAnyMigration",
7+
targets: [
8+
.target(name: "Diagnostics", path: "Sources", exclude: ["Fixed"]),
9+
]
10+
)
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
protocol P {
2+
}
3+
4+
func test1(_: any P) {
5+
}
6+
7+
func test2(_: (any P).Protocol) {
8+
}
9+
10+
func test3() {
11+
let _: [(any P)?] = []
12+
}
13+
14+
func test4() {
15+
var x = 42
16+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
protocol P {
2+
}
3+
4+
func test1(_: P) {
5+
}
6+
7+
func test2(_: P.Protocol) {
8+
}
9+
10+
func test3() {
11+
let _: [P?] = []
12+
}
13+
14+
func test4() {
15+
var x = 42
16+
}

Package.swift

Lines changed: 30 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// swift-tools-version:6.0
1+
// swift-tools-version:6.1
22

33
//===----------------------------------------------------------------------===//
44
//
@@ -104,7 +104,7 @@ let package = Package(
104104
name: "SwiftPM",
105105
platforms: [
106106
.macOS(.v13),
107-
.iOS(.v16),
107+
.iOS(.v17),
108108
.macCatalyst(.v17),
109109
],
110110
products:
@@ -138,7 +138,7 @@ let package = Package(
138138
type: .dynamic,
139139
targets: ["AppleProductTypes"]
140140
),
141-
141+
142142
.library(
143143
name: "PackagePlugin",
144144
type: .dynamic,
@@ -304,6 +304,21 @@ let package = Package(
304304
]
305305
),
306306

307+
.target(
308+
/** API for deserializing diagnostics and applying fix-its */
309+
name: "SwiftFixIt",
310+
dependencies: [
311+
"Basics",
312+
.product(name: "TSCBasic", package: "swift-tools-support-core"),
313+
] + swiftSyntaxDependencies(
314+
["SwiftDiagnostics", "SwiftIDEUtils", "SwiftParser", "SwiftSyntax"]
315+
),
316+
exclude: ["CMakeLists.txt"],
317+
swiftSettings: commonExperimentalFeatures + [
318+
.unsafeFlags(["-static"]),
319+
]
320+
),
321+
307322
// MARK: Project Model
308323

309324
.target(
@@ -573,6 +588,7 @@ let package = Package(
573588
"Workspace",
574589
"XCBuildSupport",
575590
"SwiftBuildSupport",
591+
"SwiftFixIt",
576592
] + swiftSyntaxDependencies(["SwiftIDEUtils"]),
577593
exclude: ["CMakeLists.txt", "README.md"],
578594
swiftSettings: swift6CompatibleExperimentalFeatures + [
@@ -808,7 +824,11 @@ let package = Package(
808824

809825
.testTarget(
810826
name: "BasicsTests",
811-
dependencies: ["Basics", "_InternalTestSupport", "tsan_utils"],
827+
dependencies: [
828+
"Basics",
829+
"_InternalTestSupport",
830+
"tsan_utils",
831+
],
812832
exclude: [
813833
"Archiver/Inputs/archive.tar.gz",
814834
"Archiver/Inputs/archive.zip",
@@ -916,6 +936,10 @@ let package = Package(
916936
dependencies: ["SourceControl", "_InternalTestSupport"],
917937
exclude: ["Inputs/TestRepo.tgz"]
918938
),
939+
.testTarget(
940+
name: "SwiftFixItTests",
941+
dependencies: ["SwiftFixIt", "_InternalTestSupport"]
942+
),
919943
.testTarget(
920944
name: "XCBuildSupportTests",
921945
dependencies: ["XCBuildSupport", "_InternalTestSupport", "_InternalBuildTestSupport"],
@@ -928,7 +952,7 @@ let package = Package(
928952
path: "Examples/package-info/Sources/package-info"
929953
)
930954
],
931-
swiftLanguageVersions: [.v5]
955+
swiftLanguageModes: [.v5]
932956
)
933957

934958
#if canImport(Darwin)
@@ -1079,8 +1103,7 @@ if ProcessInfo.processInfo.environment["ENABLE_APPLE_PRODUCT_TYPES"] == "1" {
10791103
}
10801104
}
10811105

1082-
if ProcessInfo.processInfo.environment["SWIFTPM_SWBUILD_FRAMEWORK"] == nil &&
1083-
ProcessInfo.processInfo.environment["SWIFTPM_NO_SWBUILD_DEPENDENCY"] == nil {
1106+
if ProcessInfo.processInfo.environment["SWIFTPM_SWBUILD_FRAMEWORK"] == nil {
10841107

10851108
let swiftbuildsupport: Target = package.targets.first(where: { $0.name == "SwiftBuildSupport" } )!
10861109
swiftbuildsupport.dependencies += [

Sources/Basics/Archiver/TarArchiver.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ public struct TarArchiver: Archiver {
2525
private let cancellator: Cancellator
2626

2727
/// The underlying command
28-
private let tarCommand: String
28+
internal let tarCommand: String
2929

3030
/// Creates a `TarArchiver`.
3131
///

Sources/Basics/Archiver/ZipArchiver.swift

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,14 @@ public struct ZipArchiver: Archiver, Cancellable {
2929

3030
/// Absolute path to the Windows tar in the system folder
3131
#if os(Windows)
32-
private let windowsTar: String
32+
internal let windowsTar: String
33+
#else
34+
internal let unzip = "unzip"
35+
internal let zip = "zip"
36+
#endif
37+
38+
#if os(FreeBSD)
39+
internal let tar = "tar"
3340
#endif
3441

3542
/// Creates a `ZipArchiver`.
@@ -74,7 +81,9 @@ public struct ZipArchiver: Archiver, Cancellable {
7481
// It's part of system32 anyway so use the absolute path.
7582
let process = AsyncProcess(arguments: [windowsTar, "xf", archivePath.pathString, "-C", destinationPath.pathString])
7683
#else
77-
let process = AsyncProcess(arguments: ["unzip", archivePath.pathString, "-d", destinationPath.pathString])
84+
let process = AsyncProcess(arguments: [
85+
self.unzip, archivePath.pathString, "-d", destinationPath.pathString,
86+
])
7887
#endif
7988
guard let registrationKey = self.cancellator.register(process) else {
8089
throw CancellationError.failedToRegisterProcess(process)
@@ -113,7 +122,10 @@ public struct ZipArchiver: Archiver, Cancellable {
113122
// On FreeBSD, the unzip command is available in base but not the zip command.
114123
// Therefore; we use libarchive(bsdtar) to produce the ZIP archive instead.
115124
let process = AsyncProcess(
116-
arguments: ["tar", "-c", "--format", "zip", "-f", destinationPath.pathString, directory.basename],
125+
arguments: [
126+
self.tar, "-c", "--format", "zip", "-f", destinationPath.pathString,
127+
directory.basename,
128+
],
117129
workingDirectory: directory.parentDirectory
118130
)
119131
#else
@@ -127,7 +139,7 @@ public struct ZipArchiver: Archiver, Cancellable {
127139
arguments: [
128140
"/bin/sh",
129141
"-c",
130-
"cd \(directory.parentDirectory.underlying.pathString) && zip -ry \(destinationPath.pathString) \(directory.basename)",
142+
"cd \(directory.parentDirectory.underlying.pathString) && \(self.zip) -ry \(destinationPath.pathString) \(directory.basename)"
131143
]
132144
)
133145
#endif
@@ -154,7 +166,7 @@ public struct ZipArchiver: Archiver, Cancellable {
154166
#if os(Windows)
155167
let process = AsyncProcess(arguments: [windowsTar, "tf", path.pathString])
156168
#else
157-
let process = AsyncProcess(arguments: ["unzip", "-t", path.pathString])
169+
let process = AsyncProcess(arguments: [self.unzip, "-t", path.pathString])
158170
#endif
159171
guard let registrationKey = self.cancellator.register(process) else {
160172
throw CancellationError.failedToRegisterProcess(process)

Sources/Basics/Concurrency/ConcurrencyHelpers.swift

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,4 +59,20 @@ extension DispatchQueue {
5959
}
6060
}
6161
}
62+
63+
package func asyncResult<T: Sendable>(_ callback: @escaping @Sendable (Result<T, Error>) -> Void, _ closure: @escaping @Sendable () async throws -> T) {
64+
let completion: @Sendable (Result<T, Error>) -> Void = {
65+
result in self.async {
66+
callback(result)
67+
}
68+
}
69+
70+
Task {
71+
do {
72+
completion(.success(try await closure()))
73+
} catch {
74+
completion(.failure(error))
75+
}
76+
}
77+
}
6278
}

Sources/Basics/Concurrency/SendableBox.swift

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,24 +16,24 @@ import struct Foundation.Date
1616
/// an `async` closure. This type serves as a replacement for `ThreadSafeBox`
1717
/// implemented with Swift Concurrency primitives.
1818
public actor SendableBox<Value: Sendable> {
19-
init(_ value: Value? = nil) {
19+
public init(_ value: Value) {
2020
self.value = value
2121
}
2222

23-
var value: Value?
23+
public var value: Value
24+
25+
public func set(_ value: Value) {
26+
self.value = value
27+
}
2428
}
2529

2630
extension SendableBox where Value == Int {
2731
func increment() {
28-
if let value {
29-
self.value = value + 1
30-
}
32+
self.value = value + 1
3133
}
3234

3335
func decrement() {
34-
if let value {
35-
self.value = value - 1
36-
}
36+
self.value = value - 1
3737
}
3838
}
3939

Sources/Basics/FileSystem/FileSystem+Extensions.swift

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -681,3 +681,17 @@ extension FileSystem {
681681
}
682682
}
683683
}
684+
685+
extension FileSystem {
686+
/// Do a deep enumeration, passing each file to block
687+
public func enumerate(directory: AbsolutePath, block: (AbsolutePath) throws -> ()) throws {
688+
for file in try getDirectoryContents(directory) {
689+
let path = directory.appending(file)
690+
if isDirectory(path) {
691+
try enumerate(directory: path, block: block)
692+
} else {
693+
try block(path)
694+
}
695+
}
696+
}
697+
}

Sources/Build/BuildDescription/ModuleBuildDescription.swift

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,14 @@ public enum ModuleBuildDescription: SPMBuildCore.ModuleBuildDescription {
140140
}
141141
}
142142

143+
public var diagnosticFiles: [AbsolutePath] {
144+
switch self {
145+
case .swift(let buildDescription):
146+
buildDescription.diagnosticFiles
147+
case .clang(_):
148+
[]
149+
}
150+
}
143151
/// Determines the arguments needed to run `swift-symbolgraph-extract` for
144152
/// this module.
145153
public func symbolGraphExtractArguments() throws -> [String] {
@@ -214,4 +222,14 @@ extension ModuleBuildDescription {
214222
}
215223
return dependencies
216224
}
225+
226+
package func recursiveLinkDependencies(using plan: BuildPlan) -> [Dependency] {
227+
var dependencies: [Dependency] = []
228+
plan.traverseLinkDependencies(of: self) { product, _, description in
229+
dependencies.append(.product(product, description))
230+
} onModule: { module, _, description in
231+
dependencies.append(.module(module, description))
232+
}
233+
return dependencies
234+
}
217235
}

0 commit comments

Comments
 (0)