Skip to content

Commit 9dc6ff7

Browse files
Merge pull request #85574 from swiftlang/jepa-main4
[utils] swift-xcodegen: Bump tools & SDK versions + misc improvements
2 parents 62b7fe5 + 38f72fa commit 9dc6ff7

33 files changed

+326
-319
lines changed

utils/swift-xcodegen/Package.swift

Lines changed: 32 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
// swift-tools-version: 5.8
1+
// swift-tools-version: 6.0
22
// The swift-tools-version declares the minimum version of Swift required to build this package.
33

44
import PackageDescription
55
import class Foundation.ProcessInfo
66

77
let package = Package(
88
name: "swift-xcodegen",
9-
platforms: [.macOS(.v13)],
9+
platforms: [.macOS(.v15)],
1010
targets: [
1111
.target(
1212
name: "SwiftXcodeGen",
@@ -16,28 +16,51 @@ let package = Package(
1616
],
1717
exclude: [
1818
"Xcodeproj/README.md",
19-
],
20-
swiftSettings: [
21-
.enableExperimentalFeature("StrictConcurrency")
2219
]
2320
),
2421
.executableTarget(
2522
name: "swift-xcodegen",
2623
dependencies: [
2724
.product(name: "ArgumentParser", package: "swift-argument-parser"),
2825
"SwiftXcodeGen"
29-
],
30-
swiftSettings: [
31-
.enableExperimentalFeature("StrictConcurrency")
3226
]
3327
),
3428
.testTarget(
3529
name: "SwiftXcodeGenTest",
3630
dependencies: ["SwiftXcodeGen"]
3731
)
38-
]
32+
],
33+
swiftLanguageModes: [.v6]
3934
)
4035

