mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
[utils] swift-xcodegen: Enable some Swift 7 upcoming features
This commit is contained in:
@@ -33,6 +33,34 @@ let package = Package(
|
||||
swiftLanguageModes: [.v6]
|
||||
)
|
||||
|
||||
// Apply global Swift settings to targets.
|
||||
do {
|
||||
var globalSwiftSettings: [SwiftSetting] = [
|
||||
// Swift 7 mode upcoming features. These must be compatible with 'swift-tools-version'.
|
||||
.enableUpcomingFeature("ExistentialAny"),
|
||||
.enableUpcomingFeature("InternalImportsByDefault"),
|
||||
.enableUpcomingFeature("MemberImportVisibility"),
|
||||
.enableUpcomingFeature("NonisolatedNonsendingByDefault"),
|
||||
]
|
||||
|
||||
#if compiler(>=6.1)
|
||||
globalSwiftSettings.append(
|
||||
.unsafeFlags(["-Werror", "ExistentialAny"])
|
||||
)
|
||||
#endif
|
||||
|
||||
globalSwiftSettings += [] // avoid unused warning
|
||||
|
||||
for target in package.targets where target.type != .plugin {
|
||||
if let swiftSettings = target.swiftSettings {
|
||||
// Target-specific settings should come last.
|
||||
target.swiftSettings = globalSwiftSettings + swiftSettings
|
||||
} else {
|
||||
target.swiftSettings = globalSwiftSettings
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ProcessInfo.processInfo.environment["SWIFTCI_USE_LOCAL_DEPS"] == nil {
|
||||
package.dependencies += [
|
||||
.package(url: "https://github.com/apple/swift-argument-parser", from: "1.4.0"),
|
||||
|
||||
@@ -10,6 +10,8 @@
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
import System
|
||||
|
||||
/// A target that defines a runnable executable.
|
||||
struct RunnableTarget: Hashable {
|
||||
var name: String
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
//
|
||||
// This source file is part of the Swift.org open source project
|
||||
//
|
||||
// Copyright (c) 2024 Apple Inc. and the Swift project authors
|
||||
// Copyright (c) 2024 - 2025 Apple Inc. and the Swift project authors
|
||||
// Licensed under Apache License v2.0 with Runtime Library Exception
|
||||
//
|
||||
// See https://swift.org/LICENSE.txt for license information
|
||||
@@ -21,7 +21,7 @@ struct Command: Hashable {
|
||||
}
|
||||
|
||||
extension Command: Decodable {
|
||||
init(from decoder: Decoder) throws {
|
||||
init(from decoder: any Decoder) throws {
|
||||
let command = try decoder.singleValueContainer().decode(String.self)
|
||||
self = try CommandParser.parseCommand(command)
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
//
|
||||
// This source file is part of the Swift.org open source project
|
||||
//
|
||||
// Copyright (c) 2024 Apple Inc. and the Swift project authors
|
||||
// Copyright (c) 2024 - 2025 Apple Inc. and the Swift project authors
|
||||
// Licensed under Apache License v2.0 with Runtime Library Exception
|
||||
//
|
||||
// See https://swift.org/LICENSE.txt for license information
|
||||
@@ -18,7 +18,7 @@ struct CompileCommands: Decodable {
|
||||
self.commands = commands
|
||||
}
|
||||
|
||||
public init(from decoder: Decoder) throws {
|
||||
public init(from decoder: any Decoder) throws {
|
||||
self.init(try decoder.singleValueContainer().decode([Element].self))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
//
|
||||
// This source file is part of the Swift.org open source project
|
||||
//
|
||||
// Copyright (c) 2024 Apple Inc. and the Swift project authors
|
||||
// Copyright (c) 2024 - 2025 Apple Inc. and the Swift project authors
|
||||
// Licensed under Apache License v2.0 with Runtime Library Exception
|
||||
//
|
||||
// See https://swift.org/LICENSE.txt for license information
|
||||
@@ -10,7 +10,7 @@
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
import Foundation
|
||||
public import Foundation
|
||||
import Synchronization
|
||||
|
||||
public final class Logger: @unchecked Sendable {
|
||||
@@ -35,8 +35,8 @@ public final class Logger: @unchecked Sendable {
|
||||
set { stateLock.withLock { _useColor = newValue } }
|
||||
}
|
||||
|
||||
private var _output: LoggableStream?
|
||||
public var output: LoggableStream? {
|
||||
private var _output: (any LoggableStream)?
|
||||
public var output: (any LoggableStream)? {
|
||||
get { stateLock.withLock { _output } }
|
||||
set { stateLock.withLock { _output = newValue } }
|
||||
}
|
||||
@@ -100,7 +100,7 @@ extension Logger {
|
||||
}
|
||||
|
||||
public protocol Loggable {
|
||||
func write(to stream: LoggableStream, useColor: Bool)
|
||||
func write(to stream: any LoggableStream, useColor: Bool)
|
||||
}
|
||||
|
||||
extension Logger.LogLevel: Loggable, CustomStringConvertible {
|
||||
@@ -122,7 +122,7 @@ extension Logger.LogLevel: Loggable, CustomStringConvertible {
|
||||
case .error: .brightRed
|
||||
}
|
||||
}
|
||||
public func write(to stream: LoggableStream, useColor: Bool) {
|
||||
public func write(to stream: any LoggableStream, useColor: Bool) {
|
||||
let str = useColor
|
||||
? "\(fg: ansiColor)\(weight: .bold)\(self)\(fg: .normal)\(weight: .normal)"
|
||||
: "\(self)"
|
||||
|
||||
@@ -15,13 +15,13 @@ import Synchronization
|
||||
public final class NinjaBuildDir: Sendable {
|
||||
public let path: AbsolutePath
|
||||
public let projectRootDir: AbsolutePath
|
||||
private let _tripleSuffix: Result<String, Error>
|
||||
private let _tripleSuffix: Result<String, any Error>
|
||||
|
||||
private let repoBuildDirs = Mutex<[Repo: RepoBuildDir]>()
|
||||
|
||||
private static func detectTripleSuffix(
|
||||
buildDir: AbsolutePath
|
||||
) -> Result<String, Error> {
|
||||
) -> Result<String, any Error> {
|
||||
Result {
|
||||
for dir in try buildDir.getDirContents() {
|
||||
guard buildDir.appending(dir).isDirectory,
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
//
|
||||
// This source file is part of the Swift.org open source project
|
||||
//
|
||||
// Copyright (c) 2024 Apple Inc. and the Swift project authors
|
||||
// Copyright (c) 2024 - 2025 Apple Inc. and the Swift project authors
|
||||
// Licensed under Apache License v2.0 with Runtime Library Exception
|
||||
//
|
||||
// See https://swift.org/LICENSE.txt for license information
|
||||
@@ -10,8 +10,8 @@
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
import Foundation
|
||||
import System
|
||||
public import Foundation
|
||||
public import System
|
||||
|
||||
public struct AbsolutePath: PathProtocol, Sendable {
|
||||
public let storage: FilePath
|
||||
@@ -100,7 +100,7 @@ extension AbsolutePath: ExpressibleByStringLiteral, ExpressibleByStringInterpola
|
||||
}
|
||||
|
||||
extension AbsolutePath: Decodable {
|
||||
public init(from decoder: Decoder) throws {
|
||||
public init(from decoder: any Decoder) throws {
|
||||
let storage = FilePath(
|
||||
try decoder.singleValueContainer().decode(String.self)
|
||||
)
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
//
|
||||
// This source file is part of the Swift.org open source project
|
||||
//
|
||||
// Copyright (c) 2024 Apple Inc. and the Swift project authors
|
||||
// Copyright (c) 2024 - 2025 Apple Inc. and the Swift project authors
|
||||
// Licensed under Apache License v2.0 with Runtime Library Exception
|
||||
//
|
||||
// See https://swift.org/LICENSE.txt for license information
|
||||
@@ -10,8 +10,8 @@
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
import ArgumentParser
|
||||
import System
|
||||
public import protocol ArgumentParser.ExpressibleByArgument
|
||||
public import System
|
||||
|
||||
public enum AnyPath: PathProtocol, Sendable {
|
||||
case relative(RelativePath)
|
||||
@@ -64,7 +64,7 @@ extension AnyPath {
|
||||
}
|
||||
|
||||
extension AnyPath: Decodable {
|
||||
public init(from decoder: Decoder) throws {
|
||||
public init(from decoder: any Decoder) throws {
|
||||
self.init(try decoder.singleValueContainer().decode(String.self))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
//
|
||||
// This source file is part of the Swift.org open source project
|
||||
//
|
||||
// Copyright (c) 2024 Apple Inc. and the Swift project authors
|
||||
// Copyright (c) 2024 - 2025 Apple Inc. and the Swift project authors
|
||||
// Licensed under Apache License v2.0 with Runtime Library Exception
|
||||
//
|
||||
// See https://swift.org/LICENSE.txt for license information
|
||||
@@ -10,7 +10,8 @@
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
import System
|
||||
public import System
|
||||
import Foundation
|
||||
|
||||
public protocol PathProtocol: Hashable, CustomStringConvertible {
|
||||
var storage: FilePath { get }
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
//
|
||||
// This source file is part of the Swift.org open source project
|
||||
//
|
||||
// Copyright (c) 2024 Apple Inc. and the Swift project authors
|
||||
// Copyright (c) 2024 - 2025 Apple Inc. and the Swift project authors
|
||||
// Licensed under Apache License v2.0 with Runtime Library Exception
|
||||
//
|
||||
// See https://swift.org/LICENSE.txt for license information
|
||||
@@ -11,7 +11,7 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
import Foundation
|
||||
import System
|
||||
public import System
|
||||
|
||||
public struct RelativePath: PathProtocol, Sendable {
|
||||
public let storage: FilePath
|
||||
@@ -70,7 +70,7 @@ extension RelativePath: ExpressibleByStringLiteral, ExpressibleByStringInterpola
|
||||
}
|
||||
|
||||
extension RelativePath: Decodable {
|
||||
public init(from decoder: Decoder) throws {
|
||||
public init(from decoder: any Decoder) throws {
|
||||
self.init(try decoder.singleValueContainer().decode(String.self))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
//
|
||||
// This source file is part of the Swift.org open source project
|
||||
//
|
||||
// Copyright (c) 2024 Apple Inc. and the Swift project authors
|
||||
// Copyright (c) 2024 - 2025 Apple Inc. and the Swift project authors
|
||||
// Licensed under Apache License v2.0 with Runtime Library Exception
|
||||
//
|
||||
// See https://swift.org/LICENSE.txt for license information
|
||||
@@ -10,6 +10,8 @@
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
import Foundation
|
||||
|
||||
extension Dictionary {
|
||||
@inline(__always)
|
||||
mutating func withValue<R>(
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
//
|
||||
// This source file is part of the Swift open source project
|
||||
//
|
||||
// Copyright (c) 2014-2024 Apple Inc. and the Swift project authors
|
||||
// Copyright (c) 2014-2025 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
|
||||
@@ -10,7 +10,7 @@
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
import Foundation
|
||||
public import Foundation
|
||||
|
||||
/// A enum representing data types for legacy PropertyList type.
|
||||
/// Note that the `identifier` enum is not strictly necessary,
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
//
|
||||
// This source file is part of the Swift.org open source project
|
||||
//
|
||||
// Copyright (c) 2024 Apple Inc. and the Swift project authors
|
||||
// Copyright (c) 2024 - 2025 Apple Inc. and the Swift project authors
|
||||
// Licensed under Apache License v2.0 with Runtime Library Exception
|
||||
//
|
||||
// See https://swift.org/LICENSE.txt for license information
|
||||
@@ -113,7 +113,7 @@ fileprivate extension PropertyList {
|
||||
|
||||
struct _Encoder: Encoder {
|
||||
var userInfo: [CodingUserInfoKey: Any] { [:] }
|
||||
var codingPath: [CodingKey] { fatalError("Unsupported") }
|
||||
var codingPath: [any CodingKey] { fatalError("Unsupported") }
|
||||
|
||||
var result = Result()
|
||||
init() {}
|
||||
@@ -122,10 +122,10 @@ fileprivate extension PropertyList {
|
||||
.init(KeyedContainer<Key>(result: result.makeDictionary()))
|
||||
}
|
||||
|
||||
func unkeyedContainer() -> UnkeyedEncodingContainer {
|
||||
func unkeyedContainer() -> any UnkeyedEncodingContainer {
|
||||
UnkeyedContainer(result: result.makeArray())
|
||||
}
|
||||
func singleValueContainer() -> SingleValueEncodingContainer {
|
||||
func singleValueContainer() -> any SingleValueEncodingContainer {
|
||||
SingleValueContainer(result: result)
|
||||
}
|
||||
}
|
||||
@@ -133,7 +133,7 @@ fileprivate extension PropertyList {
|
||||
|
||||
extension PropertyList {
|
||||
fileprivate struct KeyedContainer<Key: CodingKey>: KeyedEncodingContainerProtocol {
|
||||
var codingPath: [CodingKey] { fatalError("Unsupported") }
|
||||
var codingPath: [any CodingKey] { fatalError("Unsupported") }
|
||||
var result: Result
|
||||
|
||||
mutating func encode(_ value: String, forKey key: Key) {
|
||||
@@ -144,10 +144,12 @@ extension PropertyList {
|
||||
result.dictionary[key.stringValue] = try .encode(value)
|
||||
}
|
||||
|
||||
mutating func nestedUnkeyedContainer(forKey key: Key) -> UnkeyedEncodingContainer { fatalError("Unsupported") }
|
||||
mutating func nestedUnkeyedContainer(forKey key: Key) -> any UnkeyedEncodingContainer {
|
||||
fatalError("Unsupported")
|
||||
}
|
||||
mutating func nestedContainer<NestedKey>(keyedBy keyType: NestedKey.Type, forKey key: Key) -> KeyedEncodingContainer<NestedKey> { fatalError("Unsupported") }
|
||||
mutating func superEncoder(forKey key: Key) -> Encoder { fatalError("Unsupported") }
|
||||
mutating func superEncoder() -> Encoder { fatalError("Unsupported") }
|
||||
mutating func superEncoder(forKey key: Key) -> any Encoder { fatalError("Unsupported") }
|
||||
mutating func superEncoder() -> any Encoder { fatalError("Unsupported") }
|
||||
mutating func encodeNil(forKey key: Key) { fatalError("Unsupported") }
|
||||
mutating func encode(_ value: Bool, forKey key: Key) { fatalError("Unsupported") }
|
||||
mutating func encode(_ value: Double, forKey key: Key) { fatalError("Unsupported") }
|
||||
@@ -165,7 +167,7 @@ extension PropertyList {
|
||||
}
|
||||
|
||||
fileprivate struct UnkeyedContainer: UnkeyedEncodingContainer {
|
||||
var codingPath: [CodingKey] { fatalError("Unsupported") }
|
||||
var codingPath: [any CodingKey] { fatalError("Unsupported") }
|
||||
|
||||
var result: Result
|
||||
var count: Int {
|
||||
@@ -181,8 +183,8 @@ extension PropertyList {
|
||||
}
|
||||
|
||||
mutating func nestedContainer<NestedKey: CodingKey>(keyedBy keyType: NestedKey.Type) -> KeyedEncodingContainer<NestedKey> { fatalError("Unsupported") }
|
||||
mutating func nestedUnkeyedContainer() -> UnkeyedEncodingContainer { fatalError("Unsupported") }
|
||||
mutating func superEncoder() -> Encoder { fatalError("Unsupported") }
|
||||
mutating func nestedUnkeyedContainer() -> any UnkeyedEncodingContainer { fatalError("Unsupported") }
|
||||
mutating func superEncoder() -> any Encoder { fatalError("Unsupported") }
|
||||
mutating func encodeNil() { fatalError("Unsupported") }
|
||||
mutating func encode(_ value: Bool) { fatalError("Unsupported") }
|
||||
mutating func encode(_ value: Double) { fatalError("Unsupported") }
|
||||
@@ -200,7 +202,7 @@ extension PropertyList {
|
||||
}
|
||||
|
||||
fileprivate struct SingleValueContainer: SingleValueEncodingContainer {
|
||||
var codingPath: [CodingKey] { fatalError("Unsupported") }
|
||||
var codingPath: [any CodingKey] { fatalError("Unsupported") }
|
||||
var result: Result
|
||||
|
||||
mutating func encode<T: Encodable>(_ value: T) throws {
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
//
|
||||
// This source file is part of the Swift open source project
|
||||
//
|
||||
// Copyright (c) 2014-2024 Apple Inc. and the Swift project authors
|
||||
// Copyright (c) 2014-2025 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
|
||||
@@ -204,7 +204,7 @@ extension Xcode.Target: PropertyListSerializable {
|
||||
dict["buildPhases"] = try .array(buildPhases.map({ phase in
|
||||
// Here we have the same problem as for Reference; we cannot inherit
|
||||
// functionality since we're in an extension.
|
||||
try .identifier(serializer.serialize(object: phase as! PropertyListSerializable))
|
||||
try .identifier(serializer.serialize(object: phase as! any PropertyListSerializable))
|
||||
}))
|
||||
/// Private wrapper class for a target dependency relation. This is
|
||||
/// glue between our value-based settings structures and the Xcode
|
||||
@@ -446,9 +446,9 @@ fileprivate class PropertyListSerializer {
|
||||
/// during the serialization and replaced with other objects having the
|
||||
/// same object identifier (a violation of our assumptions)
|
||||
struct SerializedObjectRef: Hashable, Equatable {
|
||||
let object: PropertyListSerializable
|
||||
let object: any PropertyListSerializable
|
||||
|
||||
init(_ object: PropertyListSerializable) {
|
||||
init(_ object: any PropertyListSerializable) {
|
||||
self.object = object
|
||||
}
|
||||
|
||||
@@ -473,7 +473,7 @@ fileprivate class PropertyListSerializer {
|
||||
var idsToDicts = [String: PropertyList]()
|
||||
|
||||
/// Returns the quoted identifier for the object, assigning one if needed.
|
||||
func id(of object: PropertyListSerializable) -> String {
|
||||
func id(of object: any PropertyListSerializable) -> String {
|
||||
// We need a "serialized object ref" wrapper for the `objsToIds` map.
|
||||
let serObjRef = SerializedObjectRef(object)
|
||||
if let id = objsToIds[serObjRef] {
|
||||
@@ -492,7 +492,7 @@ fileprivate class PropertyListSerializer {
|
||||
/// recursive invocations of `serialize(object:)`; the closure of these
|
||||
/// invocations end up serializing the whole object graph.
|
||||
@discardableResult
|
||||
func serialize(object: PropertyListSerializable) throws -> String {
|
||||
func serialize(object: any PropertyListSerializable) throws -> String {
|
||||
// Assign an id for the object, if it doesn't already have one.
|
||||
let id = self.id(of: object)
|
||||
|
||||
|
||||
@@ -295,7 +295,7 @@ struct SwiftXcodegen: AsyncParsableCommand, Sendable {
|
||||
|
||||
func runTask<R>(
|
||||
_ body: @escaping @Sendable () throws -> R
|
||||
) async throws -> Task<R, Error> {
|
||||
) async throws -> Task<R, any Error> {
|
||||
let task = Task(operation: body)
|
||||
if !self.parallel {
|
||||
_ = try await task.value
|
||||
|
||||
Reference in New Issue
Block a user