-
Notifications
You must be signed in to change notification settings - Fork 26
/
Copy pathPackage.swift
150 lines (145 loc) · 5.2 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
// swift-tools-version: 5.9
//===----------------------------------------------------------------------===//
//
// This source file is part of the swift-kafka-client open source project
//
// Copyright (c) 2022 Apple Inc. and the swift-kafka-client project authors
// Licensed under Apache License v2.0
//
// See LICENSE.txt for license information
// See CONTRIBUTORS.txt for the list of swift-kafka-client project authors
//
// SPDX-License-Identifier: Apache-2.0
//
//===----------------------------------------------------------------------===//
import PackageDescription
let rdkafkaExclude = [
"./librdkafka/src/CMakeLists.txt",
"./librdkafka/src/Makefile",
"./librdkafka/src/README.lz4.md",
"./librdkafka/src/generate_proto.sh",
"./librdkafka/src/librdkafka_cgrp_synch.png",
"./librdkafka/src/opentelemetry/metrics.options",
"./librdkafka/src/rdkafka_sasl_win32.c",
"./librdkafka/src/rdwin32.h",
"./librdkafka/src/statistics_schema.json",
"./librdkafka/src/win32_config.h",
// Remove dependency on cURL. Disabling `ENABLE_CURL` and `WITH_CURL` does
// not appear to prevent processing of the below files, so we have to exclude
// them explicitly.
"./librdkafka/src/rdkafka_sasl_oauthbearer.c",
"./librdkafka/src/rdkafka_sasl_oauthbearer_oidc.c",
"./librdkafka/src/rdhttp.c",
]
let package = Package(
name: "swift-kafka-client",
platforms: [
.macOS(.v13),
.iOS(.v16),
.watchOS(.v9),
.tvOS(.v16),
],
products: [
.library(
name: "Kafka",
targets: ["Kafka"]
),
.library(
name: "KafkaFoundationCompat",
targets: ["KafkaFoundationCompat"]
),
],
dependencies: [
.package(url: "https://github.com/apple/swift-nio.git", from: "2.55.0"),
.package(url: "https://github.com/swift-server/swift-service-lifecycle.git", from: "2.1.0"),
.package(url: "https://github.com/apple/swift-log.git", from: "1.0.0"),
.package(url: "https://github.com/apple/swift-metrics", from: "2.4.1"),
// The zstd Swift package produces warnings that we cannot resolve:
// https://github.com/facebook/zstd/issues/3328
.package(url: "https://github.com/facebook/zstd.git", from: "1.5.0"),
],
targets: [
.target(
name: "Crdkafka",
dependencies: [
"COpenSSL",
.product(name: "libzstd", package: "zstd"),
],
exclude: rdkafkaExclude,
sources: ["./librdkafka/src/"],
publicHeadersPath: "./include",
cSettings: [
// dummy folder, because config.h is included as "../config.h" in librdkafka
.headerSearchPath("./custom/config/dummy"),
.headerSearchPath("./librdkafka/src"),
.define("_GNU_SOURCE", to: "1"), // Fix build error for Swift 5.9 onwards
],
linkerSettings: [
.linkedLibrary("sasl2"),
.linkedLibrary("z"), // zlib
]
),
.target(
name: "Kafka",
dependencies: [
"Crdkafka",
.product(name: "NIOCore", package: "swift-nio"),
.product(name: "ServiceLifecycle", package: "swift-service-lifecycle"),
.product(name: "Logging", package: "swift-log"),
.product(name: "Metrics", package: "swift-metrics"),
]
),
.target(
name: "KafkaFoundationCompat",
dependencies: [
"Kafka"
]
),
.systemLibrary(
name: "COpenSSL",
pkgConfig: "openssl",
providers: [
.brew(["libressl"]),
.apt(["libssl-dev"]),
]
),
.testTarget(
name: "KafkaTests",
dependencies: [
"Kafka",
.product(name: "MetricsTestKit", package: "swift-metrics"),
]
),
.testTarget(
name: "IntegrationTests",
dependencies: ["Kafka"]
),
]
)
for target in package.targets {
switch target.type {
case .regular, .test, .executable:
var settings = target.swiftSettings ?? []
settings.append(.enableExperimentalFeature("StrictConcurrency=complete"))
target.swiftSettings = settings
case .macro, .plugin, .system, .binary:
break // These targets do not support settings
@unknown default:
fatalError("Update to handle new target type \(target.type)")
}
}
// --- STANDARD CROSS-REPO SETTINGS DO NOT EDIT --- //
for target in package.targets {
switch target.type {
case .regular, .test, .executable:
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
case .macro, .plugin, .system, .binary:
() // not applicable
@unknown default:
() // we don't know what to do here, do nothing
}
}
// --- END: STANDARD CROSS-REPO SETTINGS DO NOT EDIT --- //