36+
// Apply global Swift settings to targets.
37+
do {
38+
var globalSwiftSettings: [SwiftSetting] = [
39+
// Swift 7 mode upcoming features. These must be compatible with 'swift-tools-version'.
40+
.enableUpcomingFeature("ExistentialAny"),
41+
.enableUpcomingFeature("InternalImportsByDefault"),
42+
.enableUpcomingFeature("MemberImportVisibility"),
43+
.enableUpcomingFeature("NonisolatedNonsendingByDefault"),
44+
]
45+
46+
#if compiler(>=6.1)
47+
globalSwiftSettings.append(
48+
.unsafeFlags(["-Werror", "ExistentialAny"])
49+
)
50+
#endif
51+
52+
globalSwiftSettings += [] // avoid unused warning
53+
54+
for target in package.targets where target.type != .plugin {
55+
if let swiftSettings = target.swiftSettings {
56+
// Target-specific settings should come last.
57+
target.swiftSettings = globalSwiftSettings + swiftSettings
58+
} else {
59+
target.swiftSettings = globalSwiftSettings
60+
}
61+
}
62+
}
63+
4164
if ProcessInfo.processInfo.environment["SWIFTCI_USE_LOCAL_DEPS"] == nil {
4265
package.dependencies += [
4366
.package(url: "https://github.com/apple/swift-argument-parser", from: "1.4.0"),

utils/swift-xcodegen/README.md

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
A script for generating an Xcode project for the Swift repo, that sits on top of an existing Ninja build.
44

5-
This script is primarily focussed on providing a good editor experience for working on the Swift project; it is not designed to produce compiled products or run tests, that should be done with `ninja` and `build-script`. It can however be used to [debug executables produced by the Ninja build](#debugging).
5+
This script is primarily focussed on providing a good editor experience for working on the Swift project; it is not designed to produce compiled products or run tests, that should be done with `ninja` and `build-script`. It can, however, be used to [debug executables produced by the Ninja build](#debugging).
66

77
## Running
88

@@ -12,11 +12,11 @@ You can run using either `utils/generate-xcode` or the `swift-xcodegen` script i
1212
./swift-xcodegen <build dir>
1313
```
1414

15-
where `<build dir>` is the path to the build directory e.g `build/Ninja-RelWithDebInfoAssert`. This will by default create a `Swift.xcodeproj` in the parent directory (next to the `build` directory). Projects for LLVM, LLDB, and Clang may also be created by passing `--llvm`, `--lldb`, and `--clang` respectively. Workspaces of useful combinations will also be created (e.g Swift+LLVM, Clang+LLVM).
15+
where `<build dir>` is the path to the build directory e.g `build/Ninja-RelWithDebInfoAssert`. This will by default create a `Swift.xcodeproj` in the parent directory (next to the `build` directory). Projects for LLVM, LLDB, and Clang may also be created by passing `--llvm`, `--lldb`, and `--clang`, respectively. Workspaces of useful combinations will also be created (e.g Swift+LLVM, Clang+LLVM).
1616

1717
For the full set of options, see the [Command usage](#command-usage) below.
1818

19-
An `ALL` meta-target is created that depends on all the targets in the given project or workspace. A scheme for this target is automatically generated too (and automatic scheme generation is disabled). You can manually add individual schemes for targets you're interested in. Note however that Clang targets do not currently have dependency information.
19+
An `ALL` meta-target is created that depends on all the targets in the given project or workspace. A scheme for this target is automatically generated too (and automatic scheme generation is disabled). You can manually add individual schemes for targets you're interested in. Note, however, that Clang targets do not currently have dependency information.
2020

2121
## Debugging
2222

@@ -95,7 +95,6 @@ PROJECT CONFIGURATION:
9595
folder references to be used for compatible targets. This allows new
9696
source files to be added to a target without needing to regenerate the
9797
project. (default: --buildable-folders)
98-
9998
--runtimes-build-dir <runtimes-build-dir>
10099
Experimental: The path to a build directory for the new 'Runtimes/'
101100
stdlib CMake build. This creates a separate 'SwiftRuntimes' project, along
@@ -107,10 +106,10 @@ PROJECT CONFIGURATION:
107106
MISC:
108107
--project-root-dir <project-root-dir>
109108
The project root directory, which is the parent directory of the Swift repo.
110-
By default this is inferred from the build directory path.
111-
--output-dir <output-dir>
112-
The output directory to write the Xcode project to. Defaults to the project
113-
root directory.
109+
By default, this is inferred from the build directory path.
110+
-o, --output-dir <output-dir>
111+
The output directory to write the Xcode project to. Defaults to the
112+
project root directory.
114113
--log-level <log-level> The log level verbosity (default: info) (values: debug, info, note, warning, error)
115114
--parallel/--no-parallel
116115
Parallelize generation of projects (default: --parallel)

utils/swift-xcodegen/Sources/SwiftXcodeGen/BuildArgs/BuildArgs.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@
22
//
33
// This source file is part of the Swift.org open source project
44
//
5-
// Copyright (c) 2024 Apple Inc. and the Swift project authors
5+
// Copyright (c) 2024 - 2025 Apple Inc. and the Swift project authors
66
// Licensed under Apache License v2.0 with Runtime Library Exception
77
//
88
// See https://swift.org/LICENSE.txt for license information
99
// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
1010
//
1111
//===----------------------------------------------------------------------===//
1212

13-
struct BuildArgs {
13+
struct BuildArgs: Sendable {
1414
let command: KnownCommand
1515
private var topLevelArgs: [Command.Argument] = []
1616
private var subOptArgs: [SubOptionArgs] = []

utils/swift-xcodegen/Sources/SwiftXcodeGen/BuildArgs/ClangBuildArgsProvider.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
//
33
// This source file is part of the Swift.org open source project
44
//
5-
// Copyright (c) 2024 Apple Inc. and the Swift project authors
5+
// Copyright (c) 2024 - 2025 Apple Inc. and the Swift project authors
66
// Licensed under Apache License v2.0 with Runtime Library Exception
77
//
88
// See https://swift.org/LICENSE.txt for license information
@@ -12,7 +12,7 @@
1212

1313
import Foundation
1414

15-
struct ClangBuildArgsProvider {
15+
struct ClangBuildArgsProvider: Sendable {
1616
private var args = CommandArgTree()
1717
private var outputs: [RelativePath: AbsolutePath] = [:]
1818

utils/swift-xcodegen/Sources/SwiftXcodeGen/BuildArgs/RunnableTargets.swift

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,24 @@
22
//
33
// This source file is part of the Swift.org open source project
44
//
5-
// Copyright (c) 2024 Apple Inc. and the Swift project authors
5+
// Copyright (c) 2024 - 2025 Apple Inc. and the Swift project authors
66
// Licensed under Apache License v2.0 with Runtime Library Exception
77
//
88
// See https://swift.org/LICENSE.txt for license information
99
// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
1010
//
1111
//===----------------------------------------------------------------------===//
1212

13+
import System
14+
1315
/// A target that defines a runnable executable.
1416
struct RunnableTarget: Hashable {
1517
var name: String
1618
var ninjaTargetName: String
1719
var path: AbsolutePath
1820
}
1921

20-
struct RunnableTargets {
22+
struct RunnableTargets: Sendable {
2123
private var addedPaths: Set<RelativePath> = []
2224
private var targets: [RunnableTarget] = []
2325

utils/swift-xcodegen/Sources/SwiftXcodeGen/BuildArgs/SwiftTargets.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@
22
//
33
// This source file is part of the Swift.org open source project
44
//
5-
// Copyright (c) 2024 Apple Inc. and the Swift project authors
5+
// Copyright (c) 2024 - 2025 Apple Inc. and the Swift project authors
66
// Licensed under Apache License v2.0 with Runtime Library Exception
77
//
88
// See https://swift.org/LICENSE.txt for license information
99
// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
1010
//
1111
//===----------------------------------------------------------------------===//
1212

13-
struct SwiftTargets {
13+
struct SwiftTargets: Sendable {
1414
private var targets: [SwiftTarget] = []
1515

1616
private var outputAliases: [String: [String]] = [:]

utils/swift-xcodegen/Sources/SwiftXcodeGen/Command/Command.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
//
33
// This source file is part of the Swift.org open source project
44
//
5-
// Copyright (c) 2024 Apple Inc. and the Swift project authors
5+
// Copyright (c) 2024 - 2025 Apple Inc. and the Swift project authors
66
// Licensed under Apache License v2.0 with Runtime Library Exception
77
//
88
// See https://swift.org/LICENSE.txt for license information
@@ -21,7 +21,7 @@ struct Command: Hashable {
2121
}
2222

2323
extension Command: Decodable {
24-
init(from decoder: Decoder) throws {
24+
init(from decoder: any Decoder) throws {
2525
let command = try decoder.singleValueContainer().decode(String.self)
2626
self = try CommandParser.parseCommand(command)
2727
}

utils/swift-xcodegen/Sources/SwiftXcodeGen/Command/CompileCommands.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
//
33
// This source file is part of the Swift.org open source project
44
//
5-
// Copyright (c) 2024 Apple Inc. and the Swift project authors
5+
// Copyright (c) 2024 - 2025 Apple Inc. and the Swift project authors
66
// Licensed under Apache License v2.0 with Runtime Library Exception
77
//
88
// See https://swift.org/LICENSE.txt for license information
@@ -18,7 +18,7 @@ struct CompileCommands: Decodable {
1818
self.commands = commands
1919
}
2020

21-
public init(from decoder: Decoder) throws {
21+
public init(from decoder: any Decoder) throws {
2222
self.init(try decoder.singleValueContainer().decode([Element].self))
2323
}
2424
}

utils/swift-xcodegen/Sources/SwiftXcodeGen/Concurrency/Lock.swift

Lines changed: 0 additions & 43 deletions
This file was deleted.
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
//===--- Mutex+Extensions.swift -------------------------------------------===//
2+
//
3+
// This source file is part of the Swift.org open source project
4+
//
5+
// Copyright (c) 2025 Apple Inc. and the Swift project authors
6+
// Licensed under Apache License v2.0 with Runtime Library Exception
7+
//
8+
// See https://swift.org/LICENSE.txt for license information
9+
// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
10+
//
11+
//===----------------------------------------------------------------------===//
12+
13+
import Synchronization
14+
15+
extension Mutex {
16+
init() where Value == Void {
17+
self.init(())
18+
}
19+
20+
init<T>() where Value == T? {
21+
self.init(nil)
22+
}
23+
24+
init<T>() where Value == [T] {
25+
self.init([])
26+
}
27+
28+
init<T, U>() where Value == [T: U] {
29+
self.init([:])
30+
}
31+
}
32+
33+
/// Having to write `_ in` when the value is `Void` is annoying.
34+
extension Mutex where Value == Void {
35+
borrowing func withLock<Result: ~Copyable & Sendable, E>(
36+
_ body: () throws(E) -> sending Result
37+
) throws(E) -> sending Result {
38+
return try self.withLock { _ throws(E) in
39+
try body()
40+
}
41+
}
42+
}

0 commit comments

Comments
 (0)