diff --git a/Mintfile b/Mintfile index 650a0e71..02b0690f 100644 --- a/Mintfile +++ b/Mintfile @@ -1,4 +1,4 @@ -dral3x/StringsLint@0.1.7 +dral3x/StringsLint@0.1.9 swiftlang/swift-format@600.0.0 -realm/SwiftLint@0.57.0 -peripheryapp/periphery@2.20.0 \ No newline at end of file +realm/SwiftLint@0.58.0 +peripheryapp/periphery@3.0.1 \ No newline at end of file diff --git a/Package.resolved b/Package.resolved index 28acdda5..519e7ca1 100644 --- a/Package.resolved +++ b/Package.resolved @@ -1,13 +1,13 @@ { - "originHash" : "f809a2c32ad5fa24ea844247b659272c2028e4a1b91ec708e451b3852ce74f9e", + "originHash" : "291aa31d257c8ebc7a33773ca74442778bf1f09d410b692f16909600bf6216fe", "pins" : [ { "identity" : "felinepine", "kind" : "remoteSourceControl", "location" : "https://github.com/brightdigit/FelinePine.git", "state" : { - "revision" : "b89389fcf3f1100d0765a6a21244df02b00fbc9e", - "version" : "1.0.0-beta.5" + "revision" : "7abf84e0cded44bc99fae106030e8e25e270dae0", + "version" : "1.0.0" } }, { @@ -15,8 +15,8 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/brightdigit/FelinePineSwift.git", "state" : { - "revision" : "60bef82f6a8e57475020a1a1fadcc6ed36088769", - "version" : "1.0.0-alpha.1" + "revision" : "e0a414b8ee7ba1290e9d3b32f4c6cceff95af508", + "version" : "1.0.0" } }, { @@ -24,17 +24,17 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/brightdigit/IPSWDownloads.git", "state" : { - "revision" : "f49b4c9a356ee031ec3874354f4d273174e5c570", - "version" : "1.0.0-beta.5" + "revision" : "48652b14ecfb832cc07481077657b165e4732dcb", + "version" : "1.0.1-beta.2" } }, { - "identity" : "operatingsystemversion", + "identity" : "osver", "kind" : "remoteSourceControl", - "location" : "https://github.com/brightdigit/OperatingSystemVersion.git", + "location" : "https://github.com/brightdigit/OSVer.git", "state" : { - "revision" : "bd3c70eb38da109ec6be9958e80ee495125d3232", - "version" : "1.0.0-beta.1" + "revision" : "448f170babc2f6c9897194a4b42719994639325d", + "version" : "1.0.0-beta.2" } }, { @@ -87,8 +87,8 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/apple/swift-http-types", "state" : { - "revision" : "ae67c8178eb46944fd85e4dc6dd970e1f3ed6ccd", - "version" : "1.3.0" + "revision" : "ef18d829e8b92d731ad27bb81583edd2094d1ce3", + "version" : "1.3.1" } }, { @@ -96,8 +96,8 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/apple/swift-log.git", "state" : { - "revision" : "9cb486020ebf03bfa5b5df985387a14a98744537", - "version" : "1.6.1" + "revision" : "96a2f8a0fa41e9e09af4585e2724c4e825410b91", + "version" : "1.6.2" } }, { @@ -105,8 +105,8 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/apple/swift-openapi-runtime", "state" : { - "revision" : "daa2fb54fe4a7f5187d7286047d5144c8cb97477", - "version" : "1.6.0" + "revision" : "23146bc8710ac5e57abb693113f02dc274cf39b6", + "version" : "1.8.0" } }, { diff --git a/Package.swift b/Package.swift index 069456b6..8cd5b46a 100644 --- a/Package.swift +++ b/Package.swift @@ -8,7 +8,7 @@ switch entry.productType { case .executable: return Self.executable(name: entry.name, targets: targets) case .library: -return Self.library(name: entry.name, type: entry.libraryType, targets: targets) +return Self.library(name: entry.name, type: entry.libraryType, targets: targets) } } } @@ -17,14 +17,10 @@ public enum SwiftSettingsBuilder { public static func buildPartialBlock(first: SwiftSetting) -> [SwiftSetting] { [first] } -public static func buildPartialBlock(accumulated: [SwiftSetting], next: SwiftSetting) --> [SwiftSetting] -{ +public static func buildPartialBlock(accumulated: [SwiftSetting], next: SwiftSetting) -> [SwiftSetting] { accumulated + [next] } -public static func buildPartialBlock(accumulated: [SwiftSetting], next: [SwiftSetting]) --> [SwiftSetting] -{ +public static func buildPartialBlock(accumulated: [SwiftSetting], next: [SwiftSetting]) -> [SwiftSetting] { accumulated + next } public static func buildPartialBlock(first: [SwiftSetting]) -> [SwiftSetting] { @@ -33,17 +29,12 @@ first public static func buildPartialBlock(first: any SwiftSettingsConvertible) -> [SwiftSetting] { first.swiftSettings() } -public static func buildPartialBlock( -accumulated: [SwiftSetting], -next: any SwiftSettingsConvertible -) -> [SwiftSetting] { +public static func buildPartialBlock(accumulated: [SwiftSetting], next: any SwiftSettingsConvertible) -> [SwiftSetting] { accumulated + next.swiftSettings() } } extension _PackageDescription_Target { -static func entry(_ entry: Target, swiftSettings: [SwiftSetting] = []) --> _PackageDescription_Target -{ +static func entry(_ entry: Target, swiftSettings: [SwiftSetting] = []) -> _PackageDescription_Target { let dependencies = entry.dependencies.map(\.targetDependency) switch entry.targetType { case .executable: @@ -95,17 +86,17 @@ var productTargets: [Target] { var targetType: TargetType { switch productType { case .library: -.regular +return .regular case .executable: -.executable +return .executable } } } extension Package { -convenience init( +public convenience init( name: String? = nil, @ProductsBuilder entries: @escaping () -> [any Product], -@PackageDependencyBuilder dependencies packageDependencies: @escaping () -> [any PackageDependency] = { [any PackageDependency] () }, +@PackageDependencyBuilder dependencies packageDependencies: @escaping () -> [any PackageDependency] = { [any PackageDependency]() }, @TestTargetBuilder testTargets: @escaping () -> any TestTargets = { [any TestTarget]() }, @SwiftSettingsBuilder swiftSettings: @escaping () -> [SwiftSetting] = { [SwiftSetting]() } ) { @@ -162,15 +153,15 @@ return self } } @resultBuilder -enum PackageDependencyBuilder { -internal static func buildPartialBlock(first: PackageDependency) -> [any PackageDependency] { +public enum PackageDependencyBuilder { +public static func buildPartialBlock(first: PackageDependency) -> [any PackageDependency] { [first] } -internal static func buildPartialBlock(accumulated: [any PackageDependency], next: PackageDependency) -> [any PackageDependency]{ +public static func buildPartialBlock(accumulated: [any PackageDependency], next: PackageDependency) -> [any PackageDependency] { accumulated + [next] } } -protocol PackageDependency: _Named { +public protocol PackageDependency: _Named { var packageName: String { get } var dependency: _PackageDescription_PackageDependency { get } } @@ -242,12 +233,11 @@ public var targetType: TargetType { } } @resultBuilder -enum DependencyBuilder { -static func buildPartialBlock(first: Dependency) -> any Dependencies { +public enum DependencyBuilder { +public static func buildPartialBlock(first: Dependency) -> any Dependencies { [first] } -static func buildPartialBlock(accumulated: any Dependencies, next: Dependency) -> any Dependencies -{ +public static func buildPartialBlock(accumulated: any Dependencies, next: Dependency) -> any Dependencies { accumulated + [next] } } @@ -299,35 +289,30 @@ first public static func buildPartialBlock(first: any Product) -> [any Product] { [first] } -public static func buildPartialBlock(accumulated: [any Product], next: any Product) --> [any Product] -{ +public static func buildPartialBlock(accumulated: [any Product], next: any Product) -> [any Product] { accumulated + [next] } -public static func buildPartialBlock(accumulated: [any Product], next: [any Product]) --> [any Product] -{ +public static func buildPartialBlock(accumulated: [any Product], next: [any Product]) -> [any Product] { accumulated + next } } -@resultBuilder -enum SupportedPlatformBuilder { -static func buildPartialBlock(first: SupportedPlatform) -> any SupportedPlatforms { +@resultBuilder public enum SupportedPlatformBuilder { +public static func buildPartialBlock(first: SupportedPlatform) -> any SupportedPlatforms { [first] } -static func buildPartialBlock(first: PlatformSet) -> any SupportedPlatforms { +public static func buildPartialBlock(first: PlatformSet) -> any SupportedPlatforms { first.body } -static func buildPartialBlock(first: any SupportedPlatforms) -> any SupportedPlatforms { +public static func buildPartialBlock(first: any SupportedPlatforms) -> any SupportedPlatforms { first } -static func buildPartialBlock( +public static func buildPartialBlock( accumulated: any SupportedPlatforms, next: any SupportedPlatforms ) -> any SupportedPlatforms { accumulated.appending(next) } -static func buildPartialBlock( +public static func buildPartialBlock( accumulated: any SupportedPlatforms, next: SupportedPlatform ) -> any SupportedPlatforms { @@ -340,11 +325,11 @@ self + dependencies } } @resultBuilder -enum ResourcesBuilder { -static func buildPartialBlock(first: Resource) -> [Resource] { +public enum ResourcesBuilder { +public static func buildPartialBlock(first: Resource) -> [Resource] { [first] } -static func buildPartialBlock(accumulated: [Resource], next: Resource) -> [Resource] { +public static func buildPartialBlock(accumulated: [Resource], next: Resource) -> [Resource] { accumulated + [next] } } @@ -365,13 +350,13 @@ extension FeatureState { public func swiftSetting(name: String) -> SwiftSetting { switch self { case .experimental: -.enableExperimentalFeature(name) +return .enableExperimentalFeature(name) case .upcoming: -.enableUpcomingFeature(name) +return .enableUpcomingFeature(name) } } } -protocol PlatformSet { +public protocol PlatformSet { @SupportedPlatformBuilder var body: any SupportedPlatforms { get } } @@ -379,7 +364,7 @@ public typealias _PackageDescription_Product = PackageDescription.Product public typealias _PackageDescription_Target = PackageDescription.Target public typealias _PackageDescription_TargetDependency = PackageDescription.Target.Dependency public typealias _PackageDescription_PackageDependency = PackageDescription.Package.Dependency -public typealias LibraryType = PackageDescription.Product.Library.LibraryType// +public typealias LibraryType = PackageDescription.Product.Library.LibraryType public struct GlobalActorIsolatedTypesUsability: SwiftSettingFeature { public var featureState: FeatureState { return .experimental @@ -432,7 +417,7 @@ return .experimental } public struct StrictConcurrency: SwiftSettingFeature { public let featureState: FeatureState -public init (featureState: FeatureState = .experimental) { +public init(featureState: FeatureState = .experimental) { self.featureState = featureState } } @@ -485,12 +470,12 @@ public struct Ounchecked: UnsafeFlag {} public struct ParseableOutput: UnsafeFlag {} public struct EmitObjcHeader: UnsafeFlag {} public struct EnableLibraryEvolution: UnsafeFlag {} -struct WarnLongExpressionTypeChecking : UnsafeFlag { -internal init(milliseconds: Int) { +public struct WarnLongExpressionTypeChecking : UnsafeFlag { +public init(milliseconds: Int) { self.milliseconds = milliseconds } -let milliseconds : Int -var unsafeFlagArguments: [String] { +public let milliseconds : Int +public var unsafeFlagArguments: [String] { [ "-Xfrontend", "-warn-long-expression-type-checking=\(milliseconds)" @@ -518,12 +503,12 @@ public struct Static: UnsafeFlag {} public struct EmitClangHeaderNonmodularIncludes: UnsafeFlag {} public struct SaveOptimizationRecord: UnsafeFlag {} public struct RcacheCompileJob: UnsafeFlag {} -struct WarnLongFunctionBodies : UnsafeFlag { -internal init(milliseconds: Int) { +public struct WarnLongFunctionBodies: UnsafeFlag { +public init(milliseconds: Int) { self.milliseconds = milliseconds } -let milliseconds : Int -var unsafeFlagArguments: [String] { +public let milliseconds: Int +public var unsafeFlagArguments: [String] { [ "-Xfrontend", "-warn-long-function-bodies=\(milliseconds)" @@ -644,8 +629,7 @@ func appending(_ testTargets: any TestTargets) -> Self } @resultBuilder public enum GroupBuilder { -public static func buildPartialBlock(accumulated: [U], next: T) -> [U] -where T.Output == U { +public static func buildPartialBlock(accumulated: [U], next: T) -> [U] where T.Output == U { accumulated + T.output(from: [next]) } public static func buildPartialBlock(first: T) -> [U] where T.Output == U { @@ -727,19 +711,19 @@ init(_ s: S) where S.Element == SupportedPlatform, S: Sequence func appending(_ platforms: any SupportedPlatforms) -> Self } @resultBuilder -enum TestTargetBuilder { -static func buildPartialBlock(first: [any TestTarget]) -> any TestTargets { +public enum TestTargetBuilder { +public static func buildPartialBlock(first: [any TestTarget]) -> any TestTargets { first } -static func buildPartialBlock(first: any TestTarget) -> any TestTargets { +public static func buildPartialBlock(first: any TestTarget) -> any TestTargets { [first] } -static func buildPartialBlock(accumulated: any TestTargets, next: any TestTarget) +public static func buildPartialBlock(accumulated: any TestTargets, next: any TestTarget) -> any TestTargets { accumulated + [next] } -static func buildPartialBlock(accumulated: any TestTargets, next: any TestTargets) +public static func buildPartialBlock(accumulated: any TestTargets, next: any TestTargets) -> any TestTargets { accumulated.appending(next) @@ -779,7 +763,11 @@ BushelDocs() RadiantKit() } } -struct BushelUtilities: Product, Target {} +struct BushelUtilities: Product, Target { +var dependencies: any Dependencies { +OSVer() +} +} struct BushelTestUtilities: Product, Target {} struct BushelHubIPSW: Product, Target { var dependencies: any Dependencies { @@ -873,7 +861,7 @@ RadiantDocs() struct BushelFoundation: Product, Target { var dependencies: any Dependencies { BushelUtilities() -OperatingSystemVersion() +OSVer() RadiantKit() } } @@ -956,11 +944,6 @@ var dependency: Package.Dependency { .package(url: "https://github.com/brightdigit/FelinePine.git", from: "1.0.0-beta.2") } } -struct OperatingSystemVersion: PackageDependency, TargetDependency { -var dependency: Package.Dependency { -.package(url: "https://github.com/brightdigit/OperatingSystemVersion.git", from: "1.0.0-beta.1") -} -} struct RadiantKit: PackageDependency, TargetDependency { var dependency: Package.Dependency { .package(url: "https://github.com/brightdigit/RadiantKit.git", from: "1.0.0-beta.1") @@ -968,12 +951,17 @@ var dependency: Package.Dependency { } struct IPSWDownloads: PackageDependency, TargetDependency { var dependency: Package.Dependency { -.package(url: "https://github.com/brightdigit/IPSWDownloads.git", from: "1.0.0-beta.4") +.package(url: "https://github.com/brightdigit/IPSWDownloads.git", from: "1.0.1-beta.1") +} +} +struct OSVer: PackageDependency, TargetDependency { +var dependency: Package.Dependency { +.package(url: "https://github.com/brightdigit/OSVer.git", from: "1.0.0-beta.2") } } struct FelinePineSwift: PackageDependency, TargetDependency { var dependency: Package.Dependency { -.package(url: "https://github.com/brightdigit/FelinePineSwift.git", from: "1.0.0-alpha.1") +.package(url: "https://github.com/brightdigit/FelinePineSwift.git", from: "1.0.0") } var condition: TargetDependencyCondition? { .notApple() diff --git a/Package/Sources/Dependencies/FelinePineSwift.swift b/Package/Sources/Dependencies/FelinePineSwift.swift index b200d518..ff374dab 100644 --- a/Package/Sources/Dependencies/FelinePineSwift.swift +++ b/Package/Sources/Dependencies/FelinePineSwift.swift @@ -31,7 +31,7 @@ import PackageDescription struct FelinePineSwift: PackageDependency, TargetDependency { var dependency: Package.Dependency { - .package(url: "https://github.com/brightdigit/FelinePineSwift.git", from: "1.0.0-alpha.1") + .package(url: "https://github.com/brightdigit/FelinePineSwift.git", from: "1.0.0") } var condition: TargetDependencyCondition? { diff --git a/Package/Sources/Dependencies/IPSWDownloads.swift b/Package/Sources/Dependencies/IPSWDownloads.swift index edc0bb64..4ba9b252 100644 --- a/Package/Sources/Dependencies/IPSWDownloads.swift +++ b/Package/Sources/Dependencies/IPSWDownloads.swift @@ -31,6 +31,6 @@ import Foundation struct IPSWDownloads: PackageDependency, TargetDependency { var dependency: Package.Dependency { - .package(url: "https://github.com/brightdigit/IPSWDownloads.git", from: "1.0.0-beta.4") + .package(url: "https://github.com/brightdigit/IPSWDownloads.git", from: "1.0.1-beta.1") } } diff --git a/Package/Sources/Dependencies/OperatingSystemVersion.swift b/Package/Sources/Dependencies/OSVer.swift similarity index 88% rename from Package/Sources/Dependencies/OperatingSystemVersion.swift rename to Package/Sources/Dependencies/OSVer.swift index 70923d0e..3dca98fc 100644 --- a/Package/Sources/Dependencies/OperatingSystemVersion.swift +++ b/Package/Sources/Dependencies/OSVer.swift @@ -29,8 +29,8 @@ import Foundation -struct OperatingSystemVersion: PackageDependency, TargetDependency { +struct OSVer: PackageDependency, TargetDependency { var dependency: Package.Dependency { - .package(url: "https://github.com/brightdigit/OperatingSystemVersion.git", from: "1.0.0-beta.1") + .package(url: "https://github.com/brightdigit/OSVer.git", from: "1.0.0-beta.2") } } diff --git a/Package/Sources/Products/BushelFoundation.swift b/Package/Sources/Products/BushelFoundation.swift index 0ed9c631..acae5333 100644 --- a/Package/Sources/Products/BushelFoundation.swift +++ b/Package/Sources/Products/BushelFoundation.swift @@ -30,7 +30,7 @@ struct BushelFoundation: Product, Target { var dependencies: any Dependencies { BushelUtilities() - OperatingSystemVersion() + OSVer() RadiantKit() } } diff --git a/Package/Sources/Products/BushelUtilities.swift b/Package/Sources/Products/BushelUtilities.swift index 0d23fe79..f1c85a4d 100644 --- a/Package/Sources/Products/BushelUtilities.swift +++ b/Package/Sources/Products/BushelUtilities.swift @@ -27,4 +27,8 @@ // OTHER DEALINGS IN THE SOFTWARE. // -struct BushelUtilities: Product, Target {} +struct BushelUtilities: Product, Target { + var dependencies: any Dependencies { + OSVer() + } +} diff --git a/Package/Sources/Tests/BushelFactoryTests.swift b/Package/Sources/Tests/BushelFactoryTests.swift index fae13eb3..d47aefa9 100644 --- a/Package/Sources/Tests/BushelFactoryTests.swift +++ b/Package/Sources/Tests/BushelFactoryTests.swift @@ -29,7 +29,6 @@ struct BushelFactoryTests: TestTarget { var dependencies: any Dependencies { - // BushelLocalization() BushelFactory() BushelTestUtilities() BushelFoundationWax() diff --git a/Package/Support/Array+Depedencies.swift b/Package/Support/Array+Depedencies.swift new file mode 100644 index 00000000..851c8a62 --- /dev/null +++ b/Package/Support/Array+Depedencies.swift @@ -0,0 +1,17 @@ + +// +// Array+Depedencies.swift +// Copyright (c) 2024 BrightDigit. +// Licensed under MIT License +// + +/// Extension to append `Dependencies` to an `Array` of `Dependency` elements. +extension Array: Dependencies where Element == Dependency { + /// Appends the provided `Dependencies` to the current `Array` of `Dependency` elements. + /// + /// - Parameter dependencies: The `Dependencies` to be appended. + /// - Returns: A new `Array` of `Dependency` elements containing the original elements and the appended `Dependencies`. + public func appending(_ dependencies: any Dependencies) -> [Dependency] { + self + dependencies + } +} diff --git a/Package/Support/Array+SupportedPlatforms.swift b/Package/Support/Array+SupportedPlatforms.swift new file mode 100644 index 00000000..8cc26817 --- /dev/null +++ b/Package/Support/Array+SupportedPlatforms.swift @@ -0,0 +1,13 @@ +// +// Array+SupportedPlatforms.swift +// Copyright (c) 2024 BrightDigit. +// Licensed under MIT License +// + +import PackageDescription + +extension Array: SupportedPlatforms where Element == SupportedPlatform { + public func appending(_ platforms: any SupportedPlatforms) -> Self { + self + .init(platforms) + } +} diff --git a/Package/Support/Array+TestTargets.swift b/Package/Support/Array+TestTargets.swift new file mode 100644 index 00000000..8254e26e --- /dev/null +++ b/Package/Support/Array+TestTargets.swift @@ -0,0 +1,11 @@ + +/// Extension for `Array` where the `Element` is any `TestTarget`. +extension Array: TestTargets where Element == any TestTarget { + /// Appends the given `TestTargets` to the current array. + /// + /// - Parameter testTargets: The `TestTargets` to append to the array. + /// - Returns: A new array containing the elements of the current array plus the elements of the `testTargets`. + public func appending(_ testTargets: any TestTargets) -> [any TestTarget] { + self + testTargets + } +} diff --git a/Package/Support/Dependencies.swift b/Package/Support/Dependencies.swift new file mode 100644 index 00000000..a4bc9325 --- /dev/null +++ b/Package/Support/Dependencies.swift @@ -0,0 +1,12 @@ + +/// A protocol that represents a collection of `Dependency` elements. +public protocol Dependencies: Sequence where Element == Dependency { + /// Initializes a `Dependencies` instance from a sequence of `Dependency` elements. + /// - Parameter s: A sequence of `Dependency` elements. + init(_ s: S) where S.Element == Dependency, S: Sequence + + /// Creates a new `Dependencies` instance by appending the provided `Dependencies` to the existing `Dependencies`. + /// - Parameter dependencies: The `Dependencies` to append. + /// - Returns: A new `Dependencies` instance that includes the existing `Dependencies` and the provided `Dependencies`. + func appending(_ dependencies: any Dependencies) -> Self +} diff --git a/Package/Support/Dependency.swift b/Package/Support/Dependency.swift new file mode 100644 index 00000000..13aeb3f5 --- /dev/null +++ b/Package/Support/Dependency.swift @@ -0,0 +1,14 @@ + +// +// Dependency.swift +// Copyright (c) 2024 BrightDigit. +// Licensed under MIT License +// + +import PackageDescription + +/// A protocol that defines a target dependency. +public protocol Dependency { + /// The target dependency for this protocol. + var targetDependency: _PackageDescription_TargetDependency { get } +} diff --git a/Package/Support/DependencyBuilder.swift b/Package/Support/DependencyBuilder.swift new file mode 100644 index 00000000..a4ffe05d --- /dev/null +++ b/Package/Support/DependencyBuilder.swift @@ -0,0 +1,18 @@ +/// A builder for creating collections of `Dependency` instances. +@resultBuilder +public enum DependencyBuilder { + /// Builds a partial block of dependencies, consisting of a single `Dependency`. + /// - Parameter first: The first `Dependency` in the block. + /// - Returns: An array containing the `first` `Dependency`. + public static func buildPartialBlock(first: Dependency) -> any Dependencies { + [first] + } + + /// Builds a partial block of dependencies, adding a new `Dependency` to an existing collection. + /// - Parameter accumulated: The existing collection of dependencies. + /// - Parameter next: The new `Dependency` to add to the collection. + /// - Returns: A new collection of dependencies, containing the accumulated dependencies and the `next` dependency. + public static func buildPartialBlock(accumulated: any Dependencies, next: Dependency) -> any Dependencies { + accumulated + [next] + } +} diff --git a/Package/Support/FeatureState.swift b/Package/Support/FeatureState.swift new file mode 100644 index 00000000..015bfaed --- /dev/null +++ b/Package/Support/FeatureState.swift @@ -0,0 +1,24 @@ + +import PackageDescription +/// Represents the state of a feature in the application. +public enum FeatureState { + /// The feature is upcoming and not yet available for use. + case upcoming + /// The feature is experimental and may have incomplete or unstable functionality. + case experimental +} + +extension FeatureState { + /// Creates a `SwiftSetting` based on the `FeatureState`. + /// + /// - Parameter name: The name of the feature. + /// - Returns: A `SwiftSetting` that enables the feature based on its state. + public func swiftSetting(name: String) -> SwiftSetting { + switch self { + case .experimental: + return .enableExperimentalFeature(name) + case .upcoming: + return .enableUpcomingFeature(name) + } + } +} diff --git a/Package/Support/Group.swift b/Package/Support/Group.swift new file mode 100644 index 00000000..ef7c4bcb --- /dev/null +++ b/Package/Support/Group.swift @@ -0,0 +1,27 @@ + +// +// Group.swift +// Copyright (c) 2024 BrightDigit. +// Licensed under MIT License +// + +import Foundation + +/// A group that can be used with the `@GroupBuilder` to create a collection of elements. +public struct Group { + /// Creates a new group with an optional name. + /// - Parameter name: The name of the group, or `nil` if the group has no name. + internal init(_ name: String? = nil) { + self.name = name + } + + /// The name of the group, or `nil` if the group has no name. + public let name: String? + + /// Executes the content closure and returns the resulting array of elements. + /// - Parameter content: A closure that returns an array of elements of type `T`. + /// - Returns: The array of elements returned by the content closure. + public func callAsFunction(@GroupBuilder content: () -> [T]) -> [T] { + content() + } +} diff --git a/Package/Support/GroupBuildable.swift b/Package/Support/GroupBuildable.swift new file mode 100644 index 00000000..410e98c0 --- /dev/null +++ b/Package/Support/GroupBuildable.swift @@ -0,0 +1,30 @@ + +// +// GroupBuildable.swift +// Copyright (c) 2024 BrightDigit. +// Licensed under MIT License +// + +import Foundation + +/// A protocol that defines a type that can be built from an array of itself. +public protocol GroupBuildable { + /// The type of the output. + associatedtype Output = Self + + /// Constructs an array of `Output` from the given array of `Self`. + /// + /// - Parameter array: The array of `Self` to construct the `Output` from. + /// - Returns: An array of `Output` constructed from the given array of `Self`. + static func output(from array: [Self]) -> [Self.Output] +} + +extension GroupBuildable where Output == Self { + /// Constructs an array of `Output` from the given array of `Self`. + /// + /// - Parameter array: The array of `Self` to construct the `Output` from. + /// - Returns: An array of `Output` constructed from the given array of `Self`. + static func output(from array: [Self]) -> [Self.Output] { + array + } +} diff --git a/Package/Support/GroupBuilder.swift b/Package/Support/GroupBuilder.swift new file mode 100644 index 00000000..4886eb3a --- /dev/null +++ b/Package/Support/GroupBuilder.swift @@ -0,0 +1,19 @@ +/// A builder for creating groups of elements. +@resultBuilder +public enum GroupBuilder { + /// Builds a partial block of the group by combining the accumulated elements with the output of the next `GroupBuildable` element. + /// - Parameters: + /// - accumulated: The accumulated elements in the group. + /// - next: The next `GroupBuildable` element to add to the group. + /// - Returns: The updated group of elements. + public static func buildPartialBlock(accumulated: [U], next: T) -> [U] where T.Output == U { + accumulated + T.output(from: [next]) + } + + /// Builds a partial block of the group with the output of the first `GroupBuildable` element. + /// - Parameter first: The first `GroupBuildable` element to add to the group. + /// - Returns: The group of elements. + public static func buildPartialBlock(first: T) -> [U] where T.Output == U { + T.output(from: [first]) + } +} diff --git a/Package/Support/LanguageTag.swift b/Package/Support/LanguageTag.swift new file mode 100644 index 00000000..5fa5e4b3 --- /dev/null +++ b/Package/Support/LanguageTag.swift @@ -0,0 +1,11 @@ +// +// LanguageTag.swift +// Copyright (c) 2024 BrightDigit. +// Licensed under MIT License +// + +import PackageDescription + +extension LanguageTag { + nonisolated(unsafe) static let english: LanguageTag = "en" +} diff --git a/Package/Support/Package+Extensions.swift b/Package/Support/Package+Extensions.swift new file mode 100644 index 00000000..adadb18b --- /dev/null +++ b/Package/Support/Package+Extensions.swift @@ -0,0 +1,85 @@ + +// +// Package+Extensions.swift +// Copyright (c) 2024 BrightDigit. +// Licensed under MIT License +// + +import PackageDescription + +extension Package { + /// Initializes a new `Package` instance with the provided properties. + /// - Parameters: + /// - name: The name of the package. If `nil`, the name will be inferred from the file path. + /// - entries: A closure that returns an array of `Product` instances. + /// - packageDependencies: A closure that returns an array of `PackageDependency` instances. + /// - testTargets: A closure that returns an array of `TestTarget` instances. + /// - swiftSettings: A closure that returns an array of `SwiftSetting` instances. + public convenience init( + name: String? = nil, + @ProductsBuilder entries: @escaping () -> [any Product], + @PackageDependencyBuilder dependencies packageDependencies: @escaping () -> [any PackageDependency] = { [any PackageDependency]() }, + @TestTargetBuilder testTargets: @escaping () -> any TestTargets = { [any TestTarget]() }, + @SwiftSettingsBuilder swiftSettings: @escaping () -> [SwiftSetting] = { [SwiftSetting]() } + ) { + let packageName: String + if let name { + packageName = name + } else { + var pathComponents = #filePath.split(separator: "/") + pathComponents.removeLast() + // swift-format-ignore: NeverForceUnwrap + packageName = String(pathComponents.last!) + } + let allTestTargets = testTargets() + let entries = entries() + let products = entries.map(_PackageDescription_Product.entry) + var targets = entries.flatMap(\.productTargets) + let allTargetsDependencies = targets.flatMap { $0.allDependencies() } + let allTestTargetsDependencies = allTestTargets.flatMap { $0.allDependencies() } + let dependencies = allTargetsDependencies + allTestTargetsDependencies + let targetDependencies = dependencies.compactMap { $0 as? Target } + let packageTargetDependencies = dependencies.compactMap { $0 as? TargetDependency } + let allPackageDependencies = packageTargetDependencies.map(\.package) + packageDependencies() + targets += targetDependencies + targets += allTestTargets.map { $0 as Target } + let packgeTargets = Dictionary( + grouping: targets, + by: { $0.name } + ) + .values + .compactMap(\.first) + .map { _PackageDescription_Target.entry($0, swiftSettings: swiftSettings()) } + let packageDeps = Dictionary( + grouping: allPackageDependencies, + by: { $0.packageName } + ) + .values.compactMap(\.first).map(\.dependency) + self.init( + name: packageName, + products: products, + dependencies: packageDeps, + targets: packgeTargets + ) + } +} + +extension Package { + /// Adds supported platforms to the package. + /// - Parameter supportedPlatforms: A closure that returns an array of `SupportedPlatforms` instances. + /// - Returns: The modified `Package` instance. + public func supportedPlatforms( + @SupportedPlatformBuilder supportedPlatforms: @escaping () -> any SupportedPlatforms + ) -> Package { + platforms = .init(supportedPlatforms()) + return self + } + + /// Sets the default localization for the package. + /// - Parameter defaultLocalization: The default localization for the package. + /// - Returns: The modified `Package` instance. + public func defaultLocalization(_ defaultLocalization: LanguageTag) -> Package { + self.defaultLocalization = defaultLocalization + return self + } +} diff --git a/Package/Support/PackageDependency.swift b/Package/Support/PackageDependency.swift new file mode 100644 index 00000000..8f21cd1c --- /dev/null +++ b/Package/Support/PackageDependency.swift @@ -0,0 +1,58 @@ +// +// PackageDependency.swift +// Copyright (c) 2024 BrightDigit. +// Licensed under MIT License +// + +import Foundation +import PackageDescription + +/// A protocol that represents a package dependency. +public protocol PackageDependency: _Named { + /// The name of the package. + var packageName: String { get } + /// The package dependency description. + var dependency: _PackageDescription_PackageDependency { get } +} + +extension PackageDependency where Self: TargetDependency { + /// The package dependency. + var package: any PackageDependency { + self + } + + /// The target dependency. + var targetDependency: _PackageDescription_TargetDependency { + switch dependency.kind { + case .sourceControl(let name, let location, requirement: _): + let packageName = name ?? location.packageName ?? self.packageName + return .product(name: productName, package: packageName, condition: self.condition) + case .fileSystem(let name, let path): + if let packageName = name ?? path.components(separatedBy: "/").last { + return .product(name: productName, package: packageName, condition: self.condition) + } else { + return .byName(name: productName) + } + case .registry: + return .byName(name: productName) + @unknown default: + return .byName(name: productName) + } + } +} + +extension PackageDependency { + /// The name of the package. + var packageName: String { + switch dependency.kind { + case .sourceControl(let name, let location, requirement: _): + return name ?? location.packageName ?? self.name + case .fileSystem(let name, let path): + return name ?? path.packageName ?? self.name + case .registry(let id, requirement: _): + return id + @unknown default: + return name + } + } +} diff --git a/Package/Support/PackageDependencyBuilder.swift b/Package/Support/PackageDependencyBuilder.swift new file mode 100644 index 00000000..ff517c35 --- /dev/null +++ b/Package/Support/PackageDependencyBuilder.swift @@ -0,0 +1,22 @@ + +/// A result builder for creating a list of `PackageDependency` values. +@resultBuilder +public enum PackageDependencyBuilder { + /// Builds a partial result block from a single `PackageDependency` value. + /// + /// - Parameter first: The first `PackageDependency` value. + /// - Returns: An array containing the first `PackageDependency` value. + public static func buildPartialBlock(first: PackageDependency) -> [any PackageDependency] { + [first] + } + + /// Builds a partial result block from an accumulated array of `PackageDependency` values and a new `PackageDependency` value. + /// + /// - Parameters: + /// - accumulated: The accumulated array of `PackageDependency` values. + /// - next: The new `PackageDependency` value to add to the array. + /// - Returns: The updated array of `PackageDependency` values. + public static func buildPartialBlock(accumulated: [any PackageDependency], next: PackageDependency) -> [any PackageDependency] { + accumulated + [next] + } +} diff --git a/Package/Support/PackageDescription.swift b/Package/Support/PackageDescription.swift new file mode 100644 index 00000000..9b2af975 --- /dev/null +++ b/Package/Support/PackageDescription.swift @@ -0,0 +1,27 @@ + +// +// PackageDescription.swift +// Copyright (c) 2024 BrightDigit. +// Licensed under MIT License +// + +import PackageDescription + +/// A type alias for `PackageDescription.Product`. +/// - Note: This alias is exempt from the "NoLeadingUnderscores" swift-format rule. +public typealias _PackageDescription_Product = PackageDescription.Product + +/// A type alias for `PackageDescription.Target`. +/// - Note: This alias is exempt from the "NoLeadingUnderscores" swift-format rule. +public typealias _PackageDescription_Target = PackageDescription.Target + +/// A type alias for `PackageDescription.Target.Dependency`. +/// - Note: This alias is exempt from the "NoLeadingUnderscores" swift-format rule. +public typealias _PackageDescription_TargetDependency = PackageDescription.Target.Dependency + +/// A type alias for `PackageDescription.Package.Dependency`. +/// - Note: This alias is exempt from the "NoLeadingUnderscores" swift-format rule. +public typealias _PackageDescription_PackageDependency = PackageDescription.Package.Dependency + +/// A type alias for `PackageDescription.Product.Library.LibraryType`. +public typealias LibraryType = PackageDescription.Product.Library.LibraryType diff --git a/Package/Support/PlatformSet.swift b/Package/Support/PlatformSet.swift new file mode 100644 index 00000000..2b9c5b58 --- /dev/null +++ b/Package/Support/PlatformSet.swift @@ -0,0 +1,7 @@ + +/// A protocol that defines a set of supported platforms. +public protocol PlatformSet { + /// The set of supported platforms, defined using the `@SupportedPlatformBuilder`. + @SupportedPlatformBuilder + var body: any SupportedPlatforms { get } +} diff --git a/Package/Support/Product+Target.swift b/Package/Support/Product+Target.swift new file mode 100644 index 00000000..d1cbe4cc --- /dev/null +++ b/Package/Support/Product+Target.swift @@ -0,0 +1,23 @@ + +// +// Product+Target.swift +// Copyright (c) 2024 BrightDigit. +// Licensed under MIT License +// + +extension Product where Self: Target { + /// An array of targets associated with the product. + var productTargets: [Target] { + [self] + } + + /// The type of the target. + var targetType: TargetType { + switch productType { + case .library: + return .regular + case .executable: + return .executable + } + } +} diff --git a/Package/Support/Product.swift b/Package/Support/Product.swift new file mode 100644 index 00000000..99b755ad --- /dev/null +++ b/Package/Support/Product.swift @@ -0,0 +1,32 @@ + +// +// Product.swift +// Copyright (c) 2024 BrightDigit. +// Licensed under MIT License +// + +import PackageDescription + +/// A protocol that defines a product. +public protocol Product: _Named, GroupBuildable { + /// The targets associated with the product. + var productTargets: [Target] { get } + + /// The type of the product. + var productType: ProductType { get } + + /// The type of the library, if the product is a library. + var libraryType: LibraryType? { get } +} + +extension Product { + /// The type of the product. + public var productType: ProductType { + .library + } + + /// The type of the library, if the product is a library. + public var libraryType: LibraryType? { + nil + } +} diff --git a/Package/Support/ProductType.swift b/Package/Support/ProductType.swift new file mode 100644 index 00000000..75acf2eb --- /dev/null +++ b/Package/Support/ProductType.swift @@ -0,0 +1,7 @@ +/// Represents the type of a product. +public enum ProductType { + /// Represents a library product. + case library + /// Represents an executable product. + case executable +} diff --git a/Package/Support/ProductsBuilder.swift b/Package/Support/ProductsBuilder.swift new file mode 100644 index 00000000..175ccdee --- /dev/null +++ b/Package/Support/ProductsBuilder.swift @@ -0,0 +1,40 @@ + +// +// ProductsBuilder.swift +// Copyright (c) 2024 BrightDigit. +// Licensed under MIT License +// + +/// A result builder for creating arrays of `Product` instances. +@resultBuilder +public enum ProductsBuilder { + /// Builds a partial block from the first element in the array. + /// - Parameter first: The first `Product` element in the array. + /// - Returns: An array containing the first `Product` element. + public static func buildPartialBlock(first: [any Product]) -> [any Product] { + first + } + + /// Builds a partial block from a single `Product` element. + /// - Parameter first: The `Product` element. + /// - Returns: An array containing the `Product` element. + public static func buildPartialBlock(first: any Product) -> [any Product] { + [first] + } + + /// Builds a partial block by accumulating the previous array of `Product` elements and adding the next `Product` element. + /// - Parameter accumulated: The previous array of `Product` elements. + /// - Parameter next: The next `Product` element to add. + /// - Returns: The updated array of `Product` elements. + public static func buildPartialBlock(accumulated: [any Product], next: any Product) -> [any Product] { + accumulated + [next] + } + + /// Builds a partial block by accumulating the previous array of `Product` elements and adding the next array of `Product` elements. + /// - Parameter accumulated: The previous array of `Product` elements. + /// - Parameter next: The next array of `Product` elements to add. + /// - Returns: The updated array of `Product` elements. + public static func buildPartialBlock(accumulated: [any Product], next: [any Product]) -> [any Product] { + accumulated + next + } +} diff --git a/Package/Support/ResourcesBuilder.swift b/Package/Support/ResourcesBuilder.swift new file mode 100644 index 00000000..6448f225 --- /dev/null +++ b/Package/Support/ResourcesBuilder.swift @@ -0,0 +1,30 @@ + +// +// ResourcesBuilder.swift +// Copyright (c) 2024 BrightDigit. +// Licensed under MIT License +// + +import PackageDescription + +/// A result builder for creating an array of `Resource` objects. +@resultBuilder +public enum ResourcesBuilder { + /// Builds a partial block with a single `Resource` object. + /// + /// - Parameter first: The first `Resource` object. + /// - Returns: An array containing the `first` `Resource` object. + public static func buildPartialBlock(first: Resource) -> [Resource] { + [first] + } + + /// Builds a partial block by appending a `Resource` object to an existing array of `Resource` objects. + /// + /// - Parameters: + /// - accumulated: The existing array of `Resource` objects. + /// - next: The `Resource` object to be appended. + /// - Returns: The updated array of `Resource` objects. + public static func buildPartialBlock(accumulated: [Resource], next: Resource) -> [Resource] { + accumulated + [next] + } +} diff --git a/Package/Support/String.swift b/Package/Support/String.swift new file mode 100644 index 00000000..c1f48fdf --- /dev/null +++ b/Package/Support/String.swift @@ -0,0 +1,22 @@ +/// An extension to the `String` type. +extension String { + /// The package name of the current string, if it is a valid package name. + /// + /// Assumes the package name is the last part of the string, separated by periods. + var packageName: String? { + split(separator: "/").last?.split(separator: ".").first.map(String.init) + } + + /// Converts a camel-case string to a snake-case string with a custom separator. + /// + /// - Parameter withSeparator: The separator to use between words in the snake-case string. Defaults to "-". + /// - Returns: The string converted to snake-case using the specified separator. + func camelToSnakeCaseFlag(withSeparator separator: String = "-") -> String { + separator + + enumerated() + .reduce("") { + $0 + ($1.offset > 0 && $1.element.isUppercase ? separator : "") + + String($1.element).lowercased() + } + } +} diff --git a/Package/Support/SupportedPlatformBuilder.swift b/Package/Support/SupportedPlatformBuilder.swift new file mode 100644 index 00000000..d80867b4 --- /dev/null +++ b/Package/Support/SupportedPlatformBuilder.swift @@ -0,0 +1,55 @@ +import PackageDescription + + +/// A builder for `SupportedPlatforms`. +@resultBuilder public enum SupportedPlatformBuilder { + /// Builds a partial block of `SupportedPlatforms` from a single `SupportedPlatform`. + /// + /// - Parameter first: A `SupportedPlatform` to include in the partial block. + /// - Returns: A partial block of `SupportedPlatforms` containing the provided `SupportedPlatform`. + public static func buildPartialBlock(first: SupportedPlatform) -> any SupportedPlatforms { + [first] + } + + /// Builds a partial block of `SupportedPlatforms` from a `PlatformSet`. + /// + /// - Parameter first: A `PlatformSet` to include in the partial block. + /// - Returns: A partial block of `SupportedPlatforms` containing the `SupportedPlatforms` from the provided `PlatformSet`. + public static func buildPartialBlock(first: PlatformSet) -> any SupportedPlatforms { + first.body + } + + /// Builds a partial block of `SupportedPlatforms` from an existing `SupportedPlatforms` instance. + /// + /// - Parameter first: A `SupportedPlatforms` instance to include in the partial block. + /// - Returns: The provided `SupportedPlatforms` instance. + public static func buildPartialBlock(first: any SupportedPlatforms) -> any SupportedPlatforms { + first + } + + /// Builds a partial block of `SupportedPlatforms` by appending one set of `SupportedPlatforms` to another. + /// + /// - Parameters: + /// - accumulated: The `SupportedPlatforms` to which the next set will be appended. + /// - next: The `SupportedPlatforms` to append to the accumulated set. + /// - Returns: The `SupportedPlatforms` with the next set appended. + public static func buildPartialBlock( + accumulated: any SupportedPlatforms, + next: any SupportedPlatforms + ) -> any SupportedPlatforms { + accumulated.appending(next) + } + + /// Builds a partial block of `SupportedPlatforms` by appending a single `SupportedPlatform` to an existing set of `SupportedPlatforms`. + /// + /// - Parameters: + /// - accumulated: The `SupportedPlatforms` to which the `SupportedPlatform` will be appended. + /// - next: The `SupportedPlatform` to append to the accumulated set. + /// - Returns: The `SupportedPlatforms` with the `SupportedPlatform` appended. + public static func buildPartialBlock( + accumulated: any SupportedPlatforms, + next: SupportedPlatform + ) -> any SupportedPlatforms { + accumulated.appending([next]) + } +} diff --git a/Package/Support/SupportedPlatforms.swift b/Package/Support/SupportedPlatforms.swift new file mode 100644 index 00000000..0e0fdb7d --- /dev/null +++ b/Package/Support/SupportedPlatforms.swift @@ -0,0 +1,12 @@ +// +// SupportedPlatforms.swift +// Copyright (c) 2024 BrightDigit. +// Licensed under MIT License +// + +import PackageDescription + +public protocol SupportedPlatforms: Sequence where Element == SupportedPlatform { + init(_ s: S) where S.Element == SupportedPlatform, S: Sequence + func appending(_ platforms: any SupportedPlatforms) -> Self +} diff --git a/Package/Support/SwiftSettingConvertible.swift b/Package/Support/SwiftSettingConvertible.swift new file mode 100644 index 00000000..10fba85d --- /dev/null +++ b/Package/Support/SwiftSettingConvertible.swift @@ -0,0 +1,23 @@ + +// +// SwiftSettingConvertible.swift +// Copyright (c) 2024 BrightDigit. +// Licensed under MIT License +// + +import PackageDescription + +/// A protocol that conforming types can use to represent a single `SwiftSetting`. +public protocol SwiftSettingConvertible: SwiftSettingsConvertible { + /// The `SwiftSetting` represented by this type. + var setting: SwiftSetting { get } +} + +extension SwiftSettingConvertible { + /// Returns an array containing the single `SwiftSetting` represented by this type. + /// + /// - Returns: An array containing the `SwiftSetting` represented by this type. + public func swiftSettings() -> [SwiftSetting] { + [setting] + } +} diff --git a/Package/Support/SwiftSettingFeature.swift b/Package/Support/SwiftSettingFeature.swift new file mode 100644 index 00000000..71286a3c --- /dev/null +++ b/Package/Support/SwiftSettingFeature.swift @@ -0,0 +1,21 @@ +// +// SwiftSettingFeature.swift +// Copyright (c) 2024 BrightDigit. +// Licensed under MIT License +// + +import PackageDescription + +public protocol SwiftSettingFeature: _Named, SwiftSettingConvertible { + var featureState: FeatureState { get } +} + +extension SwiftSettingFeature { + public var featureState: FeatureState { + .upcoming + } + + public var setting: SwiftSetting { + featureState.swiftSetting(name: name) + } +} diff --git a/Package/Support/SwiftSettings/Features/Experimental/AccessLevelOnImport.swift b/Package/Support/SwiftSettings/Features/Experimental/AccessLevelOnImport.swift new file mode 100644 index 00000000..78fb4554 --- /dev/null +++ b/Package/Support/SwiftSettings/Features/Experimental/AccessLevelOnImport.swift @@ -0,0 +1,7 @@ +/// `AccessLevelOnImport` is a `SwiftSettingFeature` that represents a feature related to access level on imports. +public struct AccessLevelOnImport: SwiftSettingFeature { + /// The feature state of the `AccessLevelOnImport` struct, which is always `.experimental`. + public var featureState: FeatureState { + return .experimental + } +} diff --git a/Package/Support/SwiftSettings/Features/Experimental/BitwiseCopyable.swift b/Package/Support/SwiftSettings/Features/Experimental/BitwiseCopyable.swift new file mode 100644 index 00000000..8cbb22ea --- /dev/null +++ b/Package/Support/SwiftSettings/Features/Experimental/BitwiseCopyable.swift @@ -0,0 +1,7 @@ +/// A feature that represents a bitwise copyable type. +public struct BitwiseCopyable: SwiftSettingFeature { + /// The current state of the feature. + public var featureState: FeatureState { + return .experimental + } +} diff --git a/Package/Support/SwiftSettings/Features/Experimental/GlobalActorIsolatedTypesUsability.swift b/Package/Support/SwiftSettings/Features/Experimental/GlobalActorIsolatedTypesUsability.swift new file mode 100644 index 00000000..62b3a76a --- /dev/null +++ b/Package/Support/SwiftSettings/Features/Experimental/GlobalActorIsolatedTypesUsability.swift @@ -0,0 +1,7 @@ +/// The `GlobalActorIsolatedTypesUsability` struct represents a feature in the Swift setting. +public struct GlobalActorIsolatedTypesUsability: SwiftSettingFeature { + /// The current state of the feature. + public var featureState: FeatureState { + return .experimental + } +} diff --git a/Package/Support/SwiftSettings/Features/Experimental/IsolatedAny.swift b/Package/Support/SwiftSettings/Features/Experimental/IsolatedAny.swift new file mode 100644 index 00000000..28f3488d --- /dev/null +++ b/Package/Support/SwiftSettings/Features/Experimental/IsolatedAny.swift @@ -0,0 +1,8 @@ + +/// A type-erased wrapper around any type that can be safely passed between isolated contexts. +public struct IsolatedAny: SwiftSettingFeature { + /// The current state of the feature. + public var featureState: FeatureState { + return .experimental + } +} diff --git a/Package/Support/SwiftSettings/Features/Experimental/MoveOnlyPartialConsumption.swift b/Package/Support/SwiftSettings/Features/Experimental/MoveOnlyPartialConsumption.swift new file mode 100644 index 00000000..45745d1a --- /dev/null +++ b/Package/Support/SwiftSettings/Features/Experimental/MoveOnlyPartialConsumption.swift @@ -0,0 +1,9 @@ + + +/// A struct representing a move-only partial consumption feature from proposal https://github.com/apple/swift-evolution/blob/main/proposals/0429-partial-consumption.md +public struct MoveOnlyPartialConsumption: SwiftSettingFeature { + /// The current state of the feature. + public var featureState: FeatureState { + return .experimental + } +} diff --git a/Package/Support/SwiftSettings/Features/Experimental/NestedProtocols.swift b/Package/Support/SwiftSettings/Features/Experimental/NestedProtocols.swift new file mode 100644 index 00000000..f4bb7301 --- /dev/null +++ b/Package/Support/SwiftSettings/Features/Experimental/NestedProtocols.swift @@ -0,0 +1,8 @@ +/// Represents a nested protocol feature in Swift. +public struct NestedProtocols: SwiftSettingFeature { + + /// The current state of the feature. + public var featureState: FeatureState { + return .experimental + } +} diff --git a/Package/Support/SwiftSettings/Features/Experimental/NoncopyableGenerics.swift b/Package/Support/SwiftSettings/Features/Experimental/NoncopyableGenerics.swift new file mode 100644 index 00000000..9b109cf3 --- /dev/null +++ b/Package/Support/SwiftSettings/Features/Experimental/NoncopyableGenerics.swift @@ -0,0 +1,8 @@ + +/// A struct that represents a non-copyable generic feature. +public struct NoncopyableGenerics: SwiftSettingFeature { + /// The feature state of the `NoncopyableGenerics` struct. + public var featureState: FeatureState { + return .experimental + } +} diff --git a/Package/Support/SwiftSettings/Features/Experimental/RegionBasedIsolation.swift b/Package/Support/SwiftSettings/Features/Experimental/RegionBasedIsolation.swift new file mode 100644 index 00000000..73514b45 --- /dev/null +++ b/Package/Support/SwiftSettings/Features/Experimental/RegionBasedIsolation.swift @@ -0,0 +1,8 @@ + +/// Represents a feature based on region-based isolation, as proposed in Swift Evolution Proposal 0414. +public struct RegionBasedIsolation: SwiftSettingFeature { + /// The state of the feature, which is always `.experimental`. + public var featureState: FeatureState { + return .experimental + } +} diff --git a/Package/Support/SwiftSettings/Features/Experimental/TransferringArgsAndResults.swift b/Package/Support/SwiftSettings/Features/Experimental/TransferringArgsAndResults.swift new file mode 100644 index 00000000..ca3ba62c --- /dev/null +++ b/Package/Support/SwiftSettings/Features/Experimental/TransferringArgsAndResults.swift @@ -0,0 +1,7 @@ +/// `TransferringArgsAndResults` is a `SwiftSettingFeature` struct that represents a feature in the Swift programming language. +public struct TransferringArgsAndResults: SwiftSettingFeature { + /// The feature state of the `TransferringArgsAndResults` struct. + public var featureState: FeatureState { + return .experimental + } +} diff --git a/Package/Support/SwiftSettings/Features/Experimental/VariadicGenerics.swift b/Package/Support/SwiftSettings/Features/Experimental/VariadicGenerics.swift new file mode 100644 index 00000000..001292c5 --- /dev/null +++ b/Package/Support/SwiftSettings/Features/Experimental/VariadicGenerics.swift @@ -0,0 +1,14 @@ + +// +// VariadicGenerics.swift +// Copyright (c) 2024 BrightDigit. +// Licensed under MIT License +// + +/// A struct representing a "Variadic Generics" feature. +public struct VariadicGenerics: SwiftSettingFeature { + /// The feature state of the "Variadic Generics" feature. + public var featureState: FeatureState { + return .experimental + } +} diff --git a/Package/Support/SwiftSettings/Features/StrictConcurrency.swift b/Package/Support/SwiftSettings/Features/StrictConcurrency.swift new file mode 100644 index 00000000..cc6eb7d4 --- /dev/null +++ b/Package/Support/SwiftSettings/Features/StrictConcurrency.swift @@ -0,0 +1,19 @@ + +// +// StrictConcurrency.swift +// Copyright (c) 2024 BrightDigit. +// Licensed under MIT License +// + +/// A struct that represents the Strict Concurrency feature. +public struct StrictConcurrency: SwiftSettingFeature { + /// The current state of the feature. + public let featureState: FeatureState + + /// Initializes a new instance of `StrictConcurrency` with the given feature state. + /// + /// - Parameter featureState: The feature state, defaults to `.experimental`. + public init(featureState: FeatureState = .experimental) { + self.featureState = featureState + } +} diff --git a/Package/Support/SwiftSettings/Features/Upcoming/DeprecateApplicationMain.swift b/Package/Support/SwiftSettings/Features/Upcoming/DeprecateApplicationMain.swift new file mode 100644 index 00000000..993f4f0d --- /dev/null +++ b/Package/Support/SwiftSettings/Features/Upcoming/DeprecateApplicationMain.swift @@ -0,0 +1,7 @@ +/// A struct that represents a feature in the Swift setting. +public struct DeprecateApplicationMain: SwiftSettingFeature { + /// The current state of the feature. + public var featureState: FeatureState { + return .upcoming + } +} diff --git a/Package/Support/SwiftSettings/Features/Upcoming/DisableOutwardActorInference.swift b/Package/Support/SwiftSettings/Features/Upcoming/DisableOutwardActorInference.swift new file mode 100644 index 00000000..22f776ef --- /dev/null +++ b/Package/Support/SwiftSettings/Features/Upcoming/DisableOutwardActorInference.swift @@ -0,0 +1,7 @@ +/// A type that disables outward actor inference. +public struct DisableOutwardActorInference: SwiftSettingFeature { + /// The current state of the feature. + public var featureState: FeatureState { + return .upcoming + } +} diff --git a/Package/Support/SwiftSettings/Features/Upcoming/DynamicActorIsolation.swift b/Package/Support/SwiftSettings/Features/Upcoming/DynamicActorIsolation.swift new file mode 100644 index 00000000..b009f586 --- /dev/null +++ b/Package/Support/SwiftSettings/Features/Upcoming/DynamicActorIsolation.swift @@ -0,0 +1,8 @@ + +/// A struct representing a dynamic actor isolation feature. +public struct DynamicActorIsolation: SwiftSettingFeature { + /// The feature state, which is set to `.upcoming`. + public var featureState: FeatureState { + return .upcoming + } +} diff --git a/Package/Support/SwiftSettings/Features/Upcoming/FullTypedThrows.swift b/Package/Support/SwiftSettings/Features/Upcoming/FullTypedThrows.swift new file mode 100644 index 00000000..fb1ab41c --- /dev/null +++ b/Package/Support/SwiftSettings/Features/Upcoming/FullTypedThrows.swift @@ -0,0 +1,7 @@ +/// `FullTypedThrows` is a `SwiftSettingFeature` that represents an upcoming feature. +public struct FullTypedThrows: SwiftSettingFeature { + /// The current state of the feature. + public var featureState: FeatureState { + return .upcoming + } +} diff --git a/Package/Support/SwiftSettings/Features/Upcoming/GlobalConcurrency.swift b/Package/Support/SwiftSettings/Features/Upcoming/GlobalConcurrency.swift new file mode 100644 index 00000000..a52f7c41 --- /dev/null +++ b/Package/Support/SwiftSettings/Features/Upcoming/GlobalConcurrency.swift @@ -0,0 +1,7 @@ +/// A struct that represents a Swift setting feature related to global concurrency. +public struct GlobalConcurrency: SwiftSettingFeature { + /// The current state of the feature. + public var featureState: FeatureState { + return .upcoming + } +} diff --git a/Package/Support/SwiftSettings/Features/Upcoming/ImportObjcForwardDeclarations.swift b/Package/Support/SwiftSettings/Features/Upcoming/ImportObjcForwardDeclarations.swift new file mode 100644 index 00000000..13ca9180 --- /dev/null +++ b/Package/Support/SwiftSettings/Features/Upcoming/ImportObjcForwardDeclarations.swift @@ -0,0 +1,7 @@ +/// Represents a Swift setting feature for importing Objective-C forward declarations. +public struct ImportObjcForwardDeclarations: SwiftSettingFeature { + /// The current state of the feature. + public var featureState: FeatureState { + return .upcoming + } +} diff --git a/Package/Support/SwiftSettings/Features/Upcoming/InferSendableFromCaptures.swift b/Package/Support/SwiftSettings/Features/Upcoming/InferSendableFromCaptures.swift new file mode 100644 index 00000000..efa13fab --- /dev/null +++ b/Package/Support/SwiftSettings/Features/Upcoming/InferSendableFromCaptures.swift @@ -0,0 +1,7 @@ +/// A struct that represents a Swift setting feature. +public struct InferSendableFromCaptures: SwiftSettingFeature { + /// The current state of the feature. + public var featureState: FeatureState { + return .upcoming + } +} diff --git a/Package/Support/SwiftSettings/Features/Upcoming/InternalImportsByDefault.swift b/Package/Support/SwiftSettings/Features/Upcoming/InternalImportsByDefault.swift new file mode 100644 index 00000000..e13a3c73 --- /dev/null +++ b/Package/Support/SwiftSettings/Features/Upcoming/InternalImportsByDefault.swift @@ -0,0 +1,7 @@ +/// A Swift setting feature that defaults imported modules to the `internal` access level. +public struct InternalImportsByDefault: SwiftSettingFeature { + /// The current state of the feature. + public var featureState: FeatureState { + return .upcoming + } +} diff --git a/Package/Support/SwiftSettings/Features/Upcoming/IsolatedDefaultValues.swift b/Package/Support/SwiftSettings/Features/Upcoming/IsolatedDefaultValues.swift new file mode 100644 index 00000000..0308e494 --- /dev/null +++ b/Package/Support/SwiftSettings/Features/Upcoming/IsolatedDefaultValues.swift @@ -0,0 +1,7 @@ +/// An isolated default values feature that conforms to the `SwiftSettingFeature` protocol. +public struct IsolatedDefaultValues: SwiftSettingFeature { + /// The current state of the feature. + public var featureState: FeatureState { + return .upcoming + } +} diff --git a/Package/Support/SwiftSettings/UnsafeFlags/ApplicationExtension.swift b/Package/Support/SwiftSettings/UnsafeFlags/ApplicationExtension.swift new file mode 100644 index 00000000..96284c65 --- /dev/null +++ b/Package/Support/SwiftSettings/UnsafeFlags/ApplicationExtension.swift @@ -0,0 +1,2 @@ +/// An `UnsafeFlag` representing the `-application-extension` flag. +public struct ApplicationExtension: UnsafeFlag {} diff --git a/Package/Support/SwiftSettings/UnsafeFlags/AvoidEmitModuleSourceInfo.swift b/Package/Support/SwiftSettings/UnsafeFlags/AvoidEmitModuleSourceInfo.swift new file mode 100644 index 00000000..11ef2d0c --- /dev/null +++ b/Package/Support/SwiftSettings/UnsafeFlags/AvoidEmitModuleSourceInfo.swift @@ -0,0 +1,2 @@ +/// Represents a flag that instructs the compiler to avoid emitting module source information. +public struct AvoidEmitModuleSourceInfo: UnsafeFlag {} diff --git a/Package/Support/SwiftSettings/UnsafeFlags/CacheCompileJob.swift b/Package/Support/SwiftSettings/UnsafeFlags/CacheCompileJob.swift new file mode 100644 index 00000000..c12a3870 --- /dev/null +++ b/Package/Support/SwiftSettings/UnsafeFlags/CacheCompileJob.swift @@ -0,0 +1,2 @@ +/// A struct that represents a cache compile job. +public struct CacheCompileJob: UnsafeFlag {} diff --git a/Package/Support/SwiftSettings/UnsafeFlags/CacheDisableReplay.swift b/Package/Support/SwiftSettings/UnsafeFlags/CacheDisableReplay.swift new file mode 100644 index 00000000..7e9d438a --- /dev/null +++ b/Package/Support/SwiftSettings/UnsafeFlags/CacheDisableReplay.swift @@ -0,0 +1,2 @@ +/// Represents the "-cache-disable-replay" flag for the Swift compiler. +public struct CacheDisableReplay: UnsafeFlag {} diff --git a/Package/Support/SwiftSettings/UnsafeFlags/ColorDiagnostics.swift b/Package/Support/SwiftSettings/UnsafeFlags/ColorDiagnostics.swift new file mode 100644 index 00000000..9e377c01 --- /dev/null +++ b/Package/Support/SwiftSettings/UnsafeFlags/ColorDiagnostics.swift @@ -0,0 +1,3 @@ + +/// A struct representing the "-color-diagnostics" flag. +public struct ColorDiagnostics: UnsafeFlag {} diff --git a/Package/Support/SwiftSettings/UnsafeFlags/ContinueBuildingAfterErrors.swift b/Package/Support/SwiftSettings/UnsafeFlags/ContinueBuildingAfterErrors.swift new file mode 100644 index 00000000..3a07fb37 --- /dev/null +++ b/Package/Support/SwiftSettings/UnsafeFlags/ContinueBuildingAfterErrors.swift @@ -0,0 +1,3 @@ + +/// A struct that represents the `"-continue-building-after-errors"` flag. +public struct ContinueBuildingAfterErrors: UnsafeFlag {} diff --git a/Package/Support/SwiftSettings/UnsafeFlags/DebugInfoStoreInvocation.swift b/Package/Support/SwiftSettings/UnsafeFlags/DebugInfoStoreInvocation.swift new file mode 100644 index 00000000..af4915f0 --- /dev/null +++ b/Package/Support/SwiftSettings/UnsafeFlags/DebugInfoStoreInvocation.swift @@ -0,0 +1,2 @@ +/// A struct representing the `"-debug-info-store-invocation"` compiler flag. +public struct DebugInfoStoreInvocation: UnsafeFlag {} diff --git a/Package/Support/SwiftSettings/UnsafeFlags/DisableActorDataRaceChecks.swift b/Package/Support/SwiftSettings/UnsafeFlags/DisableActorDataRaceChecks.swift new file mode 100644 index 00000000..5a388702 --- /dev/null +++ b/Package/Support/SwiftSettings/UnsafeFlags/DisableActorDataRaceChecks.swift @@ -0,0 +1,2 @@ +/// Disables actor data race checks in the Swift compiler. +public struct DisableActorDataRaceChecks: UnsafeFlag {} diff --git a/Package/Support/SwiftSettings/UnsafeFlags/DisableAutolinkingRuntimeCompatibility.swift b/Package/Support/SwiftSettings/UnsafeFlags/DisableAutolinkingRuntimeCompatibility.swift new file mode 100644 index 00000000..d635388b --- /dev/null +++ b/Package/Support/SwiftSettings/UnsafeFlags/DisableAutolinkingRuntimeCompatibility.swift @@ -0,0 +1,4 @@ +/// Represents a flag that disables the autolinking runtime compatibility. +/// +/// This struct is used to pass the `-disable-autolinking-runtime-compatibility` flag to the compiler. +public struct DisableAutolinkingRuntimeCompatibility: UnsafeFlag {} diff --git a/Package/Support/SwiftSettings/UnsafeFlags/DisableAutolinkingRuntimeCompatibilityConcurrency.swift b/Package/Support/SwiftSettings/UnsafeFlags/DisableAutolinkingRuntimeCompatibilityConcurrency.swift new file mode 100644 index 00000000..d281f798 --- /dev/null +++ b/Package/Support/SwiftSettings/UnsafeFlags/DisableAutolinkingRuntimeCompatibilityConcurrency.swift @@ -0,0 +1,3 @@ + +/// A struct that represents the "-disable-autolinking-runtime-compatibility-concurrency" compiler flag. +public struct DisableAutolinkingRuntimeCompatibilityConcurrency: UnsafeFlag {} diff --git a/Package/Support/SwiftSettings/UnsafeFlags/DisableAutolinkingRuntimeCompatibilityDynamicReplacements.swift b/Package/Support/SwiftSettings/UnsafeFlags/DisableAutolinkingRuntimeCompatibilityDynamicReplacements.swift new file mode 100644 index 00000000..7ace6525 --- /dev/null +++ b/Package/Support/SwiftSettings/UnsafeFlags/DisableAutolinkingRuntimeCompatibilityDynamicReplacements.swift @@ -0,0 +1,2 @@ +/// A struct that represents the "-disable-autolinking-runtime-compatibility-dynamic-replacements" unsafeFlag. +public struct DisableAutolinkingRuntimeCompatibilityDynamicReplacements: UnsafeFlag {} diff --git a/Package/Support/SwiftSettings/UnsafeFlags/DisableClangTarget.swift b/Package/Support/SwiftSettings/UnsafeFlags/DisableClangTarget.swift new file mode 100644 index 00000000..30da5797 --- /dev/null +++ b/Package/Support/SwiftSettings/UnsafeFlags/DisableClangTarget.swift @@ -0,0 +1,3 @@ + +/// A struct representing the "-disable-clang-target" flag for the Swift compiler. +public struct DisableClangTarget: UnsafeFlag {} diff --git a/Package/Support/SwiftSettings/UnsafeFlags/DisableIncrementalImports.swift b/Package/Support/SwiftSettings/UnsafeFlags/DisableIncrementalImports.swift new file mode 100644 index 00000000..f1973a70 --- /dev/null +++ b/Package/Support/SwiftSettings/UnsafeFlags/DisableIncrementalImports.swift @@ -0,0 +1,2 @@ +/// A struct that represents the `-disable-incremental-imports` Swift compiler flag. +public struct DisableIncrementalImports: UnsafeFlag {} diff --git a/Package/Support/SwiftSettings/UnsafeFlags/DisableMigratorFixits.swift b/Package/Support/SwiftSettings/UnsafeFlags/DisableMigratorFixits.swift new file mode 100644 index 00000000..a90c1005 --- /dev/null +++ b/Package/Support/SwiftSettings/UnsafeFlags/DisableMigratorFixits.swift @@ -0,0 +1,2 @@ +/// A struct that represents the `"-disable-migrator-fixits"` command-line flag. +public struct DisableMigratorFixits: UnsafeFlag {} diff --git a/Package/Support/SwiftSettings/UnsafeFlags/DisableOnlyOneDependencyFile.swift b/Package/Support/SwiftSettings/UnsafeFlags/DisableOnlyOneDependencyFile.swift new file mode 100644 index 00000000..6aa707b1 --- /dev/null +++ b/Package/Support/SwiftSettings/UnsafeFlags/DisableOnlyOneDependencyFile.swift @@ -0,0 +1,2 @@ +/// A struct that represents the "disable-only-one-dependency-file" flag. +public struct DisableOnlyOneDependencyFile: UnsafeFlag {} diff --git a/Package/Support/SwiftSettings/UnsafeFlags/DisableSandbox.swift b/Package/Support/SwiftSettings/UnsafeFlags/DisableSandbox.swift new file mode 100644 index 00000000..f22d7961 --- /dev/null +++ b/Package/Support/SwiftSettings/UnsafeFlags/DisableSandbox.swift @@ -0,0 +1,3 @@ + +/// A struct representing the "disable-sandbox" flag for unsafeFlags. +public struct DisableSandbox: UnsafeFlag {} diff --git a/Package/Support/SwiftSettings/UnsafeFlags/DisallowUseNewDriver.swift b/Package/Support/SwiftSettings/UnsafeFlags/DisallowUseNewDriver.swift new file mode 100644 index 00000000..0229910d --- /dev/null +++ b/Package/Support/SwiftSettings/UnsafeFlags/DisallowUseNewDriver.swift @@ -0,0 +1,2 @@ +/// Represents a flag that disallows the use of the new driver. +public struct DisallowUseNewDriver: UnsafeFlag {} diff --git a/Package/Support/SwiftSettings/UnsafeFlags/DriverTimeCompilation.swift b/Package/Support/SwiftSettings/UnsafeFlags/DriverTimeCompilation.swift new file mode 100644 index 00000000..4ab22fad --- /dev/null +++ b/Package/Support/SwiftSettings/UnsafeFlags/DriverTimeCompilation.swift @@ -0,0 +1,2 @@ +/// Represents a flag to enable driver time compilation. +public struct DriverTimeCompilation: UnsafeFlag {} diff --git a/Package/Support/SwiftSettings/UnsafeFlags/DumpAst.swift b/Package/Support/SwiftSettings/UnsafeFlags/DumpAst.swift new file mode 100644 index 00000000..206ea2f5 --- /dev/null +++ b/Package/Support/SwiftSettings/UnsafeFlags/DumpAst.swift @@ -0,0 +1,2 @@ +/// `DumpAst` is a `UnsafeFlag` struct that represents the `-dump-ast` command-line flag. +public struct DumpAst: UnsafeFlag {} diff --git a/Package/Support/SwiftSettings/UnsafeFlags/DumpParse.swift b/Package/Support/SwiftSettings/UnsafeFlags/DumpParse.swift new file mode 100644 index 00000000..b260b606 --- /dev/null +++ b/Package/Support/SwiftSettings/UnsafeFlags/DumpParse.swift @@ -0,0 +1,3 @@ + +/// A struct that represents the `--dump-parse` flag for the Swift compiler. +public struct DumpParse: UnsafeFlag {} diff --git a/Package/Support/SwiftSettings/UnsafeFlags/DumpPcm.swift b/Package/Support/SwiftSettings/UnsafeFlags/DumpPcm.swift new file mode 100644 index 00000000..8439ad94 --- /dev/null +++ b/Package/Support/SwiftSettings/UnsafeFlags/DumpPcm.swift @@ -0,0 +1,2 @@ +/// A struct that represents the `--dump-pcm` flag for the Swift compiler. +public struct DumpPcm: UnsafeFlag {} diff --git a/Package/Support/SwiftSettings/UnsafeFlags/DumpTypeInfo.swift b/Package/Support/SwiftSettings/UnsafeFlags/DumpTypeInfo.swift new file mode 100644 index 00000000..d8e26e4d --- /dev/null +++ b/Package/Support/SwiftSettings/UnsafeFlags/DumpTypeInfo.swift @@ -0,0 +1,2 @@ +/// Represents a flag that dumps type information. +public struct DumpTypeInfo: UnsafeFlag {} diff --git a/Package/Support/SwiftSettings/UnsafeFlags/DumpTypeRefinementContexts.swift b/Package/Support/SwiftSettings/UnsafeFlags/DumpTypeRefinementContexts.swift new file mode 100644 index 00000000..89a7786c --- /dev/null +++ b/Package/Support/SwiftSettings/UnsafeFlags/DumpTypeRefinementContexts.swift @@ -0,0 +1,2 @@ +/// A struct that represents the `"-dump-type-refinement-contexts"` unsafeFlag. +public struct DumpTypeRefinementContexts: UnsafeFlag {} diff --git a/Package/Support/SwiftSettings/UnsafeFlags/DumpUsr.swift b/Package/Support/SwiftSettings/UnsafeFlags/DumpUsr.swift new file mode 100644 index 00000000..96c6e6e1 --- /dev/null +++ b/Package/Support/SwiftSettings/UnsafeFlags/DumpUsr.swift @@ -0,0 +1,2 @@ +/// A struct that represents the `-dump-usr` flag for the compiler. +public struct DumpUsr: UnsafeFlag {} diff --git a/Package/Support/SwiftSettings/UnsafeFlags/EmbedBitcode.swift b/Package/Support/SwiftSettings/UnsafeFlags/EmbedBitcode.swift new file mode 100644 index 00000000..0a2d6044 --- /dev/null +++ b/Package/Support/SwiftSettings/UnsafeFlags/EmbedBitcode.swift @@ -0,0 +1,2 @@ +/// `EmbedBitcode` is a `UnsafeFlag` struct that enables embedding bitcode in the target binary. +public struct EmbedBitcode: UnsafeFlag {} diff --git a/Package/Support/SwiftSettings/UnsafeFlags/EmbedBitcodeMarker.swift b/Package/Support/SwiftSettings/UnsafeFlags/EmbedBitcodeMarker.swift new file mode 100644 index 00000000..1cdbca59 --- /dev/null +++ b/Package/Support/SwiftSettings/UnsafeFlags/EmbedBitcodeMarker.swift @@ -0,0 +1,2 @@ +/// A struct that represents the "-embed-bitcode-marker" unsafeFlag. +public struct EmbedBitcodeMarker: UnsafeFlag {} diff --git a/Package/Support/SwiftSettings/UnsafeFlags/EmitAssembly.swift b/Package/Support/SwiftSettings/UnsafeFlags/EmitAssembly.swift new file mode 100644 index 00000000..b3a704b8 --- /dev/null +++ b/Package/Support/SwiftSettings/UnsafeFlags/EmitAssembly.swift @@ -0,0 +1,2 @@ +/// Represents a flag that instructs the Swift compiler to emit assembly code. +public struct EmitAssembly: UnsafeFlag {} diff --git a/Package/Support/SwiftSettings/UnsafeFlags/EmitBc.swift b/Package/Support/SwiftSettings/UnsafeFlags/EmitBc.swift new file mode 100644 index 00000000..7a34904f --- /dev/null +++ b/Package/Support/SwiftSettings/UnsafeFlags/EmitBc.swift @@ -0,0 +1,2 @@ +/// Represents the "emit-bc" flag for the compiler. +public struct EmitBc: UnsafeFlag {} diff --git a/Package/Support/SwiftSettings/UnsafeFlags/EmitClangHeaderNonmodularIncludes.swift b/Package/Support/SwiftSettings/UnsafeFlags/EmitClangHeaderNonmodularIncludes.swift new file mode 100644 index 00000000..9cd446d8 --- /dev/null +++ b/Package/Support/SwiftSettings/UnsafeFlags/EmitClangHeaderNonmodularIncludes.swift @@ -0,0 +1,2 @@ +/// Represents a flag that emits non-modular includes in the Clang header. +public struct EmitClangHeaderNonmodularIncludes: UnsafeFlag {} diff --git a/Package/Support/SwiftSettings/UnsafeFlags/EmitDependencies.swift b/Package/Support/SwiftSettings/UnsafeFlags/EmitDependencies.swift new file mode 100644 index 00000000..9952ba9d --- /dev/null +++ b/Package/Support/SwiftSettings/UnsafeFlags/EmitDependencies.swift @@ -0,0 +1,9 @@ + +// +// EmitDependencies.swift +// Copyright (c) 2024 BrightDigit. +// Licensed under MIT License +// + +/// A flag that instructs the compiler to emit dependency information `unsafeFlags(["-emit-dependencies"])` +public struct EmitDependencies: UnsafeFlag {} diff --git a/Package/Support/SwiftSettings/UnsafeFlags/EmitDigesterBaseline.swift b/Package/Support/SwiftSettings/UnsafeFlags/EmitDigesterBaseline.swift new file mode 100644 index 00000000..af556762 --- /dev/null +++ b/Package/Support/SwiftSettings/UnsafeFlags/EmitDigesterBaseline.swift @@ -0,0 +1,2 @@ +/// A structure representing an unsafe flag to emit a digester baseline. +public struct EmitDigesterBaseline: UnsafeFlag {} diff --git a/Package/Support/SwiftSettings/UnsafeFlags/EmitExecutable.swift b/Package/Support/SwiftSettings/UnsafeFlags/EmitExecutable.swift new file mode 100644 index 00000000..afb6009b --- /dev/null +++ b/Package/Support/SwiftSettings/UnsafeFlags/EmitExecutable.swift @@ -0,0 +1,3 @@ + +/// A flag that instructs the Swift compiler to emit an executable. +public struct EmitExecutable: UnsafeFlag {} diff --git a/Package/Support/SwiftSettings/UnsafeFlags/EmitImportedModules.swift b/Package/Support/SwiftSettings/UnsafeFlags/EmitImportedModules.swift new file mode 100644 index 00000000..7c3a4c22 --- /dev/null +++ b/Package/Support/SwiftSettings/UnsafeFlags/EmitImportedModules.swift @@ -0,0 +1,2 @@ +/// Represents an unsafe flag that emits imported modules. +public struct EmitImportedModules: UnsafeFlag {} diff --git a/Package/Support/SwiftSettings/UnsafeFlags/EmitIr.swift b/Package/Support/SwiftSettings/UnsafeFlags/EmitIr.swift new file mode 100644 index 00000000..fccf1f7a --- /dev/null +++ b/Package/Support/SwiftSettings/UnsafeFlags/EmitIr.swift @@ -0,0 +1,2 @@ +/// Represents a flag that instructs the Swift compiler to emit LLVM IR. +public struct EmitIr: UnsafeFlag {} diff --git a/Package/Support/SwiftSettings/UnsafeFlags/EmitIrgen.swift b/Package/Support/SwiftSettings/UnsafeFlags/EmitIrgen.swift new file mode 100644 index 00000000..6548b783 --- /dev/null +++ b/Package/Support/SwiftSettings/UnsafeFlags/EmitIrgen.swift @@ -0,0 +1,2 @@ +/// Represents the "-emit-irgen" flag for the LLVM Intermediate Representation (IR) generator. +public struct EmitIrgen: UnsafeFlag {} diff --git a/Package/Support/SwiftSettings/UnsafeFlags/EmitLibrary.swift b/Package/Support/SwiftSettings/UnsafeFlags/EmitLibrary.swift new file mode 100644 index 00000000..1100a5e7 --- /dev/null +++ b/Package/Support/SwiftSettings/UnsafeFlags/EmitLibrary.swift @@ -0,0 +1,7 @@ +// EmitLibrary.swift +// Copyright (c) 2024 BrightDigit. +// Licensed under MIT License +// + +/// A flag that instructs the compiler to emit a library instead of an executable. +public struct EmitLibrary: UnsafeFlag {} diff --git a/Package/Support/SwiftSettings/UnsafeFlags/EmitLoadedModuleTrace.swift b/Package/Support/SwiftSettings/UnsafeFlags/EmitLoadedModuleTrace.swift new file mode 100644 index 00000000..e29c7b92 --- /dev/null +++ b/Package/Support/SwiftSettings/UnsafeFlags/EmitLoadedModuleTrace.swift @@ -0,0 +1,2 @@ +/// Emits a trace of the modules loaded during the compilation process. +public struct EmitLoadedModuleTrace: UnsafeFlag {} diff --git a/Package/Support/SwiftSettings/UnsafeFlags/EmitModule.swift b/Package/Support/SwiftSettings/UnsafeFlags/EmitModule.swift new file mode 100644 index 00000000..e2087ea8 --- /dev/null +++ b/Package/Support/SwiftSettings/UnsafeFlags/EmitModule.swift @@ -0,0 +1,2 @@ +/// Represents a flag that instructs the compiler to emit a module file. +public struct EmitModule: UnsafeFlag {} diff --git a/Package/Support/SwiftSettings/UnsafeFlags/EmitModuleInterface.swift b/Package/Support/SwiftSettings/UnsafeFlags/EmitModuleInterface.swift new file mode 100644 index 00000000..28f0f080 --- /dev/null +++ b/Package/Support/SwiftSettings/UnsafeFlags/EmitModuleInterface.swift @@ -0,0 +1,2 @@ +/// `EmitModuleInterface` is a `UnsafeFlag` that instructs the compiler to emit a module interface file. +public struct EmitModuleInterface: UnsafeFlag {} diff --git a/Package/Support/SwiftSettings/UnsafeFlags/EmitModuleSummary.swift b/Package/Support/SwiftSettings/UnsafeFlags/EmitModuleSummary.swift new file mode 100644 index 00000000..85f55f04 --- /dev/null +++ b/Package/Support/SwiftSettings/UnsafeFlags/EmitModuleSummary.swift @@ -0,0 +1,3 @@ + +/// A flag that enables the emission of a module summary for the current compilation. +public struct EmitModuleSummary: UnsafeFlag {} diff --git a/Package/Support/SwiftSettings/UnsafeFlags/EmitObjcHeader.swift b/Package/Support/SwiftSettings/UnsafeFlags/EmitObjcHeader.swift new file mode 100644 index 00000000..f7cf904a --- /dev/null +++ b/Package/Support/SwiftSettings/UnsafeFlags/EmitObjcHeader.swift @@ -0,0 +1,3 @@ + +/// Emits an Objective-C header file. +public struct EmitObjcHeader: UnsafeFlag {} diff --git a/Package/Support/SwiftSettings/UnsafeFlags/EmitObject.swift b/Package/Support/SwiftSettings/UnsafeFlags/EmitObject.swift new file mode 100644 index 00000000..6d44acd9 --- /dev/null +++ b/Package/Support/SwiftSettings/UnsafeFlags/EmitObject.swift @@ -0,0 +1,2 @@ +/// A struct representing the "-emit-object" flag for the Swift compiler. +public struct EmitObject: UnsafeFlag {} diff --git a/Package/Support/SwiftSettings/UnsafeFlags/EmitPcm.swift b/Package/Support/SwiftSettings/UnsafeFlags/EmitPcm.swift new file mode 100644 index 00000000..68af7bf0 --- /dev/null +++ b/Package/Support/SwiftSettings/UnsafeFlags/EmitPcm.swift @@ -0,0 +1,2 @@ +/// A flag that instructs the Swift compiler to emit a Portable C Microarchitecture (PCM) file. +public struct EmitPcm: UnsafeFlag {} diff --git a/Package/Support/SwiftSettings/UnsafeFlags/EmitSib.swift b/Package/Support/SwiftSettings/UnsafeFlags/EmitSib.swift new file mode 100644 index 00000000..2e062b19 --- /dev/null +++ b/Package/Support/SwiftSettings/UnsafeFlags/EmitSib.swift @@ -0,0 +1,2 @@ +/// A struct that represents the `-emit-sib` flag for the Swift compiler. +public struct EmitSib: UnsafeFlag {} diff --git a/Package/Support/SwiftSettings/UnsafeFlags/EmitSibgen.swift b/Package/Support/SwiftSettings/UnsafeFlags/EmitSibgen.swift new file mode 100644 index 00000000..c6b74ffa --- /dev/null +++ b/Package/Support/SwiftSettings/UnsafeFlags/EmitSibgen.swift @@ -0,0 +1,2 @@ +/// Represents a flag that instructs the Swift compiler to emit a side-by-side generation (SIBGen) file. +public struct EmitSibgen: UnsafeFlag {} diff --git a/Package/Support/SwiftSettings/UnsafeFlags/EmitSil.swift b/Package/Support/SwiftSettings/UnsafeFlags/EmitSil.swift new file mode 100644 index 00000000..e1893523 --- /dev/null +++ b/Package/Support/SwiftSettings/UnsafeFlags/EmitSil.swift @@ -0,0 +1,2 @@ +/// Represents the `-emit-sil` flag for the Swift compiler. +public struct EmitSil: UnsafeFlag {} diff --git a/Package/Support/SwiftSettings/UnsafeFlags/EmitSilgen.swift b/Package/Support/SwiftSettings/UnsafeFlags/EmitSilgen.swift new file mode 100644 index 00000000..4baa2093 --- /dev/null +++ b/Package/Support/SwiftSettings/UnsafeFlags/EmitSilgen.swift @@ -0,0 +1,2 @@ +/// Represents the "-emit-silgen" flag for the Swift compiler. +public struct EmitSilgen: UnsafeFlag {} diff --git a/Package/Support/SwiftSettings/UnsafeFlags/EmitSupportedFeatures.swift b/Package/Support/SwiftSettings/UnsafeFlags/EmitSupportedFeatures.swift new file mode 100644 index 00000000..9ce70be8 --- /dev/null +++ b/Package/Support/SwiftSettings/UnsafeFlags/EmitSupportedFeatures.swift @@ -0,0 +1,3 @@ + +/// A struct representing the "-emit-supported-features" flag for the Swift compiler. +public struct EmitSupportedFeatures: UnsafeFlag {} diff --git a/Package/Support/SwiftSettings/UnsafeFlags/EmitTbd.swift b/Package/Support/SwiftSettings/UnsafeFlags/EmitTbd.swift new file mode 100644 index 00000000..317defd1 --- /dev/null +++ b/Package/Support/SwiftSettings/UnsafeFlags/EmitTbd.swift @@ -0,0 +1,8 @@ +// +// EmitTbd.swift +// Copyright (c) 2024 BrightDigit. +// Licensed under MIT License +// + +/// A flag that instructs the compiler to emit a Textual Binary Descriptor (TBD) file. +public struct EmitTbd: UnsafeFlag {} diff --git a/Package/Support/SwiftSettings/UnsafeFlags/EnableActorDataRaceChecks.swift b/Package/Support/SwiftSettings/UnsafeFlags/EnableActorDataRaceChecks.swift new file mode 100644 index 00000000..23c92bac --- /dev/null +++ b/Package/Support/SwiftSettings/UnsafeFlags/EnableActorDataRaceChecks.swift @@ -0,0 +1,3 @@ + +/// A struct that enables actor data race checks. +public struct EnableActorDataRaceChecks: UnsafeFlag {} diff --git a/Package/Support/SwiftSettings/UnsafeFlags/EnableAutolinkingRuntimeCompatibilityBytecodeLayouts.swift b/Package/Support/SwiftSettings/UnsafeFlags/EnableAutolinkingRuntimeCompatibilityBytecodeLayouts.swift new file mode 100644 index 00000000..dac25d80 --- /dev/null +++ b/Package/Support/SwiftSettings/UnsafeFlags/EnableAutolinkingRuntimeCompatibilityBytecodeLayouts.swift @@ -0,0 +1,3 @@ + +/// A struct that enables autolinking runtime compatibility bytecode layouts. +public struct EnableAutolinkingRuntimeCompatibilityBytecodeLayouts: UnsafeFlag {} diff --git a/Package/Support/SwiftSettings/UnsafeFlags/EnableBareSlashRegex.swift b/Package/Support/SwiftSettings/UnsafeFlags/EnableBareSlashRegex.swift new file mode 100644 index 00000000..2cbd5795 --- /dev/null +++ b/Package/Support/SwiftSettings/UnsafeFlags/EnableBareSlashRegex.swift @@ -0,0 +1,6 @@ +/// Enables the "bare slash regex" feature in the Swift compiler. +/// +/// This is an `UnsafeFlag` that should be used with caution, as it may introduce +/// unexpected behavior or security vulnerabilities. It is recommended to only +/// use this flag when necessary and with a thorough understanding of its implications. +public struct EnableBareSlashRegex: UnsafeFlag {} diff --git a/Package/Support/SwiftSettings/UnsafeFlags/EnableBuiltinModule.swift b/Package/Support/SwiftSettings/UnsafeFlags/EnableBuiltinModule.swift new file mode 100644 index 00000000..b190a98f --- /dev/null +++ b/Package/Support/SwiftSettings/UnsafeFlags/EnableBuiltinModule.swift @@ -0,0 +1,4 @@ +/// Enables the built-in module flag. +/// +/// The `EnableBuiltinModule` struct conforms to the `UnsafeFlag` protocol, which allows it to be used as an unsafe flag in the Swift compiler. +public struct EnableBuiltinModule: UnsafeFlag {} diff --git a/Package/Support/SwiftSettings/UnsafeFlags/EnableExperimentalAdditiveArithmeticDerivation.swift b/Package/Support/SwiftSettings/UnsafeFlags/EnableExperimentalAdditiveArithmeticDerivation.swift new file mode 100644 index 00000000..19becece --- /dev/null +++ b/Package/Support/SwiftSettings/UnsafeFlags/EnableExperimentalAdditiveArithmeticDerivation.swift @@ -0,0 +1,3 @@ + +/// A struct that represents the "-enable-experimental-additive-arithmetic-derivation" flag. +public struct EnableExperimentalAdditiveArithmeticDerivation: UnsafeFlag {} diff --git a/Package/Support/SwiftSettings/UnsafeFlags/EnableExperimentalConcisePoundFile.swift b/Package/Support/SwiftSettings/UnsafeFlags/EnableExperimentalConcisePoundFile.swift new file mode 100644 index 00000000..ec6850ca --- /dev/null +++ b/Package/Support/SwiftSettings/UnsafeFlags/EnableExperimentalConcisePoundFile.swift @@ -0,0 +1,3 @@ + +/// A struct that enables the experimental concise pound file feature. +public struct EnableExperimentalConcisePoundFile: UnsafeFlag {} diff --git a/Package/Support/SwiftSettings/UnsafeFlags/EnableExperimentalForwardModeDifferentiation.swift b/Package/Support/SwiftSettings/UnsafeFlags/EnableExperimentalForwardModeDifferentiation.swift new file mode 100644 index 00000000..1d0f2d95 --- /dev/null +++ b/Package/Support/SwiftSettings/UnsafeFlags/EnableExperimentalForwardModeDifferentiation.swift @@ -0,0 +1,3 @@ + +/// Enables the experimental forward mode differentiation feature in Swift. +public struct EnableExperimentalForwardModeDifferentiation: UnsafeFlag {} diff --git a/Package/Support/SwiftSettings/UnsafeFlags/EnableIncrementalImports.swift b/Package/Support/SwiftSettings/UnsafeFlags/EnableIncrementalImports.swift new file mode 100644 index 00000000..904386b2 --- /dev/null +++ b/Package/Support/SwiftSettings/UnsafeFlags/EnableIncrementalImports.swift @@ -0,0 +1,2 @@ +/// An `UnsafeFlag` that enables incremental imports. +public struct EnableIncrementalImports: UnsafeFlag {} diff --git a/Package/Support/SwiftSettings/UnsafeFlags/EnableLibraryEvolution.swift b/Package/Support/SwiftSettings/UnsafeFlags/EnableLibraryEvolution.swift new file mode 100644 index 00000000..c74f5f8a --- /dev/null +++ b/Package/Support/SwiftSettings/UnsafeFlags/EnableLibraryEvolution.swift @@ -0,0 +1,4 @@ + +///This struct represents the "enable-library-evolution" compiler flag. +///It is used to enable library evolution, which allows a library to evolve over time while maintaining binary compatibility. +public struct EnableLibraryEvolution: UnsafeFlag {} diff --git a/Package/Support/SwiftSettings/UnsafeFlags/EnableOnlyOneDependencyFile.swift b/Package/Support/SwiftSettings/UnsafeFlags/EnableOnlyOneDependencyFile.swift new file mode 100644 index 00000000..5e48a301 --- /dev/null +++ b/Package/Support/SwiftSettings/UnsafeFlags/EnableOnlyOneDependencyFile.swift @@ -0,0 +1,2 @@ +/// A struct that represents the "-enable-only-one-dependency-file" compiler flag. +public struct EnableOnlyOneDependencyFile: UnsafeFlag {} diff --git a/Package/Support/SwiftSettings/UnsafeFlags/FixitAll.swift b/Package/Support/SwiftSettings/UnsafeFlags/FixitAll.swift new file mode 100644 index 00000000..470e9106 --- /dev/null +++ b/Package/Support/SwiftSettings/UnsafeFlags/FixitAll.swift @@ -0,0 +1,2 @@ +/// Represents a flag that fixes all issues in the Swift code. +public struct FixitAll: UnsafeFlag {} diff --git a/Package/Support/SwiftSettings/UnsafeFlags/G.swift b/Package/Support/SwiftSettings/UnsafeFlags/G.swift new file mode 100644 index 00000000..64814871 --- /dev/null +++ b/Package/Support/SwiftSettings/UnsafeFlags/G.swift @@ -0,0 +1,2 @@ +/// A struct representing the `-g` flag for the Swift compiler. +public struct G: UnsafeFlag {} diff --git a/Package/Support/SwiftSettings/UnsafeFlags/GdwarfTypes.swift b/Package/Support/SwiftSettings/UnsafeFlags/GdwarfTypes.swift new file mode 100644 index 00000000..49313e3e --- /dev/null +++ b/Package/Support/SwiftSettings/UnsafeFlags/GdwarfTypes.swift @@ -0,0 +1,2 @@ +/// `GdwarfTypes` is a struct that conforms to the `UnsafeFlag` protocol. +public struct GdwarfTypes: UnsafeFlag {} diff --git a/Package/Support/SwiftSettings/UnsafeFlags/GlineTablesOnly.swift b/Package/Support/SwiftSettings/UnsafeFlags/GlineTablesOnly.swift new file mode 100644 index 00000000..f33b5f94 --- /dev/null +++ b/Package/Support/SwiftSettings/UnsafeFlags/GlineTablesOnly.swift @@ -0,0 +1,2 @@ +/// A `UnsafeFlag` that represents the `-gline-tables-only` compiler flag. +public struct GlineTablesOnly: UnsafeFlag {} diff --git a/Package/Support/SwiftSettings/UnsafeFlags/Gnone.swift b/Package/Support/SwiftSettings/UnsafeFlags/Gnone.swift new file mode 100644 index 00000000..c229e165 --- /dev/null +++ b/Package/Support/SwiftSettings/UnsafeFlags/Gnone.swift @@ -0,0 +1,2 @@ +/// A structure representing the "-gnone" unsafeFlag. +public struct Gnone: UnsafeFlag {} diff --git a/Package/Support/SwiftSettings/UnsafeFlags/Help.swift b/Package/Support/SwiftSettings/UnsafeFlags/Help.swift new file mode 100644 index 00000000..3cb47fce --- /dev/null +++ b/Package/Support/SwiftSettings/UnsafeFlags/Help.swift @@ -0,0 +1,2 @@ +/// Provides a command-line flag to display help information. +public struct Help: UnsafeFlag {} diff --git a/Package/Support/SwiftSettings/UnsafeFlags/ImportUnderlyingModule.swift b/Package/Support/SwiftSettings/UnsafeFlags/ImportUnderlyingModule.swift new file mode 100644 index 00000000..e323b657 --- /dev/null +++ b/Package/Support/SwiftSettings/UnsafeFlags/ImportUnderlyingModule.swift @@ -0,0 +1,3 @@ + +/// A struct that represents the unsafeFlag "-import-underlying-module". +public struct ImportUnderlyingModule: UnsafeFlag {} diff --git a/Package/Support/SwiftSettings/UnsafeFlags/IndexFile.swift b/Package/Support/SwiftSettings/UnsafeFlags/IndexFile.swift new file mode 100644 index 00000000..a17ef9f0 --- /dev/null +++ b/Package/Support/SwiftSettings/UnsafeFlags/IndexFile.swift @@ -0,0 +1,2 @@ +/// An `UnsafeFlag` that represents the `-index-file` command-line argument. +public struct IndexFile: UnsafeFlag {} diff --git a/Package/Support/SwiftSettings/UnsafeFlags/IndexIgnoreClangModules.swift b/Package/Support/SwiftSettings/UnsafeFlags/IndexIgnoreClangModules.swift new file mode 100644 index 00000000..9081f8ca --- /dev/null +++ b/Package/Support/SwiftSettings/UnsafeFlags/IndexIgnoreClangModules.swift @@ -0,0 +1,4 @@ +/// A struct representing the `index-ignore-clang-modules` unsafeFlag. +/// +/// This flag is used to ignore Clang modules when indexing code. +public struct IndexIgnoreClangModules: UnsafeFlag {} diff --git a/Package/Support/SwiftSettings/UnsafeFlags/IndexIgnoreSystemModules.swift b/Package/Support/SwiftSettings/UnsafeFlags/IndexIgnoreSystemModules.swift new file mode 100644 index 00000000..b17fcf21 --- /dev/null +++ b/Package/Support/SwiftSettings/UnsafeFlags/IndexIgnoreSystemModules.swift @@ -0,0 +1,2 @@ +/// A struct representing the "-index-ignore-system-modules" flag for the Swift compiler. +public struct IndexIgnoreSystemModules: UnsafeFlag {} diff --git a/Package/Support/SwiftSettings/UnsafeFlags/IndexIncludeLocals.swift b/Package/Support/SwiftSettings/UnsafeFlags/IndexIncludeLocals.swift new file mode 100644 index 00000000..4c362a53 --- /dev/null +++ b/Package/Support/SwiftSettings/UnsafeFlags/IndexIncludeLocals.swift @@ -0,0 +1,2 @@ +/// A flag that includes local variables in the index. +public struct IndexIncludeLocals: UnsafeFlag {} diff --git a/Package/Support/SwiftSettings/UnsafeFlags/LinkObjcRuntime.swift b/Package/Support/SwiftSettings/UnsafeFlags/LinkObjcRuntime.swift new file mode 100644 index 00000000..efbc7acc --- /dev/null +++ b/Package/Support/SwiftSettings/UnsafeFlags/LinkObjcRuntime.swift @@ -0,0 +1,2 @@ +/// Represents a flag that links the Objective-C runtime. +public struct LinkObjcRuntime: UnsafeFlag {} diff --git a/Package/Support/SwiftSettings/UnsafeFlags/MigrateKeepObjcVisibility.swift b/Package/Support/SwiftSettings/UnsafeFlags/MigrateKeepObjcVisibility.swift new file mode 100644 index 00000000..31fe41de --- /dev/null +++ b/Package/Support/SwiftSettings/UnsafeFlags/MigrateKeepObjcVisibility.swift @@ -0,0 +1,2 @@ +/// `MigrateKeepObjcVisibility` is a struct that conforms to the `UnsafeFlag` protocol. +public struct MigrateKeepObjcVisibility: UnsafeFlag {} diff --git a/Package/Support/SwiftSettings/UnsafeFlags/MigratorUpdateSdk.swift b/Package/Support/SwiftSettings/UnsafeFlags/MigratorUpdateSdk.swift new file mode 100644 index 00000000..d5f6ff89 --- /dev/null +++ b/Package/Support/SwiftSettings/UnsafeFlags/MigratorUpdateSdk.swift @@ -0,0 +1,3 @@ + +/// A struct representing an unsafe flag for updating the SDK during migration. +public struct MigratorUpdateSdk: UnsafeFlag {} diff --git a/Package/Support/SwiftSettings/UnsafeFlags/MigratorUpdateSwift.swift b/Package/Support/SwiftSettings/UnsafeFlags/MigratorUpdateSwift.swift new file mode 100644 index 00000000..65f92c08 --- /dev/null +++ b/Package/Support/SwiftSettings/UnsafeFlags/MigratorUpdateSwift.swift @@ -0,0 +1,2 @@ +/// Represents the "migrator-update-swift" flag for the Swift compiler. +public struct MigratorUpdateSwift: UnsafeFlag {} diff --git a/Package/Support/SwiftSettings/UnsafeFlags/NoColorDiagnostics.swift b/Package/Support/SwiftSettings/UnsafeFlags/NoColorDiagnostics.swift new file mode 100644 index 00000000..b2a3db26 --- /dev/null +++ b/Package/Support/SwiftSettings/UnsafeFlags/NoColorDiagnostics.swift @@ -0,0 +1,9 @@ + +// +// NoColorDiagnostics.swift +// Copyright (c) 2024 BrightDigit. +// Licensed under MIT License +// + +/// A struct representing the "-no-color-diagnostics" compiler flag. +public struct NoColorDiagnostics: UnsafeFlag {} diff --git a/Package/Support/SwiftSettings/UnsafeFlags/NoVerifyEmittedModuleInterface.swift b/Package/Support/SwiftSettings/UnsafeFlags/NoVerifyEmittedModuleInterface.swift new file mode 100644 index 00000000..1ea59f0c --- /dev/null +++ b/Package/Support/SwiftSettings/UnsafeFlags/NoVerifyEmittedModuleInterface.swift @@ -0,0 +1,2 @@ +/// A flag that disables verification of the emitted module interface. +public struct NoVerifyEmittedModuleInterface: UnsafeFlag {} diff --git a/Package/Support/SwiftSettings/UnsafeFlags/NoWarningsAsErrors.swift b/Package/Support/SwiftSettings/UnsafeFlags/NoWarningsAsErrors.swift new file mode 100644 index 00000000..bd8fc646 --- /dev/null +++ b/Package/Support/SwiftSettings/UnsafeFlags/NoWarningsAsErrors.swift @@ -0,0 +1,2 @@ +/// A struct that represents the `-no-warnings-as-errors` flag for the Swift compiler. +public struct NoWarningsAsErrors: UnsafeFlag {} diff --git a/Package/Support/SwiftSettings/UnsafeFlags/NoWholeModuleOptimization.swift b/Package/Support/SwiftSettings/UnsafeFlags/NoWholeModuleOptimization.swift new file mode 100644 index 00000000..3050a0b4 --- /dev/null +++ b/Package/Support/SwiftSettings/UnsafeFlags/NoWholeModuleOptimization.swift @@ -0,0 +1,2 @@ +/// Represents the "-no-whole-module-optimization" flag for the Swift compiler. +public struct NoWholeModuleOptimization: UnsafeFlag {} diff --git a/Package/Support/SwiftSettings/UnsafeFlags/Nostdimport.swift b/Package/Support/SwiftSettings/UnsafeFlags/Nostdimport.swift new file mode 100644 index 00000000..a978fb2c --- /dev/null +++ b/Package/Support/SwiftSettings/UnsafeFlags/Nostdimport.swift @@ -0,0 +1,3 @@ + +/// A struct representing the `-nostdimport` flag in Swift. +public struct Nostdimport: UnsafeFlag {} diff --git a/Package/Support/SwiftSettings/UnsafeFlags/O.swift b/Package/Support/SwiftSettings/UnsafeFlags/O.swift new file mode 100644 index 00000000..4fd1f4a8 --- /dev/null +++ b/Package/Support/SwiftSettings/UnsafeFlags/O.swift @@ -0,0 +1,2 @@ +/// An unsafe flag that represents the `-O` optimization flag. +public struct O: UnsafeFlag {} diff --git a/Package/Support/SwiftSettings/UnsafeFlags/Onone.swift b/Package/Support/SwiftSettings/UnsafeFlags/Onone.swift new file mode 100644 index 00000000..bf5d8893 --- /dev/null +++ b/Package/Support/SwiftSettings/UnsafeFlags/Onone.swift @@ -0,0 +1,2 @@ +/// Represents the "-Onone" compiler flag. +public struct Onone: UnsafeFlag {} diff --git a/Package/Support/SwiftSettings/UnsafeFlags/Osize.swift b/Package/Support/SwiftSettings/UnsafeFlags/Osize.swift new file mode 100644 index 00000000..2591c819 --- /dev/null +++ b/Package/Support/SwiftSettings/UnsafeFlags/Osize.swift @@ -0,0 +1,2 @@ +/// Represents the optimization flag `-Osize` in the Swift compiler. +public struct Osize: UnsafeFlag {} diff --git a/Package/Support/SwiftSettings/UnsafeFlags/Ounchecked.swift b/Package/Support/SwiftSettings/UnsafeFlags/Ounchecked.swift new file mode 100644 index 00000000..876d394a --- /dev/null +++ b/Package/Support/SwiftSettings/UnsafeFlags/Ounchecked.swift @@ -0,0 +1,2 @@ +/// Ounchecked is a `UnsafeFlag` that represents the `-Ounchecked` compiler flag. +public struct Ounchecked: UnsafeFlag {} diff --git a/Package/Support/SwiftSettings/UnsafeFlags/Parse.swift b/Package/Support/SwiftSettings/UnsafeFlags/Parse.swift new file mode 100644 index 00000000..48dd9af6 --- /dev/null +++ b/Package/Support/SwiftSettings/UnsafeFlags/Parse.swift @@ -0,0 +1,8 @@ +// +// Parse.swift +// Copyright (c) 2024 BrightDigit. +// Licensed under MIT License +// + +/// A struct representing an "unsafe flag" for the Parse command. +public struct Parse: UnsafeFlag {} diff --git a/Package/Support/SwiftSettings/UnsafeFlags/ParseAsLibrary.swift b/Package/Support/SwiftSettings/UnsafeFlags/ParseAsLibrary.swift new file mode 100644 index 00000000..e494aa04 --- /dev/null +++ b/Package/Support/SwiftSettings/UnsafeFlags/ParseAsLibrary.swift @@ -0,0 +1,8 @@ +// +// ParseAsLibrary.swift +// Copyright (c) 2024 BrightDigit. +// Licensed under MIT License +// + +/// A struct that represents the `-parse-as-library` compiler flag. +public struct ParseAsLibrary: UnsafeFlag {} diff --git a/Package/Support/SwiftSettings/UnsafeFlags/ParseSil.swift b/Package/Support/SwiftSettings/UnsafeFlags/ParseSil.swift new file mode 100644 index 00000000..5d18e46f --- /dev/null +++ b/Package/Support/SwiftSettings/UnsafeFlags/ParseSil.swift @@ -0,0 +1,2 @@ +/// An `UnsafeFlag` that enables parsing SIL (Swift Intermediate Language) during compilation. +public struct ParseSil: UnsafeFlag {} diff --git a/Package/Support/SwiftSettings/UnsafeFlags/ParseableOutput.swift b/Package/Support/SwiftSettings/UnsafeFlags/ParseableOutput.swift new file mode 100644 index 00000000..c9b2f978 --- /dev/null +++ b/Package/Support/SwiftSettings/UnsafeFlags/ParseableOutput.swift @@ -0,0 +1,2 @@ +/// Represents a command-line flag that enables the "parseable output" mode. +public struct ParseableOutput: UnsafeFlag {} diff --git a/Package/Support/SwiftSettings/UnsafeFlags/PrefixSerializedDebuggingOptions.swift b/Package/Support/SwiftSettings/UnsafeFlags/PrefixSerializedDebuggingOptions.swift new file mode 100644 index 00000000..214530e8 --- /dev/null +++ b/Package/Support/SwiftSettings/UnsafeFlags/PrefixSerializedDebuggingOptions.swift @@ -0,0 +1,3 @@ + +/// A struct that represents the "-prefix-serialized-debugging-options" unsafeFlag. +public struct PrefixSerializedDebuggingOptions: UnsafeFlag {} diff --git a/Package/Support/SwiftSettings/UnsafeFlags/PrettyPrint.swift b/Package/Support/SwiftSettings/UnsafeFlags/PrettyPrint.swift new file mode 100644 index 00000000..81b47137 --- /dev/null +++ b/Package/Support/SwiftSettings/UnsafeFlags/PrettyPrint.swift @@ -0,0 +1,3 @@ + +/// A struct that represents the "-pretty-print" flag for unsafeFlags. +public struct PrettyPrint: UnsafeFlag {} diff --git a/Package/Support/SwiftSettings/UnsafeFlags/PrintAst.swift b/Package/Support/SwiftSettings/UnsafeFlags/PrintAst.swift new file mode 100644 index 00000000..41dd230c --- /dev/null +++ b/Package/Support/SwiftSettings/UnsafeFlags/PrintAst.swift @@ -0,0 +1,2 @@ +/// Represents the `print-ast` unsafeFlag. +public struct PrintAst: UnsafeFlag {} diff --git a/Package/Support/SwiftSettings/UnsafeFlags/PrintAstDecl.swift b/Package/Support/SwiftSettings/UnsafeFlags/PrintAstDecl.swift new file mode 100644 index 00000000..96598cf1 --- /dev/null +++ b/Package/Support/SwiftSettings/UnsafeFlags/PrintAstDecl.swift @@ -0,0 +1,2 @@ +/// Represents a flag that prints the AST declaration. +public struct PrintAstDecl: UnsafeFlag {} diff --git a/Package/Support/SwiftSettings/UnsafeFlags/PrintEducationalNotes.swift b/Package/Support/SwiftSettings/UnsafeFlags/PrintEducationalNotes.swift new file mode 100644 index 00000000..bf2158ca --- /dev/null +++ b/Package/Support/SwiftSettings/UnsafeFlags/PrintEducationalNotes.swift @@ -0,0 +1,2 @@ +/// Represents a flag that enables the printing of educational notes during the build process. +public struct PrintEducationalNotes: UnsafeFlag {} diff --git a/Package/Support/SwiftSettings/UnsafeFlags/PrintTargetInfo.swift b/Package/Support/SwiftSettings/UnsafeFlags/PrintTargetInfo.swift new file mode 100644 index 00000000..20d7a209 --- /dev/null +++ b/Package/Support/SwiftSettings/UnsafeFlags/PrintTargetInfo.swift @@ -0,0 +1,8 @@ +// +// PrintTargetInfo.swift +// Copyright (c) 2024 BrightDigit. +// Licensed under MIT License +// + +/// A struct that represents the `--print-target-info` flag. +public struct PrintTargetInfo: UnsafeFlag {} diff --git a/Package/Support/SwiftSettings/UnsafeFlags/ProfileCoverageMapping.swift b/Package/Support/SwiftSettings/UnsafeFlags/ProfileCoverageMapping.swift new file mode 100644 index 00000000..c34d2084 --- /dev/null +++ b/Package/Support/SwiftSettings/UnsafeFlags/ProfileCoverageMapping.swift @@ -0,0 +1,9 @@ + +// +// ProfileCoverageMapping.swift +// Copyright (c) 2024 BrightDigit. +// Licensed under MIT License +// + +/// A struct representing the `--profile-coverage-mapping` flag for the Swift compiler. +public struct ProfileCoverageMapping: UnsafeFlag {} diff --git a/Package/Support/SwiftSettings/UnsafeFlags/ProfileGenerate.swift b/Package/Support/SwiftSettings/UnsafeFlags/ProfileGenerate.swift new file mode 100644 index 00000000..9ac69993 --- /dev/null +++ b/Package/Support/SwiftSettings/UnsafeFlags/ProfileGenerate.swift @@ -0,0 +1,2 @@ +/// Represents a profile generation flag for the compiler. +public struct ProfileGenerate: UnsafeFlag {} diff --git a/Package/Support/SwiftSettings/UnsafeFlags/RcacheCompileJob.swift b/Package/Support/SwiftSettings/UnsafeFlags/RcacheCompileJob.swift new file mode 100644 index 00000000..9f60de27 --- /dev/null +++ b/Package/Support/SwiftSettings/UnsafeFlags/RcacheCompileJob.swift @@ -0,0 +1,2 @@ +/// Represents a compile job for the `Rcache` feature. +public struct RcacheCompileJob: UnsafeFlag {} diff --git a/Package/Support/SwiftSettings/UnsafeFlags/RcrossImport.swift b/Package/Support/SwiftSettings/UnsafeFlags/RcrossImport.swift new file mode 100644 index 00000000..823841ae --- /dev/null +++ b/Package/Support/SwiftSettings/UnsafeFlags/RcrossImport.swift @@ -0,0 +1,2 @@ +/// Represents an unsafeFlag for the "-Rcross-import" option. +public struct RcrossImport: UnsafeFlag {} diff --git a/Package/Support/SwiftSettings/UnsafeFlags/RemoveRuntimeAsserts.swift b/Package/Support/SwiftSettings/UnsafeFlags/RemoveRuntimeAsserts.swift new file mode 100644 index 00000000..2e40c235 --- /dev/null +++ b/Package/Support/SwiftSettings/UnsafeFlags/RemoveRuntimeAsserts.swift @@ -0,0 +1,2 @@ +/// A struct that removes runtime asserts from the compiled code. +public struct RemoveRuntimeAsserts: UnsafeFlag {} diff --git a/Package/Support/SwiftSettings/UnsafeFlags/RequireExplicitAvailability.swift b/Package/Support/SwiftSettings/UnsafeFlags/RequireExplicitAvailability.swift new file mode 100644 index 00000000..f702ed3f --- /dev/null +++ b/Package/Support/SwiftSettings/UnsafeFlags/RequireExplicitAvailability.swift @@ -0,0 +1,3 @@ + +/// A struct that represents the "-require-explicit-availability" Xcode compiler flag. +public struct RequireExplicitAvailability: UnsafeFlag {} diff --git a/Package/Support/SwiftSettings/UnsafeFlags/RequireExplicitSendable.swift b/Package/Support/SwiftSettings/UnsafeFlags/RequireExplicitSendable.swift new file mode 100644 index 00000000..778b3c42 --- /dev/null +++ b/Package/Support/SwiftSettings/UnsafeFlags/RequireExplicitSendable.swift @@ -0,0 +1,2 @@ +/// Represents a flag that requires explicit `Sendable` conformance. +public struct RequireExplicitSendable: UnsafeFlag {} diff --git a/Package/Support/SwiftSettings/UnsafeFlags/ResolveImports.swift b/Package/Support/SwiftSettings/UnsafeFlags/ResolveImports.swift new file mode 100644 index 00000000..d6ad268b --- /dev/null +++ b/Package/Support/SwiftSettings/UnsafeFlags/ResolveImports.swift @@ -0,0 +1,2 @@ +/// Represents a flag that resolves imports in the build process. +public struct ResolveImports: UnsafeFlag {} diff --git a/Package/Support/SwiftSettings/UnsafeFlags/RindexingSystemModule.swift b/Package/Support/SwiftSettings/UnsafeFlags/RindexingSystemModule.swift new file mode 100644 index 00000000..ee72e1f7 --- /dev/null +++ b/Package/Support/SwiftSettings/UnsafeFlags/RindexingSystemModule.swift @@ -0,0 +1,2 @@ +/// Represents an unsafe flag for the Rindexing System Module. +public struct RindexingSystemModule: UnsafeFlag {} diff --git a/Package/Support/SwiftSettings/UnsafeFlags/RmacroLoading.swift b/Package/Support/SwiftSettings/UnsafeFlags/RmacroLoading.swift new file mode 100644 index 00000000..521f8d75 --- /dev/null +++ b/Package/Support/SwiftSettings/UnsafeFlags/RmacroLoading.swift @@ -0,0 +1,2 @@ +/// A struct representing the "-Rmacro-loading" Clang flag. +public struct RmacroLoading: UnsafeFlag {} diff --git a/Package/Support/SwiftSettings/UnsafeFlags/RmoduleLoading.swift b/Package/Support/SwiftSettings/UnsafeFlags/RmoduleLoading.swift new file mode 100644 index 00000000..d7943475 --- /dev/null +++ b/Package/Support/SwiftSettings/UnsafeFlags/RmoduleLoading.swift @@ -0,0 +1,3 @@ + +/// A struct representing the "-Rmodule-loading" Xcode compiler flag. +public struct RmoduleLoading: UnsafeFlag {} diff --git a/Package/Support/SwiftSettings/UnsafeFlags/RmoduleRecovery.swift b/Package/Support/SwiftSettings/UnsafeFlags/RmoduleRecovery.swift new file mode 100644 index 00000000..b1a0138e --- /dev/null +++ b/Package/Support/SwiftSettings/UnsafeFlags/RmoduleRecovery.swift @@ -0,0 +1,2 @@ +/// The `RmoduleRecovery` struct represents an unsafeFlag that enables the `-Rmodule-recovery` compiler flag. +public struct RmoduleRecovery: UnsafeFlag {} diff --git a/Package/Support/SwiftSettings/UnsafeFlags/RskipExplicitInterfaceBuild.swift b/Package/Support/SwiftSettings/UnsafeFlags/RskipExplicitInterfaceBuild.swift new file mode 100644 index 00000000..4c431ee3 --- /dev/null +++ b/Package/Support/SwiftSettings/UnsafeFlags/RskipExplicitInterfaceBuild.swift @@ -0,0 +1,4 @@ +/// Represents the "-Rskip-explicit-interface-build" compiler flag. +/// +/// This flag is used to skip the explicit interface build during the compilation process. +public struct RskipExplicitInterfaceBuild: UnsafeFlag {} diff --git a/Package/Support/SwiftSettings/UnsafeFlags/SaveOptimizationRecord.swift b/Package/Support/SwiftSettings/UnsafeFlags/SaveOptimizationRecord.swift new file mode 100644 index 00000000..6bfebec2 --- /dev/null +++ b/Package/Support/SwiftSettings/UnsafeFlags/SaveOptimizationRecord.swift @@ -0,0 +1,2 @@ +/// Represents a flag that saves an optimization record. +public struct SaveOptimizationRecord: UnsafeFlag {} diff --git a/Package/Support/SwiftSettings/UnsafeFlags/SaveTemps.swift b/Package/Support/SwiftSettings/UnsafeFlags/SaveTemps.swift new file mode 100644 index 00000000..398f3eb6 --- /dev/null +++ b/Package/Support/SwiftSettings/UnsafeFlags/SaveTemps.swift @@ -0,0 +1,2 @@ +/// A flag that enables saving temporary files during the build process. +public struct SaveTemps: UnsafeFlag {} diff --git a/Package/Support/SwiftSettings/UnsafeFlags/ScanDependencies.swift b/Package/Support/SwiftSettings/UnsafeFlags/ScanDependencies.swift new file mode 100644 index 00000000..e3cafcf7 --- /dev/null +++ b/Package/Support/SwiftSettings/UnsafeFlags/ScanDependencies.swift @@ -0,0 +1,2 @@ +/// Represents a flag for scanning dependencies. +public struct ScanDependencies: UnsafeFlag {} diff --git a/Package/Support/SwiftSettings/UnsafeFlags/SerializeDiagnostics.swift b/Package/Support/SwiftSettings/UnsafeFlags/SerializeDiagnostics.swift new file mode 100644 index 00000000..48581072 --- /dev/null +++ b/Package/Support/SwiftSettings/UnsafeFlags/SerializeDiagnostics.swift @@ -0,0 +1,2 @@ +/// A struct that represents the `-serialize-diagnostics` flag for the Swift compiler. +public struct SerializeDiagnostics: UnsafeFlag {} diff --git a/Package/Support/SwiftSettings/UnsafeFlags/Static.swift b/Package/Support/SwiftSettings/UnsafeFlags/Static.swift new file mode 100644 index 00000000..70cb09f8 --- /dev/null +++ b/Package/Support/SwiftSettings/UnsafeFlags/Static.swift @@ -0,0 +1,2 @@ +/// A struct representing the `-static` flag for unsafeFlags. +public struct Static: UnsafeFlag {} diff --git a/Package/Support/SwiftSettings/UnsafeFlags/StaticExecutable.swift b/Package/Support/SwiftSettings/UnsafeFlags/StaticExecutable.swift new file mode 100644 index 00000000..bd686690 --- /dev/null +++ b/Package/Support/SwiftSettings/UnsafeFlags/StaticExecutable.swift @@ -0,0 +1,2 @@ +/// A static executable flag for the Swift compiler. +public struct StaticExecutable: UnsafeFlag {} diff --git a/Package/Support/SwiftSettings/UnsafeFlags/StaticStdlib.swift b/Package/Support/SwiftSettings/UnsafeFlags/StaticStdlib.swift new file mode 100644 index 00000000..f87d9391 --- /dev/null +++ b/Package/Support/SwiftSettings/UnsafeFlags/StaticStdlib.swift @@ -0,0 +1,2 @@ +/// A type that represents the "-static-stdlib" flag for the Swift compiler. +public struct StaticStdlib: UnsafeFlag {} diff --git a/Package/Support/SwiftSettings/UnsafeFlags/SuppressRemarks.swift b/Package/Support/SwiftSettings/UnsafeFlags/SuppressRemarks.swift new file mode 100644 index 00000000..9f52e6a7 --- /dev/null +++ b/Package/Support/SwiftSettings/UnsafeFlags/SuppressRemarks.swift @@ -0,0 +1,2 @@ +/// The `SuppressRemarks` struct represents an unsafe flag that can be used to suppress remarks in a build. +public struct SuppressRemarks: UnsafeFlag {} diff --git a/Package/Support/SwiftSettings/UnsafeFlags/SuppressWarnings.swift b/Package/Support/SwiftSettings/UnsafeFlags/SuppressWarnings.swift new file mode 100644 index 00000000..51b585a2 --- /dev/null +++ b/Package/Support/SwiftSettings/UnsafeFlags/SuppressWarnings.swift @@ -0,0 +1,2 @@ +/// Represents a flag that suppresses warnings in the build process. +public struct SuppressWarnings: UnsafeFlag {} diff --git a/Package/Support/SwiftSettings/UnsafeFlags/TrackSystemDependencies.swift b/Package/Support/SwiftSettings/UnsafeFlags/TrackSystemDependencies.swift new file mode 100644 index 00000000..fe4ea99d --- /dev/null +++ b/Package/Support/SwiftSettings/UnsafeFlags/TrackSystemDependencies.swift @@ -0,0 +1,2 @@ +/// A struct representing the `--track-system-dependencies` flag for the Swift compiler. +public struct TrackSystemDependencies: UnsafeFlag {} diff --git a/Package/Support/SwiftSettings/UnsafeFlags/Typecheck.swift b/Package/Support/SwiftSettings/UnsafeFlags/Typecheck.swift new file mode 100644 index 00000000..4daef934 --- /dev/null +++ b/Package/Support/SwiftSettings/UnsafeFlags/Typecheck.swift @@ -0,0 +1,2 @@ +/// Represents a flag for the typecheck command. +public struct Typecheck: UnsafeFlag {} diff --git a/Package/Support/SwiftSettings/UnsafeFlags/V.swift b/Package/Support/SwiftSettings/UnsafeFlags/V.swift new file mode 100644 index 00000000..8b4f33d4 --- /dev/null +++ b/Package/Support/SwiftSettings/UnsafeFlags/V.swift @@ -0,0 +1,2 @@ +/// Represents an unsafe flag with the value "-v". +public struct V: UnsafeFlag {} diff --git a/Package/Support/SwiftSettings/UnsafeFlags/ValidateClangModulesOnce.swift b/Package/Support/SwiftSettings/UnsafeFlags/ValidateClangModulesOnce.swift new file mode 100644 index 00000000..0b163146 --- /dev/null +++ b/Package/Support/SwiftSettings/UnsafeFlags/ValidateClangModulesOnce.swift @@ -0,0 +1,2 @@ +/// Represents a Swift flag that validates Clang modules once. +public struct ValidateClangModulesOnce: UnsafeFlag {} diff --git a/Package/Support/SwiftSettings/UnsafeFlags/VerifyDebugInfo.swift b/Package/Support/SwiftSettings/UnsafeFlags/VerifyDebugInfo.swift new file mode 100644 index 00000000..ec4eb274 --- /dev/null +++ b/Package/Support/SwiftSettings/UnsafeFlags/VerifyDebugInfo.swift @@ -0,0 +1,3 @@ + +/// A struct that represents the `-verify-debug-info` unsafed flag. +public struct VerifyDebugInfo: UnsafeFlag {} diff --git a/Package/Support/SwiftSettings/UnsafeFlags/VerifyEmittedModuleInterface.swift b/Package/Support/SwiftSettings/UnsafeFlags/VerifyEmittedModuleInterface.swift new file mode 100644 index 00000000..a4a6d600 --- /dev/null +++ b/Package/Support/SwiftSettings/UnsafeFlags/VerifyEmittedModuleInterface.swift @@ -0,0 +1,2 @@ +/// A flag that enables verification of the emitted module interface. +public struct VerifyEmittedModuleInterface: UnsafeFlag {} diff --git a/Package/Support/SwiftSettings/UnsafeFlags/Version.swift b/Package/Support/SwiftSettings/UnsafeFlags/Version.swift new file mode 100644 index 00000000..241daf92 --- /dev/null +++ b/Package/Support/SwiftSettings/UnsafeFlags/Version.swift @@ -0,0 +1,2 @@ +/// `Version` is a struct that represents an unsafe flag with the value `-version`. +public struct Version: UnsafeFlag {} diff --git a/Package/Support/SwiftSettings/UnsafeFlags/WarnConcurrency.swift b/Package/Support/SwiftSettings/UnsafeFlags/WarnConcurrency.swift new file mode 100644 index 00000000..883d3886 --- /dev/null +++ b/Package/Support/SwiftSettings/UnsafeFlags/WarnConcurrency.swift @@ -0,0 +1,3 @@ + +/// A struct that represents the "-warn-concurrency" flag for the Swift compiler. +public struct WarnConcurrency: UnsafeFlag {} diff --git a/Package/Support/SwiftSettings/UnsafeFlags/WarnImplicitOverrides.swift b/Package/Support/SwiftSettings/UnsafeFlags/WarnImplicitOverrides.swift new file mode 100644 index 00000000..4a922a26 --- /dev/null +++ b/Package/Support/SwiftSettings/UnsafeFlags/WarnImplicitOverrides.swift @@ -0,0 +1,8 @@ +// +// WarnImplicitOverrides.swift +// Copyright (c) 2024 BrightDigit. +// Licensed under MIT License +// + +/// A flag that enables warnings for implicit overrides. +public struct WarnImplicitOverrides: UnsafeFlag {} diff --git a/Package/Support/SwiftSettings/UnsafeFlags/WarnLongExpressionTypeChecking.swift b/Package/Support/SwiftSettings/UnsafeFlags/WarnLongExpressionTypeChecking.swift new file mode 100644 index 00000000..d439e9c7 --- /dev/null +++ b/Package/Support/SwiftSettings/UnsafeFlags/WarnLongExpressionTypeChecking.swift @@ -0,0 +1,20 @@ + +/// A struct that represents a warning for long expression type checking. +public struct WarnLongExpressionTypeChecking : UnsafeFlag { + /// Initializes a new instance of `WarnLongExpressionTypeChecking`. + /// - Parameter milliseconds: The number of milliseconds to use for the warning threshold. + public init(milliseconds: Int) { + self.milliseconds = milliseconds + } + + /// The number of milliseconds to use for the warning threshold. + public let milliseconds : Int + + /// The unsafe flag arguments to be used for the warning. + public var unsafeFlagArguments: [String] { + [ + "-Xfrontend", + "-warn-long-expression-type-checking=\(milliseconds)" + ] + } +} diff --git a/Package/Support/SwiftSettings/UnsafeFlags/WarnLongFunctionBodies.swift b/Package/Support/SwiftSettings/UnsafeFlags/WarnLongFunctionBodies.swift new file mode 100644 index 00000000..08f1193f --- /dev/null +++ b/Package/Support/SwiftSettings/UnsafeFlags/WarnLongFunctionBodies.swift @@ -0,0 +1,20 @@ + +/// A struct that represents a warning flag for long function bodies. +public struct WarnLongFunctionBodies: UnsafeFlag { + /// Initializes a new instance of `WarnLongFunctionBodies`. + /// - Parameter milliseconds: The threshold in milliseconds for the compiler to warn about long function bodies. + public init(milliseconds: Int) { + self.milliseconds = milliseconds + } + + /// The threshold in milliseconds for the compiler to warn about long function bodies. + public let milliseconds: Int + + /// The command-line arguments to be passed to the compiler to enable the warning. + public var unsafeFlagArguments: [String] { + [ + "-Xfrontend", + "-warn-long-function-bodies=\(milliseconds)" + ] + } +} diff --git a/Package/Support/SwiftSettings/UnsafeFlags/WarnSwift3ObjcInferenceComplete.swift b/Package/Support/SwiftSettings/UnsafeFlags/WarnSwift3ObjcInferenceComplete.swift new file mode 100644 index 00000000..4d2c006a --- /dev/null +++ b/Package/Support/SwiftSettings/UnsafeFlags/WarnSwift3ObjcInferenceComplete.swift @@ -0,0 +1,2 @@ +/// A struct that represents the "-warn-swift3-objc-inference-complete" compiler flag. +public struct WarnSwift3ObjcInferenceComplete: UnsafeFlag {} diff --git a/Package/Support/SwiftSettings/UnsafeFlags/WarnSwift3ObjcInferenceMinimal.swift b/Package/Support/SwiftSettings/UnsafeFlags/WarnSwift3ObjcInferenceMinimal.swift new file mode 100644 index 00000000..d1d1401c --- /dev/null +++ b/Package/Support/SwiftSettings/UnsafeFlags/WarnSwift3ObjcInferenceMinimal.swift @@ -0,0 +1,2 @@ +/// Represents a warning flag for minimal Swift 3 Objective-C inference. +public struct WarnSwift3ObjcInferenceMinimal: UnsafeFlag {} diff --git a/Package/Support/SwiftSettings/UnsafeFlags/WarningsAsErrors.swift b/Package/Support/SwiftSettings/UnsafeFlags/WarningsAsErrors.swift new file mode 100644 index 00000000..c2a1787c --- /dev/null +++ b/Package/Support/SwiftSettings/UnsafeFlags/WarningsAsErrors.swift @@ -0,0 +1,2 @@ +/// A struct that represents the "-warnings-as-errors" flag. +public struct WarningsAsErrors: UnsafeFlag {} diff --git a/Package/Support/SwiftSettings/UnsafeFlags/WholeModuleOptimization.swift b/Package/Support/SwiftSettings/UnsafeFlags/WholeModuleOptimization.swift new file mode 100644 index 00000000..3d55afed --- /dev/null +++ b/Package/Support/SwiftSettings/UnsafeFlags/WholeModuleOptimization.swift @@ -0,0 +1,8 @@ +// +// WholeModuleOptimization.swift +// Copyright (c) 2024 BrightDigit. +// Licensed under MIT License +// + +/// A type-erased wrapper around the "-whole-module-optimization" compiler flag. +public struct WholeModuleOptimization: UnsafeFlag {} diff --git a/Package/Support/SwiftSettingsBuilder.swift b/Package/Support/SwiftSettingsBuilder.swift new file mode 100644 index 00000000..8e1fe6e9 --- /dev/null +++ b/Package/Support/SwiftSettingsBuilder.swift @@ -0,0 +1,65 @@ +// +// SwiftSettingsBuilder.swift +// Copyright (c) 2024 BrightDigit. +// Licensed under MIT License +// + +import PackageDescription + +/// A result builder for creating collections of `SwiftSetting` instances. +@resultBuilder +public enum SwiftSettingsBuilder { + /// Builds a partial block with a single `SwiftSetting` instance. + /// + /// - Parameter first: The `SwiftSetting` instance to include in the partial block. + /// - Returns: An array containing the provided `SwiftSetting` instance. + public static func buildPartialBlock(first: SwiftSetting) -> [SwiftSetting] { + [first] + } + + /// Builds a partial block by accumulating the provided `SwiftSetting` instances. + /// + /// - Parameters: + /// - accumulated: The accumulated `SwiftSetting` instances. + /// - next: The next `SwiftSetting` instance to add to the block. + /// - Returns: An array containing the accumulated `SwiftSetting` instances and the next instance. + public static func buildPartialBlock(accumulated: [SwiftSetting], next: SwiftSetting) -> [SwiftSetting] { + accumulated + [next] + } + + /// Builds a partial block by accumulating the provided `SwiftSetting` instances. + /// + /// - Parameters: + /// - accumulated: The accumulated `SwiftSetting` instances. + /// - next: The next array of `SwiftSetting` instances to add to the block. + /// - Returns: An array containing the accumulated `SwiftSetting` instances and the next instances. + public static func buildPartialBlock(accumulated: [SwiftSetting], next: [SwiftSetting]) -> [SwiftSetting] { + accumulated + next + } + + /// Builds a partial block with the provided array of `SwiftSetting` instances. + /// + /// - Parameter first: The array of `SwiftSetting` instances to include in the partial block. + /// - Returns: The provided array of `SwiftSetting` instances. + public static func buildPartialBlock(first: [SwiftSetting]) -> [SwiftSetting] { + first + } + + /// Builds a partial block with the `SwiftSetting` instances from the provided `SwiftSettingsConvertible` instance. + /// + /// - Parameter first: The `SwiftSettingsConvertible` instance to extract `SwiftSetting` instances from. + /// - Returns: An array of `SwiftSetting` instances extracted from the provided `SwiftSettingsConvertible` instance. + public static func buildPartialBlock(first: any SwiftSettingsConvertible) -> [SwiftSetting] { + first.swiftSettings() + } + + /// Builds a partial block by accumulating the `SwiftSetting` instances from the provided `SwiftSettingsConvertible` instance. + /// + /// - Parameters: + /// - accumulated: The accumulated `SwiftSetting` instances. + /// - next: The `SwiftSettingsConvertible` instance to extract `SwiftSetting` instances from. + /// - Returns: An array containing the accumulated `SwiftSetting` instances and the `SwiftSetting` instances extracted from the provided `SwiftSettingsConvertible` instance. + public static func buildPartialBlock(accumulated: [SwiftSetting], next: any SwiftSettingsConvertible) -> [SwiftSetting] { + accumulated + next.swiftSettings() + } +} diff --git a/Package/Support/SwiftSettingsConvertible.swift b/Package/Support/SwiftSettingsConvertible.swift new file mode 100644 index 00000000..2a54deb8 --- /dev/null +++ b/Package/Support/SwiftSettingsConvertible.swift @@ -0,0 +1,26 @@ + +// +// SwiftSettingsConvertible.swift +// Copyright (c) 2024 BrightDigit. +// Licensed under MIT License +// + +import PackageDescription + +/// A protocol that defines a type that can be converted to a collection of `SwiftSetting` values. +public protocol SwiftSettingsConvertible: GroupBuildable where Output == SwiftSetting { + /// Returns an array of `SwiftSetting` values. + func swiftSettings() -> [SwiftSetting] +} + +extension SwiftSettingsConvertible { + /// Returns an array of `SwiftSetting` values by flattening the `swiftSettings()` arrays of the provided `SwiftSettingsConvertible` instances. + /// + /// - Parameter array: An array of `SwiftSettingsConvertible` instances. + /// - Returns: An array of `SwiftSetting` values. + public static func output(from array: [Self]) -> [SwiftSetting] { + array.flatMap { + $0.swiftSettings() + } + } +} diff --git a/Package/Support/Target.swift b/Package/Support/Target.swift new file mode 100644 index 00000000..b7469446 --- /dev/null +++ b/Package/Support/Target.swift @@ -0,0 +1,58 @@ + +// +// Target.swift +// Copyright (c) 2024 BrightDigit. +// Licensed under MIT License +// + +import PackageDescription + +/// A protocol that defines a target. +public protocol Target: _Depending, Dependency, _Named { + + /// The type of the target. + var targetType: TargetType { get } + + /// The Swift settings for the target. + /// + /// - Returns: An array of `SwiftSetting` objects. + @SwiftSettingsBuilder + var swiftSettings: [SwiftSetting] { get } + + /// The resources for the target. + /// + /// - Returns: An array of `Resource` objects. + @ResourcesBuilder + var resources: [Resource] { get } + + /// The path of the target. + var path: String? { get } +} + +extension Target { + + /// The target type, which is `.regular` by default. + public var targetType: TargetType { + .regular + } + + /// The target dependency, which is a `.target` with the target's name. + public var targetDependency: _PackageDescription_TargetDependency { + .target(name: name) + } + + /// The Swift settings for the target, which is an empty array by default. + public var swiftSettings: [SwiftSetting] { + [] + } + + /// The resources for the target, which is an empty array by default. + public var resources: [Resource] { + [] + } + + /// The path of the target, which is `nil` by default. + public var path: String? { + nil + } +} diff --git a/Package/Support/TargetDependency.swift b/Package/Support/TargetDependency.swift new file mode 100644 index 00000000..1e396330 --- /dev/null +++ b/Package/Support/TargetDependency.swift @@ -0,0 +1,25 @@ +// +// TargetDependency.swift +// Copyright (c) 2024 BrightDigit. +// Licensed under MIT License +// + +import PackageDescription + +protocol TargetDependency: Dependency, _Named { + var productName: String { get } + var package: PackageDependency { get } + var condition: TargetDependencyCondition? { get } +} + +extension TargetDependency { + var productName: String { + name + } + + var targetDependency: _PackageDescription_TargetDependency { + .product(name: name, package: package.packageName, condition: condition) + } + + var condition: TargetDependencyCondition? { return nil } +} diff --git a/Package/Support/TargetType.swift b/Package/Support/TargetType.swift new file mode 100644 index 00000000..4bacf34c --- /dev/null +++ b/Package/Support/TargetType.swift @@ -0,0 +1,9 @@ +/// Represents the type of a target in the project. +public enum TargetType { + /// Represents a regular (non-executable) target. + case regular + /// Represents an executable target. + case executable + /// Represents a test target. + case test +} diff --git a/Package/Support/TestTarget.swift b/Package/Support/TestTarget.swift new file mode 100644 index 00000000..52bd6b4d --- /dev/null +++ b/Package/Support/TestTarget.swift @@ -0,0 +1,9 @@ +/// A protocol that represents a test target. +public protocol TestTarget: Target, GroupBuildable {} + +extension TestTarget { + /// The target type for this target. + public var targetType: TargetType { + .test + } +} diff --git a/Package/Support/TestTargetBuilder.swift b/Package/Support/TestTargetBuilder.swift new file mode 100644 index 00000000..40f59bce --- /dev/null +++ b/Package/Support/TestTargetBuilder.swift @@ -0,0 +1,28 @@ +// +// TestTargetBuilder.swift +// Copyright (c) 2024 BrightDigit. +// Licensed under MIT License +// + +@resultBuilder +public enum TestTargetBuilder { + public static func buildPartialBlock(first: [any TestTarget]) -> any TestTargets { + first + } + + public static func buildPartialBlock(first: any TestTarget) -> any TestTargets { + [first] + } + + public static func buildPartialBlock(accumulated: any TestTargets, next: any TestTarget) + -> any TestTargets + { + accumulated + [next] + } + + public static func buildPartialBlock(accumulated: any TestTargets, next: any TestTargets) + -> any TestTargets + { + accumulated.appending(next) + } +} diff --git a/Package/Support/TestTargets.swift b/Package/Support/TestTargets.swift new file mode 100644 index 00000000..c07e255d --- /dev/null +++ b/Package/Support/TestTargets.swift @@ -0,0 +1,11 @@ +/// A protocol that represents a sequence of `TestTarget` elements. +public protocol TestTargets: Sequence where Element == any TestTarget { + /// Initializes a `TestTargets` instance from a sequence of `TestTarget` elements. + /// - Parameter s: A sequence of `TestTarget` elements. + init(_ s: S) where S.Element == any TestTarget, S: Sequence + + /// Appends a sequence of `TestTarget` elements to the current `TestTargets` instance. + /// - Parameter testTargets: A sequence of `TestTarget` elements to append. + /// - Returns: A new `TestTargets` instance with the additional `TestTarget` elements. + func appending(_ testTargets: any TestTargets) -> Self +} diff --git a/Package/Support/UnsafeFlag.swift b/Package/Support/UnsafeFlag.swift new file mode 100644 index 00000000..a348c45e --- /dev/null +++ b/Package/Support/UnsafeFlag.swift @@ -0,0 +1,24 @@ +// +// UnsafeFlag.swift +// Copyright (c) 2024 BrightDigit. +// Licensed under MIT License +// + +import PackageDescription +/// A protocol that represents an unsafe flag for a Swift setting. +public protocol UnsafeFlag: SwiftSettingConvertible, _Named { + /// The arguments for the unsafe flag. + var unsafeFlagArguments: [String] { get } +} + +extension UnsafeFlag { + /// The arguments for the unsafe flag. + public var unsafeFlagArguments: [String] { + [name.camelToSnakeCaseFlag()] + } + + /// The Swift setting for the unsafe flag. + public var setting: SwiftSetting { + .unsafeFlags(unsafeFlagArguments) + } +} diff --git a/Package/Support/_Depending.swift b/Package/Support/_Depending.swift new file mode 100644 index 00000000..1f51cd14 --- /dev/null +++ b/Package/Support/_Depending.swift @@ -0,0 +1,30 @@ + +// swift-format-ignore: NoLeadingUnderscores +/// A protocol that represents an entity that has dependencies. +public protocol _Depending { + /// The dependencies of the entity. + @DependencyBuilder + var dependencies: any Dependencies { get } +} + +extension _Depending { + /// The default implementation of the `dependencies` property. + public var dependencies: any Dependencies { + [Dependency]() + } +} + +extension _Depending { + /// Retrieves all the dependencies of the entity, including nested dependencies. + /// + /// - Returns: An array of all the dependencies of the entity. + public func allDependencies() -> [Dependency] { + dependencies.compactMap { + $0 as? _Depending + } + .flatMap { + $0.allDependencies() + } + .appending(dependencies) + } +} diff --git a/Package/Support/_Named.swift b/Package/Support/_Named.swift new file mode 100644 index 00000000..305d922c --- /dev/null +++ b/Package/Support/_Named.swift @@ -0,0 +1,16 @@ +// +// _Named.swift +// Copyright (c) 2024 BrightDigit. +// Licensed under MIT License +// + +// swift-format-ignore: NoLeadingUnderscores +public protocol _Named { + var name: String { get } +} + +extension _Named { + public var name: String { + "\(Self.self)" + } +} diff --git a/Package/Support/_PackageDescription_Product.swift b/Package/Support/_PackageDescription_Product.swift new file mode 100644 index 00000000..d61a233b --- /dev/null +++ b/Package/Support/_PackageDescription_Product.swift @@ -0,0 +1,17 @@ + +/// Extends the `_PackageDescription_Product` type. +extension _PackageDescription_Product { + /// Creates a new `_PackageDescription_Product` instance based on the provided `Product`. + /// - Parameter entry: The `Product` instance to be used for creating the new `_PackageDescription_Product`. + /// - Returns: A new `_PackageDescription_Product` instance. + static func entry(_ entry: any Product) -> _PackageDescription_Product { + let targets = entry.productTargets.map(\.name) + + switch entry.productType { + case .executable: + return Self.executable(name: entry.name, targets: targets) + case .library: + return Self.library(name: entry.name, type: entry.libraryType, targets: targets) + } + } +} diff --git a/Package/Support/_PackageDescription_Target.swift b/Package/Support/_PackageDescription_Target.swift new file mode 100644 index 00000000..a125b173 --- /dev/null +++ b/Package/Support/_PackageDescription_Target.swift @@ -0,0 +1,46 @@ + +// +// _PackageDescription_Target.swift +// Copyright (c) 2024 BrightDigit. +// Licensed under MIT License +// + +import PackageDescription + +extension _PackageDescription_Target { + /// Creates a new target based on the provided `entry` and optional `swiftSettings`. + /// + /// - Parameters: + /// - entry: The `Target` to be used as the basis for the new target. + /// - swiftSettings: An optional array of `SwiftSetting` values to be applied to the new target. + /// - Returns: A new `_PackageDescription_Target` instance based on the provided `entry` and `swiftSettings`. + static func entry(_ entry: Target, swiftSettings: [SwiftSetting] = []) -> _PackageDescription_Target { + let dependencies = entry.dependencies.map(\.targetDependency) + switch entry.targetType { + case .executable: + return .executableTarget( + name: entry.name, + dependencies: dependencies, + path: entry.path, + resources: entry.resources, + swiftSettings: swiftSettings + entry.swiftSettings + ) + case .regular: + return .target( + name: entry.name, + dependencies: dependencies, + path: entry.path, + resources: entry.resources, + swiftSettings: swiftSettings + entry.swiftSettings + ) + case .test: + return .testTarget( + name: entry.name, + dependencies: dependencies, + path: entry.path, + resources: entry.resources, + swiftSettings: swiftSettings + entry.swiftSettings + ) + } + } +} diff --git a/Scripts/package.sh b/Scripts/package.sh index 5c55168e..bebc9c57 100755 --- a/Scripts/package.sh +++ b/Scripts/package.sh @@ -9,7 +9,7 @@ output_file=Package.swift cd $PACKAGE_DIR echo "// swift-tools-version: $swift_tools_version" > $input_file -find ../PackageDSL/Sources/PackageDSL -name '*.swift' -type f -exec cat {} + >> $input_file +find Package/Support -name '*.swift' -type f -exec cat {} + >> $input_file find Package/Sources -mindepth 2 -type f -name '*.swift' -not -path '*/\.*' -exec cat {} + >> $input_file cat Package/Sources/*.swift >> $input_file diff --git a/Sources/BushelFoundation/HardwareModel.swift b/Sources/BushelFoundation/HardwareModel.swift index acc4225a..7e20229f 100644 --- a/Sources/BushelFoundation/HardwareModel.swift +++ b/Sources/BushelFoundation/HardwareModel.swift @@ -28,6 +28,7 @@ // public import Foundation +public import OSVer /// A struct representing a hardware model. public struct HardwareModel: Codable, Equatable, Sendable { @@ -42,7 +43,7 @@ public struct HardwareModel: Codable, Equatable, Sendable { public let dataRepresentationVersion: Int /// The minimum supported operating system version for the hardware model. - public let minimumSupportedOS: OperatingSystemVersion + public let minimumSupportedOS: OSVer /// The platform version of the hardware model. public let platformVersion: Int diff --git a/Sources/BushelFoundation/ImageMetadata.swift b/Sources/BushelFoundation/ImageMetadata.swift index e44f6332..ce6ec605 100644 --- a/Sources/BushelFoundation/ImageMetadata.swift +++ b/Sources/BushelFoundation/ImageMetadata.swift @@ -28,7 +28,7 @@ // public import Foundation -import OperatingSystemVersion +public import OSVer /// Represents metadata associated with an image file. public struct ImageMetadata: Codable, @@ -42,7 +42,7 @@ public struct ImageMetadata: Codable, /// The build version associated with the image, if available. public let buildVersion: String? /// The operating system version the image is intended for. - public let operatingSystemVersion: OperatingSystemVersion + public let operatingSystemVersion: OSVer /// The size of the image file in bytes. public let contentLength: Int /// The last modification date of the image file. @@ -57,7 +57,7 @@ public struct ImageMetadata: Codable, /// A custom debug description string providing details about the image metadata. public var debugDescription: String { // swiftlint:disable:next line_length - "\(Self.self)(isImageSupported: \(self.isImageSupported), buildVersion: \"\(self.buildVersion ?? "")\", operatingSystemVersion: \(self.operatingSystemVersion.debugDescription), contentLength: \(self.contentLength), lastModified: Date(timeIntervalSinceReferenceDate: \(self.lastModified.timeIntervalSinceReferenceDate))" + "\(Self.self)(isImageSupported: \(self.isImageSupported), buildVersion: \"\(self.buildVersion ?? "")\", operatingSystemVersion: \(self.operatingSystemVersion.description), contentLength: \(self.contentLength), lastModified: Date(timeIntervalSinceReferenceDate: \(self.lastModified.timeIntervalSinceReferenceDate))" } /// Creates a new `ImageMetadata` instance. @@ -74,7 +74,7 @@ public struct ImageMetadata: Codable, public init( isImageSupported: Bool, buildVersion: String?, - operatingSystemVersion: OperatingSystemVersion, + operatingSystemVersion: OSVer, contentLength: Int, lastModified: Date, fileExtension: String, diff --git a/Sources/BushelFoundation/OperatingSystemInstalled.swift b/Sources/BushelFoundation/OperatingSystemInstalled.swift index 0411b03d..be86adba 100644 --- a/Sources/BushelFoundation/OperatingSystemInstalled.swift +++ b/Sources/BushelFoundation/OperatingSystemInstalled.swift @@ -28,6 +28,7 @@ // public import Foundation +public import OSVer /// A protocol that represents an operating system that is installed on a device. public protocol OperatingSystemInstalled { @@ -35,7 +36,7 @@ public protocol OperatingSystemInstalled { var buildVersion: String? { get } /// The version of the operating system. - var operatingSystemVersion: OperatingSystemVersion { get } + var operatingSystemVersion: OSVer { get } } extension OperatingSystemInstalled { diff --git a/Sources/BushelFoundation/OperatingSystemVersionComponents.swift b/Sources/BushelFoundation/OperatingSystemVersionComponents.swift index 0c133edb..59886744 100644 --- a/Sources/BushelFoundation/OperatingSystemVersionComponents.swift +++ b/Sources/BushelFoundation/OperatingSystemVersionComponents.swift @@ -28,6 +28,7 @@ // public import Foundation +public import OSVer /// Represents the version components of an operating system. public struct OperatingSystemVersionComponents: Sendable { @@ -35,5 +36,5 @@ public struct OperatingSystemVersionComponents: Sendable { public let buildVersion: String? /// The version of the operating system. - public let operatingSystemVersion: OperatingSystemVersion + public let operatingSystemVersion: OSVer } diff --git a/Sources/BushelFoundation/SigVerification/ImageSignature.swift b/Sources/BushelFoundation/SigVerification/ImageSignature.swift index 57cfbca5..7b3c559f 100644 --- a/Sources/BushelFoundation/SigVerification/ImageSignature.swift +++ b/Sources/BushelFoundation/SigVerification/ImageSignature.swift @@ -28,6 +28,7 @@ // public import Foundation +public import OSVer /// Represents an image signature, /// containing information about the source, system, and verification details. @@ -42,7 +43,7 @@ public struct ImageSignature: Sendable { public let vmSystemID: VMSystemID /// The version of the operating system. - public let operatingSystemVersion: OperatingSystemVersion + public let operatingSystemVersion: OSVer /// The build version of the operating system, if available. public let buildVersion: String? @@ -76,7 +77,7 @@ public struct ImageSignature: Sendable { sourceID: String, signatureID: String, vmSystemID: VMSystemID, - operatingSystemVersion: OperatingSystemVersion, + operatingSystemVersion: OSVer, buildVersion: String?, verification: SigVerification, priority: SignaturePriority, diff --git a/Sources/BushelFoundation/SigVerification/SignatureSource.swift b/Sources/BushelFoundation/SigVerification/SignatureSource.swift index dd32d6c3..eda3f4cc 100644 --- a/Sources/BushelFoundation/SigVerification/SignatureSource.swift +++ b/Sources/BushelFoundation/SigVerification/SignatureSource.swift @@ -29,6 +29,7 @@ import BushelUtilities public import Foundation +public import OSVer /// Represents the source of a signature, either an operating system version or a signature ID. public enum SignatureSource: Sendable, CustomDebugStringConvertible { @@ -36,7 +37,7 @@ public enum SignatureSource: Sendable, CustomDebugStringConvertible { case signatureID(String) /// Represents an operating system version, optionally with a build version. - case operatingSystemVersion(OperatingSystemVersion, String?) + case operatingSystemVersion(OSVer, String?) } extension SignatureSource { diff --git a/Sources/BushelFoundationWax/Fake/OperatingSystemVersion.swift b/Sources/BushelFoundationWax/Fake/OSVer.swift similarity index 91% rename from Sources/BushelFoundationWax/Fake/OperatingSystemVersion.swift rename to Sources/BushelFoundationWax/Fake/OSVer.swift index 48ced98d..7a1a9bd5 100644 --- a/Sources/BushelFoundationWax/Fake/OperatingSystemVersion.swift +++ b/Sources/BushelFoundationWax/Fake/OSVer.swift @@ -1,5 +1,5 @@ // -// OperatingSystemVersion.swift +// OSVer.swift // BushelKit // // Created by Leo Dion. @@ -28,9 +28,10 @@ // package import Foundation +package import OSVer -extension OperatingSystemVersion { - package static func random() -> OperatingSystemVersion { +extension OSVer { + package static func random() -> OSVer { .init( majorVersion: .random(in: 12...15), minorVersion: .random(in: 0...6), diff --git a/Sources/BushelHubIPSW/Firmware.swift b/Sources/BushelHubIPSW/Firmware.swift index 4e9bcf52..eeab0193 100644 --- a/Sources/BushelHubIPSW/Firmware.swift +++ b/Sources/BushelHubIPSW/Firmware.swift @@ -30,6 +30,7 @@ public import BushelFoundation public import Foundation public import IPSWDownloads +public import OSVer extension Firmware: OperatingSystemInstalled { private struct InvalidURLError: Error { @@ -40,7 +41,7 @@ extension Firmware: OperatingSystemInstalled { self.buildid } - public var operatingSystemVersion: OperatingSystemVersion { + public var operatingSystemVersion: OSVer { self.version } } diff --git a/Sources/BushelLibrary/ImageMetadata+Previews.swift b/Sources/BushelLibrary/ImageMetadata+Previews.swift index c3cff01b..ccf17e94 100644 --- a/Sources/BushelLibrary/ImageMetadata+Previews.swift +++ b/Sources/BushelLibrary/ImageMetadata+Previews.swift @@ -30,6 +30,7 @@ public import BushelFoundation import BushelMacOSCore import Foundation +import OSVer extension ImageMetadata { /// A namespace for preview models of `ImageMetadata`. @@ -52,7 +53,7 @@ extension ImageMetadata { public static let venturaBeta3 = ImageMetadata( isImageSupported: true, buildVersion: "22A5295h", - operatingSystemVersion: OperatingSystemVersion( + operatingSystemVersion: OSVer( majorVersion: 13, minorVersion: 0, patchVersion: 0 ), contentLength: 679_094_144, @@ -66,7 +67,7 @@ extension ImageMetadata { public static let monterey = ImageMetadata( isImageSupported: true, buildVersion: "21F79", - operatingSystemVersion: OperatingSystemVersion( + operatingSystemVersion: OSVer( majorVersion: 12, minorVersion: 4, patchVersion: 0 diff --git a/Sources/BushelLibraryWax/Stub/MacOSLibrarySystemStub.swift b/Sources/BushelLibraryWax/Stub/MacOSLibrarySystemStub.swift index 5bf002fd..cd1dee50 100644 --- a/Sources/BushelLibraryWax/Stub/MacOSLibrarySystemStub.swift +++ b/Sources/BushelLibraryWax/Stub/MacOSLibrarySystemStub.swift @@ -30,6 +30,7 @@ public import BushelFoundation public import BushelLibrary public import Foundation +import OSVer public import RadiantDocs public struct MacOSLibrarySystemStub: LibrarySystem { @@ -82,7 +83,7 @@ public struct MacOSLibrarySystemStub: LibrarySystem { "macOS \(codeNameFor(operatingSystemVersion: metadata.operatingSystemVersion)) \(metadata.operatingSystemVersion)" } - private func codeNameFor(operatingSystemVersion: OperatingSystemVersion) -> String { + private func codeNameFor(operatingSystemVersion: OSVer) -> String { Self.codeNames[operatingSystemVersion.majorVersion] ?? operatingSystemVersion.majorVersion.description } diff --git a/Sources/BushelLibraryWax/Stub/UbuntuLibrarySystemStub.swift b/Sources/BushelLibraryWax/Stub/UbuntuLibrarySystemStub.swift index e1f4f91a..b6fe7c89 100644 --- a/Sources/BushelLibraryWax/Stub/UbuntuLibrarySystemStub.swift +++ b/Sources/BushelLibraryWax/Stub/UbuntuLibrarySystemStub.swift @@ -30,6 +30,7 @@ public import BushelFoundation public import BushelLibrary public import Foundation +import OSVer public import RadiantDocs public struct UbuntuLibrarySystemStub: LibrarySystem { @@ -75,7 +76,7 @@ public struct UbuntuLibrarySystemStub: LibrarySystem { "\(self.shortName) \(codeNameFor(operatingSystemVersion: metadata.operatingSystemVersion)) \(metadata.operatingSystemVersion)" } - private func codeNameFor(operatingSystemVersion _: OperatingSystemVersion) -> String { + private func codeNameFor(operatingSystemVersion _: OSVer) -> String { "Kinetic Kudu" } diff --git a/Sources/BushelMacOSCore/ImageMetadata.swift b/Sources/BushelMacOSCore/ImageMetadata.swift index 8508dcae..2fb5865a 100644 --- a/Sources/BushelMacOSCore/ImageMetadata.swift +++ b/Sources/BushelMacOSCore/ImageMetadata.swift @@ -71,7 +71,7 @@ self.init( isImageSupported: vzRestoreImage.isSupported, buildVersion: vzRestoreImage.buildVersion, - operatingSystemVersion: vzRestoreImage.operatingSystemVersion, + operatingSystemVersion: .init(vzRestoreImage.operatingSystemVersion), contentLength: contentLength, lastModified: lastModified, fileExtension: MacOSVirtualization.ipswFileExtension, diff --git a/Sources/BushelMacOSCore/MacOSRelease.swift b/Sources/BushelMacOSCore/MacOSRelease.swift index 1ca0ea30..7823786b 100644 --- a/Sources/BushelMacOSCore/MacOSRelease.swift +++ b/Sources/BushelMacOSCore/MacOSRelease.swift @@ -29,6 +29,7 @@ public import BushelFoundation import Foundation +import OSVer public struct MacOSRelease: InstallerRelease { public let majorVersion: Int @@ -40,7 +41,7 @@ public struct MacOSRelease: InstallerRelease { } public init?(majorVersion: Int) { - guard let releaseName = OperatingSystemVersion.macOSReleaseName(majorVersion: majorVersion) + guard let releaseName = OSVer.macOSReleaseName(majorVersion: majorVersion) else { assertionFailure("Missing Metadata for macOS \(majorVersion).") return nil diff --git a/Sources/BushelMacOSCore/MacOSVirtualization.swift b/Sources/BushelMacOSCore/MacOSVirtualization.swift index 83357464..088f6fae 100644 --- a/Sources/BushelMacOSCore/MacOSVirtualization.swift +++ b/Sources/BushelMacOSCore/MacOSVirtualization.swift @@ -30,6 +30,7 @@ import BushelDocs public import BushelFoundation import Foundation +import OSVer public import RadiantDocs public enum MacOSVirtualization: Sendable { @@ -72,7 +73,7 @@ public enum MacOSVirtualization: Sendable { } public static func codeNameFor(majorVersion: Int) -> String? { - OperatingSystemVersion.macOSReleaseName(majorVersion: majorVersion) + OSVer.macOSReleaseName(majorVersion: majorVersion) } public static func codeNameWithDefaultFor(majorVersion: Int) -> String { @@ -80,7 +81,7 @@ public enum MacOSVirtualization: Sendable { } public static func codeNameFor(majorVersion: Int, withDefault defaultName: String) -> String { - OperatingSystemVersion.macOSReleaseName(majorVersion: majorVersion) ?? defaultName + OSVer.macOSReleaseName(majorVersion: majorVersion) ?? defaultName } public static func operatingSystemShortName(for metadata: any OperatingSystemInstalled) -> String diff --git a/Sources/BushelMacOSCore/VZMacOSRestoreImage.swift b/Sources/BushelMacOSCore/VZMacOSRestoreImage.swift index 64972f17..021d12ce 100644 --- a/Sources/BushelMacOSCore/VZMacOSRestoreImage.swift +++ b/Sources/BushelMacOSCore/VZMacOSRestoreImage.swift @@ -30,6 +30,7 @@ #if canImport(Virtualization) && arch(arm64) public import BushelFoundation import BushelUtilities + import OSVer public import Virtualization @@ -37,14 +38,14 @@ #warning("Remove @unchecked Sendable") extension VZMacOSRestoreImage: @unchecked @retroactive Sendable { internal struct OperatingSystem: OperatingSystemInstalled { - internal let operatingSystemVersion: OperatingSystemVersion + internal let operatingSystemVersion: OSVer internal let buildVersion: String? - internal init(operatingSystemVersion: OperatingSystemVersion, buildVersion: String?) { + internal init(operatingSystemVersion: OSVer, buildVersion: String?) { self.operatingSystemVersion = operatingSystemVersion self.buildVersion = buildVersion } - internal init?(operatingSystemVersion: OperatingSystemVersion?, buildVersion: String?) { + internal init?(operatingSystemVersion: OSVer?, buildVersion: String?) { guard let operatingSystemVersion else { return nil } @@ -54,7 +55,7 @@ public var operatingSystem: any OperatingSystemInstalled { OperatingSystem( - operatingSystemVersion: self.operatingSystemVersion, + operatingSystemVersion: .init(self.operatingSystemVersion), buildVersion: self.buildVersion ) } diff --git a/Sources/BushelMachine/Building/InstallerImage.swift b/Sources/BushelMachine/Building/InstallerImage.swift index 1787eac8..44aa1e81 100644 --- a/Sources/BushelMachine/Building/InstallerImage.swift +++ b/Sources/BushelMachine/Building/InstallerImage.swift @@ -30,6 +30,7 @@ public import BushelFoundation public import BushelLogging public import Foundation +public import OSVer /// A protocol that represents an installer image for an operating system. public protocol InstallerImage: OperatingSystemInstalled, Sendable { @@ -54,7 +55,7 @@ public protocol InstallerImage: OperatingSystemInstalled, Sendable { extension InstallerImage { /// The operating system version associated with the installer image. - public var operatingSystemVersion: OperatingSystemVersion { + public var operatingSystemVersion: OSVer { metadata.operatingSystem } diff --git a/Sources/BushelMachine/Building/InstallerImageMetadata.swift b/Sources/BushelMachine/Building/InstallerImageMetadata.swift index 68133a0b..c2e3d670 100644 --- a/Sources/BushelMachine/Building/InstallerImageMetadata.swift +++ b/Sources/BushelMachine/Building/InstallerImageMetadata.swift @@ -29,6 +29,7 @@ public import BushelFoundation public import Foundation +public import OSVer /// Represents metadata for an installer image. public struct InstallerImageMetadata: Equatable, Sendable { @@ -39,7 +40,7 @@ public struct InstallerImageMetadata: Equatable, Sendable { /// The label name of the installer image. public let labelName: String /// The operating system version of the installer image. - public let operatingSystem: OperatingSystemVersion + public let operatingSystem: OSVer /// The build version of the installer image, if available. public let buildVersion: String? /// The name of the image resource used for the installer image. @@ -68,7 +69,7 @@ public struct InstallerImageMetadata: Equatable, Sendable { longName: String, defaultName: String, labelName: String, - operatingSystem: OperatingSystemVersion, + operatingSystem: OSVer, buildVersion: String?, imageResourceName: String, systemName: String, diff --git a/Sources/BushelMachine/Configuration/MachineConfiguration.swift b/Sources/BushelMachine/Configuration/MachineConfiguration.swift index 6cef0a88..16ea1165 100644 --- a/Sources/BushelMachine/Configuration/MachineConfiguration.swift +++ b/Sources/BushelMachine/Configuration/MachineConfiguration.swift @@ -30,6 +30,7 @@ public import BushelFoundation import BushelUtilities public import Foundation +public import OSVer public import RadiantDocs import RadiantKit @@ -40,7 +41,7 @@ public struct MachineConfiguration: Codable, OperatingSystemInstalled, Sendable /// System ID public let vmSystemID: VMSystemID public let snapshotSystemID: SnapshotterID - public let operatingSystemVersion: OperatingSystemVersion + public let operatingSystemVersion: OSVer public let buildVersion: String? /// Storage specifications @@ -66,7 +67,7 @@ public struct MachineConfiguration: Codable, OperatingSystemInstalled, Sendable restoreImageFile: InstallerImageIdentifier, vmSystemID: VMSystemID, snapshotSystemID: SnapshotterID, - operatingSystemVersion: OperatingSystemVersion, + operatingSystemVersion: OSVer, buildVersion: String? = nil, storage: [MachineStorageSpecification], cpuCount: Int = 1, diff --git a/Sources/BushelMachine/Snapshots/Snapshot.swift b/Sources/BushelMachine/Snapshots/Snapshot.swift index 3152d73b..e45ceaea 100644 --- a/Sources/BushelMachine/Snapshots/Snapshot.swift +++ b/Sources/BushelMachine/Snapshots/Snapshot.swift @@ -29,6 +29,7 @@ public import BushelFoundation public import Foundation +public import OSVer /// Represents a snapshot of a system, /// containing information about the system's state at a specific point in time. @@ -49,7 +50,7 @@ public struct Snapshot: Codable, Identifiable, Sendable { public var notes: String /// The version of the operating system installed at the time of the snapshot. - public var operatingSystemVersion: OperatingSystemVersion? + public var operatingSystemVersion: OSVer? /// The build version of the operating system installed at the time of the snapshot. public var buildVersion: String? @@ -76,7 +77,7 @@ public struct Snapshot: Codable, Identifiable, Sendable { createdAt: Date, isDiscardable: Bool, notes: String = "", - operatingSystemVersion: OperatingSystemVersion? = nil, + operatingSystemVersion: OSVer? = nil, buildVersion: String? = nil ) { self.name = name @@ -94,7 +95,7 @@ extension Snapshot { /// Represents the operating system information installed at the time of the snapshot. internal struct OperatingSystem: OperatingSystemInstalled { /// The version of the operating system installed at the time of the snapshot. - internal let operatingSystemVersion: OperatingSystemVersion + internal let operatingSystemVersion: OSVer /// The build version of the operating system installed at the time of the snapshot. internal let buildVersion: String? @@ -104,7 +105,7 @@ extension Snapshot { /// - operatingSystemVersion: The version of the operating system /// installed at the time of the snapshot. /// - buildVersion: The build version of the operating system installed at the time of the snapshot. - internal init(operatingSystemVersion: OperatingSystemVersion, buildVersion: String?) { + internal init(operatingSystemVersion: OSVer, buildVersion: String?) { self.operatingSystemVersion = operatingSystemVersion self.buildVersion = buildVersion } @@ -115,7 +116,7 @@ extension Snapshot { /// at the time of the snapshot. May be `nil`. /// - buildVersion: The build version of the operating system /// installed at the time of the snapshot. May be `nil`. - internal init?(operatingSystemVersion: OperatingSystemVersion?, buildVersion: String?) { + internal init?(operatingSystemVersion: OSVer?, buildVersion: String?) { guard let operatingSystemVersion else { return nil } diff --git a/Sources/BushelMachineWax/Fake/InstallerImageMetadata.swift b/Sources/BushelMachineWax/Fake/InstallerImageMetadata.swift index 29e25771..94661d62 100644 --- a/Sources/BushelMachineWax/Fake/InstallerImageMetadata.swift +++ b/Sources/BushelMachineWax/Fake/InstallerImageMetadata.swift @@ -29,9 +29,10 @@ public import BushelMachine public import Foundation +public import OSVer extension InstallerImageMetadata { - public init(operatingSystem: OperatingSystemVersion) { + public init(operatingSystem: OSVer) { self.init( longName: .randomLowerCaseAlphaNumberic(), defaultName: .randomLowerCaseAlphaNumberic(), diff --git a/Sources/BushelUtilities/Extensions/OperatingSystemVersion.swift b/Sources/BushelUtilities/Extensions/OSVer.swift similarity index 93% rename from Sources/BushelUtilities/Extensions/OperatingSystemVersion.swift rename to Sources/BushelUtilities/Extensions/OSVer.swift index fdc371ac..a14bdfae 100644 --- a/Sources/BushelUtilities/Extensions/OperatingSystemVersion.swift +++ b/Sources/BushelUtilities/Extensions/OSVer.swift @@ -1,5 +1,5 @@ // -// OperatingSystemVersion.swift +// OSVer.swift // BushelKit // // Created by Leo Dion. @@ -28,12 +28,9 @@ // public import Foundation +public import OSVer -#if canImport(FoundationNetworking) - extension OperatingSystemVersion: @unchecked Sendable {} -#endif - -extension OperatingSystemVersion { +extension OSVer { /// A private dictionary mapping macOS major version numbers to their corresponding release names. private static let codeNames: [Int: String] = [ 11: "Big Sur", @@ -48,7 +45,7 @@ extension OperatingSystemVersion { /// The release name of the current macOS version, if available. public var macOSReleaseName: String? { - Self.macOSReleaseName(majorVersion: majorVersion) + Self.macOSReleaseName(majorVersion: self.majorVersion) } /// Returns the release name for the specified macOS major version, if available. diff --git a/Sources/BushelUtilities/Semver.swift b/Sources/BushelUtilities/Semver.swift index 787e6ae7..cc59c52a 100644 --- a/Sources/BushelUtilities/Semver.swift +++ b/Sources/BushelUtilities/Semver.swift @@ -28,6 +28,7 @@ // public import Foundation +public import OSVer /// Represents a Semantic Version (SemVer) using the `OperatingSystemVersion` type. -public typealias Semver = OperatingSystemVersion +public typealias Semver = OSVer diff --git a/Sources/BushelVirtualBuddy/VirtualBuddySig.swift b/Sources/BushelVirtualBuddy/VirtualBuddySig.swift index 01c4ca06..0769d151 100644 --- a/Sources/BushelVirtualBuddy/VirtualBuddySig.swift +++ b/Sources/BushelVirtualBuddy/VirtualBuddySig.swift @@ -28,10 +28,11 @@ // public import Foundation +public import OSVer public struct VirtualBuddySig: Codable { public let uuid: UUID - public let version: OperatingSystemVersion + public let version: OSVer public let build: String public let code: Int public let message: String diff --git a/Tests/BushelFactoryTests/Utilities/MockInstallerImage.swift b/Tests/BushelFactoryTests/Utilities/MockInstallerImage.swift index eae16fc9..1f3f9a6f 100644 --- a/Tests/BushelFactoryTests/Utilities/MockInstallerImage.swift +++ b/Tests/BushelFactoryTests/Utilities/MockInstallerImage.swift @@ -31,6 +31,7 @@ import BushelFoundation import BushelMachine import BushelMachineWax import Foundation +import OSVer internal struct MockInstallerImage: InstallerImage, Equatable { internal let libraryID: LibraryIdentifier? @@ -51,7 +52,7 @@ internal struct MockInstallerImage: InstallerImage, Equatable { var dictionary: [Int: [MockInstallerImage]] = .init() for majorVersion in majorVersionRange { let osVersionsAll = (0..