Skip to content

Commit 298a1cb

Browse files
Add Apache Avro wrap
1 parent 2163a6a commit 298a1cb

4 files changed

Lines changed: 216 additions & 0 deletions

File tree

releases.json

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,17 @@
263263
"0.4.1-1"
264264
]
265265
},
266+
"avro-cpp": {
267+
"dependency_names": [
268+
"avro-cpp"
269+
],
270+
"program_names": [
271+
"avrogencpp"
272+
],
273+
"versions": [
274+
"1.12.1-1"
275+
]
276+
},
266277
"aws-c-common": {
267278
"dependency_names": [
268279
"aws-c-common"

subprojects/avro-cpp.wrap

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
[wrap-file]
2+
directory = avro-cpp-1.12.1
3+
source_url = https://dlcdn.apache.org/avro/avro-1.12.1/cpp/avro-cpp-1.12.1.tar.gz
4+
source_filename = avro-cpp-1.12.1.tar.gz
5+
source_hash = 18a0d155905a4dab0c2bfd66c742358a7d969bcff58cf6f655bcf602879f4fe7
6+
patch_directory = avro-cpp
7+
8+
[provide]
9+
dependency_names = avro-cpp
10+
program_names = avrogencpp
Lines changed: 183 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,183 @@
1+
project(
2+
'avro-cpp',
3+
'cpp',
4+
version: '1.12.1',
5+
license: 'Apache-2.0',
6+
meson_version: '>=0.60.0',
7+
)
8+
9+
override_cpp = 'cpp_std=c++17'
10+
11+
avro_flags = []
12+
avro_deps = []
13+
avro_public_deps = []
14+
15+
fmt_dep = dependency(
16+
'fmt',
17+
required: true,
18+
)
19+
avro_deps += fmt_dep
20+
avro_public_deps += fmt_dep
21+
22+
zlib_dep = dependency(
23+
'zlib',
24+
required: true,
25+
)
26+
avro_deps += zlib_dep
27+
28+
snappy_dep = dependency(
29+
'snappy',
30+
required: false,
31+
)
32+
if snappy_dep.found()
33+
avro_flags += '-DSNAPPY_CODEC_AVAILABLE'
34+
avro_deps += snappy_dep
35+
endif
36+
37+
zstd_dep = dependency(
38+
'libzstd',
39+
required: false,
40+
)
41+
if zstd_dep.found()
42+
avro_flags += '-DZSTD_CODEC_AVAILABLE'
43+
avro_deps += zstd_dep
44+
endif
45+
46+
# Set static and shared flags manually since Meson 1.3.0 is still too new
47+
avro_flags += '-DAVRO_SOURCE'
48+
if get_option('default_library') == 'shared'
49+
avro_flags += '-DAVRO_DYN_LINK'
50+
elif get_option('default_library') == 'both'
51+
error('Building both static and shared libraries is not possible')
52+
endif
53+
54+
avro_inc = include_directories('include/avro')
55+
56+
avro_src = files(
57+
'impl/BinaryDecoder.cc',
58+
'impl/BinaryEncoder.cc',
59+
'impl/Compiler.cc',
60+
'impl/CustomAttributes.cc',
61+
'impl/DataFile.cc',
62+
'impl/FileStream.cc',
63+
'impl/Generic.cc',
64+
'impl/GenericDatum.cc',
65+
'impl/LogicalType.cc',
66+
'impl/Node.cc',
67+
'impl/NodeImpl.cc',
68+
'impl/Resolver.cc',
69+
'impl/ResolverSchema.cc',
70+
'impl/Schema.cc',
71+
'impl/Stream.cc',
72+
'impl/Types.cc',
73+
'impl/ValidSchema.cc',
74+
'impl/Validator.cc',
75+
'impl/Zigzag.cc',
76+
'impl/json/JsonDom.cc',
77+
'impl/json/JsonIO.cc',
78+
'impl/parsing/JsonCodec.cc',
79+
'impl/parsing/ResolvingDecoder.cc',
80+
'impl/parsing/Symbol.cc',
81+
'impl/parsing/ValidatingCodec.cc',
82+
)
83+
84+
avro_lib = library(
85+
'avrocpp',
86+
sources: avro_src,
87+
include_directories: avro_inc,
88+
cpp_args: avro_flags,
89+
dependencies: avro_deps,
90+
override_options: override_cpp,
91+
# gnu_symbol_visibility: 'hidden', TODO: should be hidden but tests fail if not
92+
version: meson.project_version(),
93+
install: true,
94+
)
95+
96+
install_subdir(
97+
'include/avro',
98+
install_dir: get_option('includedir'),
99+
install_tag: 'devel',
100+
)
101+
102+
avro_dep = declare_dependency(
103+
include_directories: avro_inc,
104+
link_with: avro_lib,
105+
dependencies: avro_public_deps,
106+
)
107+
meson.override_dependency('avro-cpp', avro_dep)
108+
109+
avro_requires = []
110+
foreach dep : avro_public_deps
111+
avro_requires += dep.name()
112+
endforeach
113+
import('pkgconfig').generate(
114+
avro_lib,
115+
name: meson.project_name(),
116+
description: 'C++ library for parsing Avro data',
117+
url: 'https://avro.apache.org/',
118+
requires: avro_requires,
119+
)
120+
121+
# Check first if tests should be built
122+
boost_dep = dependency(
123+
'boost',
124+
modules: ['test'],
125+
required: get_option('tests'),
126+
)
127+
tests_enabled = boost_dep.found()
128+
129+
# Emulate enabled_if since Meson 1.1.0 is still too new
130+
avrogencpp_enabled = get_option('avrogencpp').enabled() or (
131+
tests_enabled
132+
and get_option(
133+
'avrogencpp',
134+
).auto()
135+
)
136+
if tests_enabled and not avrogencpp_enabled
137+
error('Tests require avrogencpp')
138+
endif
139+
140+
if avrogencpp_enabled
141+
avrogencpp_exe = executable(
142+
'avrogencpp',
143+
sources: ['impl/avrogencpp.cc'],
144+
cpp_args: ['-DAVRO_VERSION="@0@"'.format(meson.project_version())],
145+
dependencies: avro_dep,
146+
override_options: override_cpp,
147+
install: true,
148+
install_tag: 'devel',
149+
)
150+
meson.override_find_program('avrogencpp', avrogencpp_exe)
151+
endif
152+
153+
if tests_enabled
154+
# TODO: avrogencpp jsonschema tests
155+
156+
unittests = [
157+
'buffertest',
158+
'CodecTests',
159+
'CommonsSchemasTests',
160+
'CompilerTests',
161+
'DataFileTests',
162+
'JsonTests',
163+
'LargeSchemaTests',
164+
'SchemaTests',
165+
'SpecificTests',
166+
'StreamTests',
167+
'unittest',
168+
]
169+
foreach unittest : unittests
170+
test_exe = executable(
171+
unittest,
172+
sources: 'test/@0@.cc'.format(unittest),
173+
dependencies: [avro_dep, boost_dep],
174+
override_options: override_cpp,
175+
build_by_default: false,
176+
)
177+
test(
178+
unittest,
179+
test_exe,
180+
workdir: meson.current_source_dir(),
181+
)
182+
endforeach
183+
endif
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
option(
2+
'avrogencpp',
3+
type: 'feature',
4+
value: 'auto',
5+
description: 'Build avrogencpp exectuable',
6+
)
7+
option(
8+
'tests',
9+
type: 'feature',
10+
value: 'auto',
11+
description: 'Build tests (requires avrogencpp)',
12+
)

0 commit comments

Comments
 (0)