-
Notifications
You must be signed in to change notification settings - Fork 12
/
Package.swift
138 lines (108 loc) · 3.66 KB
/
Package.swift
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
// swift-tools-version:6.0
// The swift-tools-version declares the minimum version of Swift required to build this package.
import CompilerPluginSupport
import PackageDescription
let package = Package(
name: "Vexil",
platforms: [
.iOS(.v15),
.macOS(.v12),
.tvOS(.v15),
.watchOS(.v8),
],
products: [
// Automatic
.library(name: "Vexil", targets: [ "Vexil" ]),
// .library(name: "Vexillographer", targets: [ "Vexillographer" ]),
],
dependencies: .init {
Package.Dependency.package(url: "https://github.com/apple/swift-async-algorithms.git", from: "1.0.0")
Package.Dependency.package(url: "https://github.com/nicklockwood/SwiftFormat.git", from: "0.54.1")
Package.Dependency.package(url: "https://github.com/swiftlang/swift-syntax.git", exact: "600.0.0-prerelease-2024-06-12")
#if os(Linux)
// Linux does not come bundled with swift-testing
Package.Dependency.package(url: "https://github.com/apple/swift-testing.git", exact: "0.11.0")
#endif
},
targets: .init {
// Vexil
Target.target(
name: "Vexil",
dependencies: [
.target(name: "VexilMacros"),
.product(name: "AsyncAlgorithms", package: "swift-async-algorithms"),
],
swiftSettings: [
.enableExperimentalFeature("StrictConcurrency"),
]
)
Target.testTarget(
name: "VexilTests",
dependencies: .init {
Target.Dependency.target(name: "Vexil")
#if os(Linux)
// Linux does not come bundled with swift-testing
Target.Dependency.product(name: "Testing", package: "swift-testing")
#endif
},
swiftSettings: [
.enableExperimentalFeature("StrictConcurrency"),
]
)
// Vexillographer
// Target.target(
// name: "Vexillographer",
// dependencies: [
// .target(name: "Vexil"),
// ]
// ),
// Macros
Target.macro(
name: "VexilMacros",
dependencies: [
.product(name: "SwiftCompilerPlugin", package: "swift-syntax"),
.product(name: "SwiftSyntax", package: "swift-syntax"),
.product(name: "SwiftSyntaxBuilder", package: "swift-syntax"),
.product(name: "SwiftSyntaxMacros", package: "swift-syntax"),
],
swiftSettings: [
.enableExperimentalFeature("StrictConcurrency"),
]
)
#if !os(Linux)
// We can't disable macro validation using `swift test` so these are guaranteed to fail on Linux
Target.testTarget(
name: "VexilMacroTests",
dependencies: [
.target(name: "VexilMacros"),
.product(name: "SwiftSyntaxMacrosTestSupport", package: "swift-syntax"),
],
swiftSettings: [
.enableExperimentalFeature("StrictConcurrency"),
]
)
#endif
},
swiftLanguageVersions: [
.v6,
]
)
// MARK: - Helpers
@resultBuilder
enum CollectionBuilder<Element> {
typealias Component = [Element]
static func buildExpression(_ expression: Element) -> Component {
[expression]
}
static func buildBlock(_ components: Component...) -> Component {
components.flatMap { $0 }
}
static func buildLimitedAvailability(_ components: [Element]) -> Component {
components
}
}
extension Array {
init(@CollectionBuilder<Element> collecting: () -> [Element]) {
self = collecting()
}
}