-
Notifications
You must be signed in to change notification settings - Fork 23
/
Package.swift
182 lines (170 loc) · 6.83 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
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
// swift-tools-version:5.9
import PackageDescription
import class Foundation.FileManager
// Compute libuv sources to exclude
var libuvExclude = [
"./libuv/src/unix/aix-common.c",
"./libuv/src/unix/aix.c",
"./libuv/src/unix/bsd-proctitle.c",
"./libuv/src/unix/cygwin.c",
"./libuv/src/unix/freebsd.c",
"./libuv/src/unix/haiku.c",
"./libuv/src/unix/hurd.c",
"./libuv/src/unix/ibmi.c",
"./libuv/src/unix/netbsd.c",
"./libuv/src/unix/no-fsevents.c",
"./libuv/src/unix/no-proctitle.c",
"./libuv/src/unix/openbsd.c",
"./libuv/src/unix/os390-proctitle.c",
"./libuv/src/unix/os390-syscalls.c",
"./libuv/src/unix/os390.c",
"./libuv/src/unix/posix-hrtime.c",
"./libuv/src/unix/posix-poll.c",
"./libuv/src/unix/pthread-fixes.c",
"./libuv/src/unix/qnx.c",
"./libuv/src/unix/sunos.c",
"./libuv/src/unix/sysinfo-loadavg.c",
"./libuv/src/unix/sysinfo-memory.c",
]
#if !os(macOS)
libuvExclude += [
"./libuv/src/unix/bsd-ifaddrs.c",
"./libuv/src/unix/darwin-proctitle.c",
"./libuv/src/unix/darwin.c",
"./libuv/src/unix/fsevents.c",
"./libuv/src/unix/kqueue.c",
"./libuv/src/unix/random-getentropy.c",
]
#endif
#if !os(Linux)
libuvExclude += [
"./libuv/src/unix/epoll.c",
"./libuv/src/unix/linux-core.c",
"./libuv/src/unix/linux-inotify.c",
"./libuv/src/unix/linux-syscalls.c",
"./libuv/src/unix/procfs-exepath.c",
"./libuv/src/unix/random-getrandom.c",
"./libuv/src/unix/random-sysctl-linux.c",
]
#endif
var datastaxExclude = [
"./datastax-cpp-driver/src/CMakeLists.txt",
"./datastax-cpp-driver/src/fixnl.sh",
"./datastax-cpp-driver/src/wkt.rl",
"./datastax-cpp-driver/src/wktgen.sh",
"./datastax-cpp-driver/src/gssapi",
"./datastax-cpp-driver/src/ssl/ssl_no_impl.cpp",
// See ./custom/src/ssl/ssl_openssl_impl.cpp
"./datastax-cpp-driver/src/ssl/ssl_openssl_impl.cpp",
"./datastax-cpp-driver/src/third_party/curl/CMakeLists.txt",
"./datastax-cpp-driver/src/third_party/curl/COPYING",
"./datastax-cpp-driver/src/third_party/hdr_histogram/CMakeLists.txt",
"./datastax-cpp-driver/src/third_party/hdr_histogram/LICENSE.txt",
"./datastax-cpp-driver/src/third_party/http-parser/AUTHORS",
"./datastax-cpp-driver/src/third_party/http-parser/bench.c",
"./datastax-cpp-driver/src/third_party/http-parser/CMakeLists.txt",
"./datastax-cpp-driver/src/third_party/http-parser/http_parser.gyp",
"./datastax-cpp-driver/src/third_party/http-parser/LICENSE-MIT",
"./datastax-cpp-driver/src/third_party/http-parser/README",
"./datastax-cpp-driver/src/third_party/http-parser/README.md",
"./datastax-cpp-driver/src/third_party/http-parser/test.c",
"./datastax-cpp-driver/src/third_party/http-parser/contrib/parsertrace.c",
"./datastax-cpp-driver/src/third_party/http-parser/contrib/url_parser.c",
"./datastax-cpp-driver/src/third_party/minizip",
"./datastax-cpp-driver/src/third_party/mt19937_64",
"./datastax-cpp-driver/src/third_party/rapidjson",
"./datastax-cpp-driver/src/third_party/sparsehash",
"./datastax-cpp-driver/tests",
"./datastax-cpp-driver/examples",
]
do {
if !(try FileManager.default.contentsOfDirectory(
atPath: "./Sources/CDataStaxDriver/datastax-cpp-driver/src/third_party/sparsehash/CMakeFiles"
).isEmpty) {
datastaxExclude.append("./datastax-cpp-driver/src/third_party/sparsehash/CMakeFiles/")
}
} catch {
// Assume CMakeFiles does not exist so no need to exclude it
}
let package = Package(
name: "swift-cassandra-client",
products: [
.library(name: "CassandraClient", targets: ["CassandraClient"])
],
dependencies: [
.package(url: "https://github.com/apple/swift-nio", .upToNextMajor(from: "2.41.1")),
.package(url: "https://github.com/apple/swift-nio-ssl", .upToNextMajor(from: "2.21.0")),
.package(url: "https://github.com/apple/swift-atomics", from: "1.0.2"),
.package(url: "https://github.com/apple/swift-log", .upToNextMajor(from: "1.0.0")),
],
targets: [
.target(
name: "Clibuv",
dependencies: [],
exclude: libuvExclude,
sources: [
"./libuv/src/fs-poll.c",
"./libuv/src/idna.c",
"./libuv/src/inet.c",
"./libuv/src/random.c",
"./libuv/src/strscpy.c",
"./libuv/src/strtok.c",
"./libuv/src/threadpool.c",
"./libuv/src/timer.c",
"./libuv/src/uv-common.c",
"./libuv/src/uv-data-getter-setters.c",
"./libuv/src/version.c",
"./libuv/src/unix",
],
cSettings: [
.headerSearchPath("./libuv/src"),
.define("_GNU_SOURCE", to: "1"), // required to fix "undefined CPU_COUNT" error
]
),
.target(
name: "CDataStaxDriver",
dependencies: [
"Clibuv",
.product(name: "NIOSSL", package: "swift-nio-ssl"),
],
exclude: datastaxExclude,
sources: [
"./datastax-cpp-driver/src",
"./custom/src",
],
publicHeadersPath: "./datastax-cpp-driver/include",
cxxSettings: [
// This is available on all modern Linux systems, and is needed for efficient
// MicroTimer implementation. Otherwise busy waits are used.
.define("HAVE_TIMERFD", .when(platforms: [.linux])),
.headerSearchPath("./custom/include"),
.headerSearchPath("./extras"),
.headerSearchPath("./datastax-cpp-driver/src"),
.headerSearchPath("./datastax-cpp-driver/src/third_party/http-parser"),
.headerSearchPath("./datastax-cpp-driver/src/third_party/sparsehash/src/"),
]
),
.target(
name: "CassandraClient",
dependencies: [
"CDataStaxDriver",
.product(name: "NIO", package: "swift-nio"),
.product(name: "NIOCore", package: "swift-nio"),
.product(name: "Atomics", package: "swift-atomics"),
.product(name: "Logging", package: "swift-log"),
]
),
.testTarget(name: "CassandraClientTests", dependencies: ["CassandraClient"]),
],
cxxLanguageStandard: .cxx14
)
// --- STANDARD CROSS-REPO SETTINGS DO NOT EDIT --- //
for target in package.targets {
if target.type != .plugin {
var settings = target.swiftSettings ?? []
// https://github.com/swiftlang/swift-evolution/blob/main/proposals/0444-member-import-visibility.md
settings.append(.enableUpcomingFeature("MemberImportVisibility"))
target.swiftSettings = settings
}
}
// --- END: STANDARD CROSS-REPO SETTINGS DO NOT EDIT --- //