Skip to content
This repository was archived by the owner on Mar 10, 2025. It is now read-only.

Commit 8dcad74

Browse files
authored
Add initial wrap for 1.4.0 (#1)
* Add initial wrap for 1.4.0 * Fix ERROR: The "meson-" prefix is reserved and cannot be used for top-level subdir(). * Allow configuring sasl/ssl
1 parent f9d7274 commit 8dcad74

File tree

4 files changed

+221
-0
lines changed

4 files changed

+221
-0
lines changed
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# https://github.com/mesonbuild/meson/issues/2546
2+
install_headers(hdr, subdir: 'librdkafka')
3+
foreach h: hdr
4+
configure_file(
5+
copy: true,
6+
input: h,
7+
output: '@PLAINNAME@',
8+
)
9+
endforeach

meson.build

Lines changed: 196 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,196 @@
1+
project('rdkafka', 'c', 'cpp', version: '1.4.0')
2+
cc = meson.get_compiler('c')
3+
cpp = meson.get_compiler('cpp')
4+
pkgconfig = import('pkgconfig')
5+
6+
hdr = files(
7+
'src/rdkafka.h',
8+
'src-cpp/rdkafkacpp.h',
9+
)
10+
subdir('include-workaround-meson/librdkafka')
11+
srcc = [
12+
'src/crc32c.c',
13+
'src/rdaddr.c',
14+
'src/rdavl.c',
15+
'src/rdbuf.c',
16+
'src/rdcrc32.c',
17+
'src/rdfnv1a.c',
18+
'src/rdkafka.c',
19+
'src/rdkafka_assignor.c',
20+
'src/rdkafka_broker.c',
21+
'src/rdkafka_buf.c',
22+
'src/rdkafka_cgrp.c',
23+
'src/rdkafka_conf.c',
24+
'src/rdkafka_event.c',
25+
'src/rdkafka_feature.c',
26+
'src/rdkafka_lz4.c',
27+
'src/rdkafka_metadata.c',
28+
'src/rdkafka_metadata_cache.c',
29+
'src/rdkafka_msg.c',
30+
'src/rdkafka_msgset_reader.c',
31+
'src/rdkafka_msgset_writer.c',
32+
'src/rdkafka_offset.c',
33+
'src/rdkafka_op.c',
34+
'src/rdkafka_partition.c',
35+
'src/rdkafka_pattern.c',
36+
'src/rdkafka_queue.c',
37+
'src/rdkafka_range_assignor.c',
38+
'src/rdkafka_request.c',
39+
'src/rdkafka_roundrobin_assignor.c',
40+
'src/rdkafka_sasl.c',
41+
'src/rdkafka_sasl_plain.c',
42+
'src/rdkafka_subscription.c',
43+
'src/rdkafka_timer.c',
44+
'src/rdkafka_topic.c',
45+
'src/rdkafka_transport.c',
46+
'src/rdkafka_interceptor.c',
47+
'src/rdkafka_header.c',
48+
'src/rdkafka_admin.c',
49+
'src/rdkafka_aux.c',
50+
'src/rdkafka_background.c',
51+
'src/rdkafka_idempotence.c',
52+
'src/rdkafka_txnmgr.c',
53+
'src/rdkafka_cert.c',
54+
'src/rdkafka_coord.c',
55+
'src/rdkafka_mock.c',
56+
'src/rdkafka_mock_handlers.c',
57+
'src/rdkafka_mock_cgrp.c',
58+
'src/rdkafka_error.c',
59+
'src/rdlist.c',
60+
'src/rdlog.c',
61+
'src/rdmurmur2.c',
62+
'src/rdports.c',
63+
'src/rdrand.c',
64+
'src/rdregex.c',
65+
'src/rdstring.c',
66+
'src/rdunittest.c',
67+
'src/rdvarint.c',
68+
'src/snappy.c',
69+
'src/tinycthread.c',
70+
'src/tinycthread_extra.c',
71+
'src/rdxxhash.c',
72+
]
73+
srccpp = [
74+
'src-cpp/ConfImpl.cpp',
75+
'src-cpp/ConsumerImpl.cpp',
76+
'src-cpp/HeadersImpl.cpp',
77+
'src-cpp/KafkaConsumerImpl.cpp',
78+
'src-cpp/MessageImpl.cpp',
79+
'src-cpp/MetadataImpl.cpp',
80+
'src-cpp/ProducerImpl.cpp',
81+
'src-cpp/QueueImpl.cpp',
82+
'src-cpp/RdKafka.cpp',
83+
'src-cpp/TopicImpl.cpp',
84+
'src-cpp/TopicPartitionImpl.cpp',
85+
'src-cpp/HandleImpl.cpp',
86+
'src-cpp/rdkafkacpp.h',
87+
'src-cpp/rdkafkacpp_int.h',
88+
]
89+
90+
regex = cc.compiles('''
91+
#include <stddef.h>
92+
#include <regex.h>
93+
void foo (void) {
94+
regcomp(NULL, NULL, 0);
95+
regexec(NULL, NULL, 0, NULL, 0);
96+
regerror(0, NULL, NULL, 0);
97+
regfree(NULL);
98+
}
99+
''', name: 'have regex')
100+
101+
zlib = dependency('zlib', required: get_option('WITH_ZLIB'), static: get_option('default_library') == 'static', fallback: ['zlib', 'zlib_dep'])
102+
zstd = dependency('libzstd', required: get_option('WITH_ZSTD'), static: get_option('default_library') == 'static', fallback: ['zstd', 'zstd_dep'])
103+
lz4 = dependency('liblz4', required: get_option('ENABLE_LZ4_EXT'), static: get_option('default_library') == 'static', fallback: ['lz4', 'lz4_dep'])
104+
sasl = dependency('libsasl2', required: get_option('WITH_SASL'), static: get_option('default_library') == 'static') # TODO: make SASL usable without libsasl2 on windows
105+
ssl = dependency('openssl', required: get_option('WITH_SSL'), static: get_option('default_library') == 'static')
106+
dl = cc.find_library('dl', required : get_option('WITH_LIBDL'))
107+
threads = dependency('threads')
108+
109+
conf = configuration_data()
110+
111+
conf.set10('WITHOUT_OPTIMIZATION', get_option('WITHOUT_OPTIMIZATION'))
112+
conf.set10('ENABLE_DEVEL', get_option('ENABLE_DEVEL'))
113+
conf.set10('ENABLE_REFCNT_DEBUG', get_option('ENABLE_REFCNT_DEBUG'))
114+
conf.set10('ENABLE_SHAREDPTR_DEBUG', get_option('ENABLE_SHAREDPTR_DEBUG'))
115+
conf.set10('WITH_PLUGINS', dl.found())
116+
conf.set10('WITH_LIBDL', dl.found())
117+
conf.set10('WITH_ZLIB', zlib.found())
118+
conf.set10('WITH_ZSTD', zstd.found())
119+
conf.set10('WITH_SSL', ssl.found())
120+
conf.set10('WITH_SASL', sasl.found())
121+
conf.set10('ENABLE_LZ4_EXT', lz4.found())
122+
conf.set10('HAVE_REGEX', regex)
123+
conf.set('CMAKE_SHARED_LIBRARY_SUFFIX', 'so')
124+
125+
built_with = 'meson ' + cc.get_id() + ' ' + cpp.get_id()
126+
if ssl.found()
127+
built_with += ' SSL'
128+
srcc += 'src/rdkafka_ssl.c'
129+
endif
130+
if dl.found()
131+
srcc += ['src/rddl.c', 'src/rdkafka_plugin.c']
132+
built_with += ' LIBDL PLUGINS'
133+
endif
134+
if sasl.found()
135+
if host_machine.system() == 'windows'
136+
srcc += 'src/rdkafka_sasl_win32.c'
137+
else
138+
srcc += 'src/rdkafka_sasl_cyrus.c'
139+
conf.set10('WITH_SASL_CYRUS', true)
140+
built_with += ' SASL_CYRUS'
141+
endif
142+
if ssl.found()
143+
srcc += [ 'src/rdkafka_sasl_scram.c', 'src/rdkafka_sasl_oauthbearer.c']
144+
conf.set10('WITH_SASL_SCRAM', true)
145+
conf.set10('WITH_SASL_OAUTHBEARER', true)
146+
built_with += ' SASL_SCRAM SASL_OAUTHBEARER'
147+
endif
148+
endif
149+
150+
if zlib.found()
151+
srcc += 'src/rdgz.c'
152+
built_with += ' ZLIB'
153+
endif
154+
if zstd.found()
155+
srcc += 'src/rdkafka_zstd.c'
156+
built_with += ' ZSTD'
157+
endif
158+
if lz4.found()
159+
srcc += ['src/lz4.c', 'src/lz4frame.c', 'src/lz4hc.c']
160+
built_with += ' LZ4'
161+
endif
162+
if not regex
163+
srcc += 'src/regexp.c'
164+
endif
165+
166+
conf.set('BUILT_WITH', built_with)
167+
configure_file(configuration: conf,
168+
input: 'packaging/cmake/config.h.in',
169+
output: 'config.h',
170+
format: 'cmake',
171+
)
172+
173+
rdkafka = library('rdkafka', srcc, install: true, dependencies: [threads, dl, zlib, zstd, sasl, ssl, lz4])
174+
rdkafka_dep = declare_dependency(
175+
link_with: rdkafka,
176+
include_directories: include_directories('include-workaround-meson'),
177+
)
178+
pkgconfig.generate(rdkafka,
179+
subdirs: 'rdkafka',
180+
version : meson.project_version(),
181+
name: 'rdkafka',
182+
filebase: 'rdkafka',
183+
description: 'The Apache Kafka C/C++ library'
184+
)
185+
rdkafkapp = library('rdkafka++', srccpp, install: true, dependencies: rdkafka_dep)
186+
rdkafkapp_dep = declare_dependency(
187+
link_with: rdkafkapp,
188+
include_directories: include_directories('include-workaround-meson'),
189+
)
190+
pkgconfig.generate(rdkafkapp,
191+
subdirs: 'rdkafka',
192+
version: meson.project_version(),
193+
name: 'rdkafka++',
194+
filebase: 'rdkafka',
195+
description: 'The Apache Kafka C/C++ library'
196+
)

meson_options.txt

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
option('WITHOUT_OPTIMIZATION', type : 'boolean', value : false, description : 'Disable optimization')
2+
option('ENABLE_DEVEL', type : 'boolean', value : false, description : 'Enable development asserts, checks, etc')
3+
option('ENABLE_REFCNT_DEBUG', type : 'boolean', value : false, description : 'Enable refcnt debugging')
4+
option('ENABLE_SHAREDPTR_DEBUG', type : 'boolean', value : false, description : 'Enable sharedptr debugging')
5+
option('WITH_LIBDL', type : 'feature', value : 'enabled', description : 'With libdl')
6+
option('WITH_ZLIB', type : 'feature', value : 'enabled', description : 'With ZLIB')
7+
option('WITH_ZSTD', type : 'feature', value : 'enabled', description : 'With ZSTD')
8+
option('WITH_SSL', type : 'feature', value : 'enabled', description : 'With SSL')
9+
option('WITH_SASL', type : 'feature', value : 'enabled', description : 'With SASL')
10+
option('ENABLE_LZ4_EXT', type : 'feature', value : 'enabled', description : 'Enable external LZ4 library support')

upstream.wrap

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
[wrap-file]
2+
directory = librdkafka-1.4.0
3+
4+
source_url = https://github.com/edenhill/librdkafka/archive/v1.4.0.tar.gz
5+
source_filename = rdkafka-1.4.0.tgz
6+
source_hash = ae27ea3f3d0d32d29004e7f709efbba2666c5383a107cc45b3a1949486b2eb84

0 commit comments

Comments
 (0)