Skip to content

Commit 55de49d

Browse files
committed
[utils] swift-xcodegen: Bump deployment target to macOS 15 and use Mutex
1 parent 8358329 commit 55de49d

File tree

8 files changed

+62
-96
lines changed

8 files changed

+62
-96
lines changed

utils/swift-xcodegen/Package.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ 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",

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+
}

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

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

utils/swift-xcodegen/Sources/SwiftXcodeGen/Logging/Logger.swift

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,11 @@
1111
//===----------------------------------------------------------------------===//
1212

1313
import Foundation
14+
import Synchronization
1415

1516
public final class Logger: @unchecked Sendable {
16-
private let stateLock = Lock()
17-
private let outputLock = Lock()
17+
private let stateLock = Mutex<Void>()
18+
private let outputLock = Mutex<Void>()
1819

1920
private var _hadError = false
2021
public var hadError: Bool {
@@ -44,7 +45,7 @@ public final class Logger: @unchecked Sendable {
4445
}
4546

4647
extension Logger {
47-
public enum LogLevel: Comparable {
48+
public enum LogLevel: Comparable, Sendable {
4849
/// A message with information that isn't useful to the user, but is
4950
/// useful when debugging issues.
5051
case debug

utils/swift-xcodegen/Sources/SwiftXcodeGen/Ninja/NinjaBuildDir.swift

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,22 @@
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 Synchronization
14+
1315
public final class NinjaBuildDir: Sendable {
1416
public let path: AbsolutePath
1517
public let projectRootDir: AbsolutePath
1618
private let _tripleSuffix: Result<String, Error>
1719

18-
private let repoBuildDirs = MutexBox<[Repo: RepoBuildDir]>()
20+
private let repoBuildDirs = Mutex<[Repo: RepoBuildDir]>()
1921

2022
private static func detectTripleSuffix(
2123
buildDir: AbsolutePath

utils/swift-xcodegen/Sources/SwiftXcodeGen/Ninja/RepoBuildDir.swift

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,16 @@
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 Synchronization
14+
1315
public final class RepoBuildDir: Sendable {
1416
public let projectRootDir: AbsolutePath
1517
public let repo: Repo
@@ -19,10 +21,10 @@ public final class RepoBuildDir: Sendable {
1921

2022
private let repoDirCache: DirectoryCache
2123

22-
private let _ninjaFile = MutexBox<NinjaBuildFile?>()
23-
private let _runnableTargets = MutexBox<RunnableTargets?>()
24-
private let _clangArgs = MutexBox<ClangBuildArgsProvider?>()
25-
private let _swiftTargets = MutexBox<SwiftTargets?>()
24+
private let _ninjaFile = Mutex<NinjaBuildFile?>()
25+
private let _runnableTargets = Mutex<RunnableTargets?>()
26+
private let _clangArgs = Mutex<ClangBuildArgsProvider?>()
27+
private let _swiftTargets = Mutex<SwiftTargets?>()
2628

2729
init(_ repo: Repo, for parent: NinjaBuildDir) throws {
2830
self.projectRootDir = parent.projectRootDir

utils/swift-xcodegen/Sources/SwiftXcodeGen/Path/DirectoryCache.swift

Lines changed: 4 additions & 3 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
@@ -11,13 +11,14 @@
1111
//===----------------------------------------------------------------------===//
1212

1313
import Foundation
14+
import Synchronization
1415

1516
/// A simple cache for the recursive contents of a directory under a given
1617
/// root path. This is pretty basic and doesn't handle cases where we've already
1718
/// cached the parent.
18-
struct DirectoryCache {
19+
struct DirectoryCache: ~Copyable {
1920
private let root: AbsolutePath
20-
private let storage = MutexBox<[RelativePath: [RelativePath]]>()
21+
private let storage = Mutex<[RelativePath: [RelativePath]]>()
2122

2223
init(root: AbsolutePath) {
2324
self.root = root

0 commit comments

Comments
 (0)