Skip to content

Commit b414921

Browse files
committed
libcbor: add 0.13.0
1 parent 29928d3 commit b414921

File tree

8 files changed

+244
-0
lines changed

8 files changed

+244
-0
lines changed

ci_config.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -610,6 +610,11 @@
610610
"libattr1-dev"
611611
]
612612
},
613+
"libcbor": {
614+
"build_options": [
615+
"libcbor:tests=enabled"
616+
]
617+
},
613618
"libdrm": {
614619
"_comment": "- relies on Linux and BSD specific APIs",
615620
"build_on": {

releases.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1874,6 +1874,14 @@
18741874
"2.76-1"
18751875
]
18761876
},
1877+
"libcbor": {
1878+
"dependency_names": [
1879+
"libcbor"
1880+
],
1881+
"versions": [
1882+
"0.13.0-1"
1883+
]
1884+
},
18771885
"libccp4c": {
18781886
"dependency_names": [
18791887
"libccp4c"

subprojects/libcbor.wrap

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
[wrap-file]
2+
directory = libcbor-0.13.0
3+
source_url = https://github.com/PJK/libcbor/archive/refs/tags/v0.13.0.tar.gz
4+
source_filename = libcbor-0.13.0.tar.gz
5+
source_hash = 95a7f0dd333fd1dce3e4f92691ca8be38227b27887599b21cd3c4f6d6a7abb10
6+
patch_directory = libcbor
7+
8+
[provide]
9+
dependency_names = libcbor
Lines changed: 157 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,157 @@
1+
project(
2+
'libcbor',
3+
'c',
4+
version: '0.13.0',
5+
meson_version: '>=0.63.0',
6+
default_options: ['warning_level=3'],
7+
license: 'MIT',
8+
)
9+
10+
cc = meson.get_compiler('c')
11+
12+
tests_opt = get_option('tests').disable_auto_if(meson.is_subproject())
13+
14+
subdir('src/cbor')
15+
16+
src = [
17+
'src/cbor.c',
18+
'src/allocators.c',
19+
'src/cbor/streaming.c',
20+
'src/cbor/internal/encoders.c',
21+
'src/cbor/internal/builder_callbacks.c',
22+
'src/cbor/internal/loaders.c',
23+
'src/cbor/internal/memory_utils.c',
24+
'src/cbor/internal/stack.c',
25+
'src/cbor/internal/unicode.c',
26+
'src/cbor/encoding.c',
27+
'src/cbor/serialization.c',
28+
'src/cbor/arrays.c',
29+
'src/cbor/common.c',
30+
'src/cbor/floats_ctrls.c',
31+
'src/cbor/bytestrings.c',
32+
'src/cbor/callbacks.c',
33+
'src/cbor/strings.c',
34+
'src/cbor/maps.c',
35+
'src/cbor/tags.c',
36+
'src/cbor/ints.c',
37+
]
38+
39+
inc = include_directories('src')
40+
41+
c_args = ['-DCBOR_BUILD=1']
42+
43+
if get_option('default_library') == 'static'
44+
c_args += ['-DCBOR_BUILD_STATIC=1']
45+
endif
46+
47+
libcbor = library(
48+
'cbor',
49+
src,
50+
config_file,
51+
c_args: c_args,
52+
include_directories: inc,
53+
install: true,
54+
version: meson.project_version(),
55+
override_options: ['c_std=c11'],
56+
)
57+
58+
libcbor_dep = declare_dependency(
59+
link_with: libcbor,
60+
include_directories: inc,
61+
)
62+
63+
meson.override_dependency('libcbor', libcbor_dep)
64+
65+
headers = [
66+
config_file,
67+
'src/cbor/streaming.h',
68+
'src/cbor/cbor_export.h',
69+
'src/cbor/data.h',
70+
'src/cbor/encoding.h',
71+
'src/cbor/serialization.h',
72+
'src/cbor/arrays.h',
73+
'src/cbor/common.h',
74+
'src/cbor/floats_ctrls.h',
75+
'src/cbor/bytestrings.h',
76+
'src/cbor/callbacks.h',
77+
'src/cbor/strings.h',
78+
'src/cbor/maps.h',
79+
'src/cbor/tags.h',
80+
'src/cbor/ints.h',
81+
]
82+
83+
install_headers('src/cbor.h')
84+
install_headers(
85+
headers,
86+
subdir: 'cbor',
87+
)
88+
89+
tests = [
90+
'test/array_encoders_test.c',
91+
'test/array_test.c',
92+
'test/bad_inputs_test.c',
93+
'test/bytestring_encoders_test.c',
94+
'test/bytestring_test.c',
95+
'test/cbor_serialize_test.c',
96+
'test/cbor_stream_decode_test.c',
97+
'test/copy_test.c',
98+
'test/fuzz_test.c',
99+
'test/map_encoders_test.c',
100+
'test/map_test.c',
101+
'test/negint_encoders_test.c',
102+
'test/negint_test.c',
103+
'test/pretty_printer_test.c',
104+
'test/stack_over_limit_test.c',
105+
'test/string_encoders_test.c',
106+
'test/string_test.c',
107+
'test/tag_encoders_test.c',
108+
'test/tag_test.c',
109+
'test/uint_encoders_test.c',
110+
'test/uint_test.c',
111+
]
112+
113+
if host_machine.system() != 'windows'
114+
tests += ['test/callbacks_test.c', 'test/memory_utils_test.c', 'test/unicode_test.c']
115+
endif
116+
117+
if cc.get_id() != 'clang-cl'
118+
tests += ['test/float_ctrl_encoders_test.c', 'test/float_ctrl_test.c']
119+
endif
120+
121+
cmocka = dependency(
122+
'cmocka',
123+
required: tests_opt,
124+
)
125+
m = cc.find_library(
126+
'm',
127+
required: false,
128+
)
129+
130+
if cmocka.found() and tests_opt.allowed()
131+
libcbor_test = static_library(
132+
'cbor_test',
133+
['test/assertions.c', 'test/stream_expectations.c', 'test/test_allocator.c'],
134+
include_directories: inc,
135+
dependencies: [libcbor_dep, cmocka, m],
136+
c_args: c_args,
137+
)
138+
139+
foreach path : tests
140+
name = path.split('/')[1].replace('.c', '')
141+
test_exe = executable(
142+
name,
143+
path,
144+
include_directories: inc,
145+
link_with: libcbor_test,
146+
dependencies: [libcbor_dep, cmocka, m],
147+
override_options: ['c_std=c11'],
148+
)
149+
150+
test(
151+
name,
152+
test_exe,
153+
suite: 'libcbor',
154+
should_fail: false,
155+
)
156+
endforeach
157+
endif
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
option(
2+
'tests',
3+
type: 'feature',
4+
description: 'Build libcbor tests',
5+
)
6+
7+
option(
8+
'buffer_growth',
9+
type: 'integer',
10+
description: 'Growth factor for buffer resizing',
11+
value: 2,
12+
)
13+
14+
option(
15+
'max_stack_size',
16+
type: 'integer',
17+
description: 'Maximum stack size for nested structures',
18+
value: 2048,
19+
)
20+
21+
option(
22+
'pretty_printer',
23+
type: 'boolean',
24+
description: 'Enable the pretty printer',
25+
value: true,
26+
)
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#ifndef CBOR_EXPORT
2+
# if (defined(__GNUC__) && __GNUC__ >= 4) || defined(__ICC)
3+
# define CBOR_EXPORT __attribute__ ((visibility("default")))
4+
# elif (defined(__SUNPRO_C) || defined(__SUNPRO_CC))
5+
# define CBOR_EXPORT __global
6+
/* Windows is special and you cannot just define entry points unconditionally. */
7+
# elif defined(_WIN32) && !defined(CBOR_BUILD_STATIC)
8+
# ifdef CBOR_BUILD
9+
# define CBOR_EXPORT __declspec(dllexport)
10+
# else
11+
# define CBOR_EXPORT __declspec(dllimport)
12+
# endif
13+
# else
14+
/* nothing else worked, give up and do nothing */
15+
# define CBOR_EXPORT
16+
# endif
17+
#endif
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
version = meson.project_version().split('.')
2+
config = configuration_data()
3+
config.set('CBOR_VERSION_MAJOR', version[0])
4+
config.set('CBOR_VERSION_MINOR', version[1])
5+
config.set('CBOR_VERSION_PATCH', version[2])
6+
config.set('CBOR_BUFFER_GROWTH', get_option('buffer_growth'))
7+
config.set('CBOR_MAX_STACK_SIZE', get_option('max_stack_size'))
8+
config.set('CBOR_PRETTY_PRINTER', get_option('pretty_printer'))
9+
config.set('CBOR_RESTRICT_SPECIFIER', cc.get_id() == 'msvc' ? '' : 'restrict')
10+
config.set('CBOR_INLINE_SPECIFIER', '')
11+
12+
config_file = configure_file(
13+
input: 'configuration.h.in',
14+
output: 'configuration.h',
15+
format: 'cmake',
16+
configuration: config,
17+
install: true,
18+
install_dir: get_option('includedir') / 'cbor',
19+
)

tools/sanity_checks.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,9 @@
7272
'libcap': {
7373
'gen_cap_names.py',
7474
},
75+
'libcbor': {
76+
'cbor_export.h',
77+
},
7578
'libexif': {
7679
'def.py',
7780
},

0 commit comments

Comments
 (0)