Skip to content

Commit b0d26bf

Browse files
committed
Add setup to enable all traits with env vars
1 parent 06eb4dc commit b0d26bf

File tree

1 file changed

+15
-4
lines changed

1 file changed

+15
-4
lines changed

Package.swift

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,26 @@
11
// swift-tools-version:6.1
22
// The swift-tools-version declares the minimum version of Swift required to build this package.
33

4+
import Foundation
45
import PackageDescription
56

67
let swiftSettings: [SwiftSetting] = [
78
.enableUpcomingFeature("ExistentialAny")
89
]
910

11+
// Should we enable all traits.
12+
let enableAllTraitsExplicitly = ProcessInfo.processInfo.environment["ENABLE_ALL_TRAITS"] != nil
13+
let enableAllTraitsInCI = ProcessInfo.processInfo.environment["CI"] != nil
14+
let enableAllTraits = enableAllTraitsExplicitly || enableAllTraitsInCI
15+
// Construct trait set
16+
var traits: Set<Trait> = [
17+
.trait(name: "ExperimentalConfiguration")
18+
]
19+
let defaultTraits: Trait = .default(enabledTraits: [])
20+
if enableAllTraits {
21+
traits.insert(enableAllTraits ? .default(enabledTraits: Set(traits.map(\.name))) : defaultTraits)
22+
}
23+
1024
let package = Package(
1125
name: "hummingbird",
1226
platforms: [.macOS(.v15), .iOS(.v17), .macCatalyst(.v17), .tvOS(.v17), .visionOS(.v1)],
@@ -19,10 +33,7 @@ let package = Package(
1933
.library(name: "HummingbirdTesting", targets: ["HummingbirdTesting"]),
2034
.executable(name: "PerformanceTest", targets: ["PerformanceTest"]),
2135
],
22-
traits: [
23-
.trait(name: "ExperimentalConfiguration"),
24-
.default(enabledTraits: ["ExperimentalConfiguration"]),
25-
],
36+
traits: traits,
2637
dependencies: [
2738
.package(url: "https://github.com/apple/swift-async-algorithms.git", from: "1.0.2"),
2839
.package(url: "https://github.com/apple/swift-atomics.git", from: "1.0.0"),

0 commit comments

Comments
 (0)