@@ -20,82 +20,119 @@ let package = Package(
2020// .library(name: "Vexillographer", targets: [ "Vexillographer" ]),
2121 ] ,
2222
23- dependencies: [
24- . package ( url: " https://github.com/apple/swift-async-algorithms.git " , from: " 1.0.0 " ) ,
25- . package ( url: " https://github.com/nicklockwood/SwiftFormat.git " , from: " 0.54.1 " ) ,
26- . package ( url: " https://github.com/apple/swift-syntax.git " , exact: " 600.0.0-prerelease-2024-06-12 " ) ,
27- ] ,
23+ dependencies: . init {
24+ Package . Dependency. package ( url: " https://github.com/apple/swift-async-algorithms.git " , from: " 1.0.0 " )
25+ Package . Dependency. package ( url: " https://github.com/nicklockwood/SwiftFormat.git " , from: " 0.54.1 " )
26+ Package . Dependency. package ( url: " https://github.com/swiftlang/swift-syntax.git " , exact: " 600.0.0-prerelease-2024-06-12 " )
27+
28+ #if os(Linux)
29+ // Linux does not come bundled with swift-testing
30+ Package . Dependency. package ( url: " https://github.com/apple/swift-testing.git " , exact: " 0.11.0 " )
31+ #endif
32+
33+ } ,
34+
35+ targets: . init {
36+
37+ // Vexil
38+
39+ Target . target (
40+ name: " Vexil " ,
41+ dependencies: [
42+ . target( name: " VexilMacros " ) ,
43+ . product( name: " AsyncAlgorithms " , package : " swift-async-algorithms " ) ,
44+ ] ,
45+ swiftSettings: [
46+ . enableExperimentalFeature( " StrictConcurrency " ) ,
47+ ]
48+ )
49+ Target . testTarget (
50+ name: " VexilTests " ,
51+ dependencies: . init {
52+ Target . Dependency. target ( name: " Vexil " )
53+
54+ #if os(Linux)
55+ // Linux does not come bundled with swift-testing
56+ Target . Dependency. product ( name: " Testing " , package : " swift-testing " )
57+ #endif
2858
29- targets: {
30- var targets : [ Target ] = [
31-
32- // Vexil
33-
34- . target(
35- name: " Vexil " ,
36- dependencies: [
37- . target( name: " VexilMacros " ) ,
38- . product( name: " AsyncAlgorithms " , package : " swift-async-algorithms " ) ,
39- ] ,
40- swiftSettings: [
41- . enableExperimentalFeature( " StrictConcurrency " ) ,
42- ]
43- ) ,
44- . testTarget(
45- name: " VexilTests " ,
46- dependencies: [
47- . target( name: " Vexil " ) ,
48- ] ,
49- swiftSettings: [
50- . enableExperimentalFeature( " StrictConcurrency " ) ,
51- ]
52- ) ,
53-
54- // Vexillographer
55-
56- // .target(
57- // name: "Vexillographer",
58- // dependencies: [
59- // .target(name: "Vexil"),
60- // ]
61- // ),
62-
63- // Macros
64-
65- . macro(
66- name: " VexilMacros " ,
67- dependencies: [
68- . product( name: " SwiftCompilerPlugin " , package : " swift-syntax " ) ,
69- . product( name: " SwiftSyntax " , package : " swift-syntax " ) ,
70- . product( name: " SwiftSyntaxBuilder " , package : " swift-syntax " ) ,
71- . product( name: " SwiftSyntaxMacros " , package : " swift-syntax " ) ,
72- ] ,
73- swiftSettings: [
74- . enableExperimentalFeature( " StrictConcurrency " ) ,
75- ]
76- ) ,
77-
78- ]
59+ } ,
60+ swiftSettings: [
61+ . enableExperimentalFeature( " StrictConcurrency " ) ,
62+ ]
63+ )
64+
65+ // Vexillographer
66+
67+ // Target.target(
68+ // name: "Vexillographer",
69+ // dependencies: [
70+ // .target(name: "Vexil"),
71+ // ]
72+ // ),
73+
74+ // Macros
75+
76+ Target . macro (
77+ name: " VexilMacros " ,
78+ dependencies: [
79+ . product( name: " SwiftCompilerPlugin " , package : " swift-syntax " ) ,
80+ . product( name: " SwiftSyntax " , package : " swift-syntax " ) ,
81+ . product( name: " SwiftSyntaxBuilder " , package : " swift-syntax " ) ,
82+ . product( name: " SwiftSyntaxMacros " , package : " swift-syntax " ) ,
83+ ] ,
84+ swiftSettings: [
85+ . enableExperimentalFeature( " StrictConcurrency " ) ,
86+ ]
87+ )
7988
8089#if !os(Linux)
81- targets += [
82- . testTarget(
83- name: " VexilMacroTests " ,
84- dependencies: [
85- . target( name: " VexilMacros " ) ,
86- . product( name: " SwiftSyntaxMacrosTestSupport " , package : " swift-syntax " ) ,
87- ] ,
88- swiftSettings: [
89- . enableExperimentalFeature( " StrictConcurrency " ) ,
90- ]
91- ) ,
92- ]
90+
91+ // We can't disable macro validation using `swift test` so these are guaranteed to fail on Linux
92+ Target . testTarget (
93+ name: " VexilMacroTests " ,
94+ dependencies: [
95+ . target( name: " VexilMacros " ) ,
96+ . product( name: " SwiftSyntaxMacrosTestSupport " , package : " swift-syntax " ) ,
97+ ] ,
98+ swiftSettings: [
99+ . enableExperimentalFeature( " StrictConcurrency " ) ,
100+ ]
101+ )
102+
93103#endif
94104
95- return targets
96- } ( ) ,
105+ } ,
97106
98107 swiftLanguageVersions: [
99108 . v6,
100109 ]
110+
101111)
112+
113+ // MARK: - Helpers
114+
115+ @resultBuilder
116+ enum CollectionBuilder < Element> {
117+
118+ typealias Component = [ Element ]
119+
120+ static func buildExpression( _ expression: Element ) -> Component {
121+ [ expression]
122+ }
123+
124+ static func buildBlock( _ components: Component ... ) -> Component {
125+ components. flatMap { $0 }
126+ }
127+
128+ static func buildLimitedAvailability( _ components: [ Element ] ) -> Component {
129+ components
130+ }
131+
132+ }
133+
134+ extension Array {
135+ init ( @CollectionBuilder < Element > collecting: ( ) -> [ Element ] ) {
136+ self = collecting ( )
137+ }
138+ }
0 commit comments