-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathPackage.swift
142 lines (134 loc) · 5.06 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
139
140
141
142
// swift-tools-version: 6.0
// The swift-tools-version declares the minimum version of Swift required to build this package.
import class Foundation.ProcessInfo
import PackageDescription
let externalDependencies: [String: Range<Version>] = [
"https://github.com/ordo-one/flatbuffers": .upToNextMajor(from: "22.0.0"),
"https://github.com/apple/swift-argument-parser": .upToNextMajor(from: "1.1.0"),
"https://github.com/apple/swift-nio": .upToNextMajor(from: "2.42.0"),
"https://github.com/apple/swift-log": .upToNextMajor(from: "1.4.4"),
"https://github.com/ordo-one/swift-service-lifecycle_1.0": .upToNextMajor(from: "1.0.0-alpha.13"), // to remove in future
"https://github.com/apple/swift-service-discovery.git" : .upToNextMajor(from: "1.0.0"),
]
let internalDependencies: [String: Range<Version>] = [
"package-benchmark": .upToNextMajor(from: "1.0.0"),
"package-consul": .upToNextMajor(from: "7.0.0"),
"package-lz4": .upToNextMinor(from: "1.10.0"),
]
#if swift(>=6.0)
@MainActor
#endif
func makeDependencies() -> [Package.Dependency] {
var dependencies: [Package.Dependency] = []
dependencies.reserveCapacity(externalDependencies.count + internalDependencies.count)
for extDep in externalDependencies {
dependencies.append(.package(url: extDep.key, extDep.value))
}
let localPath = ProcessInfo.processInfo.environment["LOCAL_PACKAGES_DIR"]
for intDep in internalDependencies {
if let localPath {
dependencies.append(.package(name: "\(intDep.key)", path: "\(localPath)/\(intDep.key)"))
} else {
dependencies.append(.package(url: "https://github.com/ordo-one/\(intDep.key)", intDep.value))
}
}
return dependencies
}
let package = Package(
name: "package-distributed-system",
platforms: [
.macOS(.v15),
.iOS(.v17),
],
products: [
.library(
name: "DistributedSystem",
targets: ["DistributedSystem"]
),
.executable(
name: "TestClient",
targets: ["TestClient"]
),
.executable(
name: "TestService",
targets: ["TestService"]
),
],
dependencies: makeDependencies(),
targets: [
.target(
name: "DistributedSystem",
dependencies: [
.product(name: "ConsulServiceDiscovery", package: "package-consul"),
.product(name: "Logging", package: "swift-log"),
.product(name: "lz4", package: "package-lz4"),
.product(name: "NIOCore", package: "swift-nio"),
.product(name: "NIOPosix", package: "swift-nio"),
.product(name: "ServiceDiscovery", package: "swift-service-discovery"),
],
swiftSettings:[
.enableExperimentalFeature("AccessLevelOnImport")
]
),
.target(
name: "TestMessages",
dependencies: [
"DistributedSystem",
.product(name: "FlatBuffers", package: "flatbuffers"),
],
path: "Sources/ForTesting/TestMessages/",
exclude: ["TestMessages.fbs"]
),
.executableTarget(
name: "TestService",
dependencies: [
"DistributedSystem",
"TestMessages",
.product(name: "ArgumentParser", package: "swift-argument-parser"),
.product(name: "Lifecycle", package: "swift-service-lifecycle_1.0"),
],
path: "Sources/ForTesting/TestService",
swiftSettings: [
.unsafeFlags(["-Xfrontend", "-enable-experimental-distributed"]),
]
),
.executableTarget(
name: "TestClient",
dependencies: [
"DistributedSystem",
"TestMessages",
.product(name: "ArgumentParser", package: "swift-argument-parser"),
.product(name: "Lifecycle", package: "swift-service-lifecycle_1.0"),
],
path: "Sources/ForTesting/TestClient",
swiftSettings: [
.unsafeFlags(["-Xfrontend", "-enable-experimental-distributed"]),
]
),
.executableTarget(
name: "DistributedSystemBenchmark",
dependencies: [
"DistributedSystem",
"TestMessages",
.product(name: "Benchmark", package: "package-benchmark"),
.product(name: "BenchmarkPlugin", package: "package-benchmark"),
],
path: "Benchmarks/DistributedSystem",
swiftSettings: [
.enableExperimentalFeature("AccessLevelOnImport"),
.unsafeFlags(["-Xfrontend", "-enable-experimental-distributed"])
]
),
.testTarget(
name: "DistributedSystemTests",
dependencies: [
"DistributedSystem",
"TestMessages",
],
resources: [
.process("Resources")
]
),
],
swiftLanguageModes: [.v5]
)