Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions ci_config.json
Original file line number Diff line number Diff line change
Expand Up @@ -610,6 +610,11 @@
"libattr1-dev"
]
},
"libcbor": {
"build_options": [
"libcbor:tests=enabled"
]
},
"libdrm": {
"_comment": "- relies on Linux and BSD specific APIs",
"build_on": {
Expand Down
8 changes: 8 additions & 0 deletions releases.json
Original file line number Diff line number Diff line change
Expand Up @@ -1874,6 +1874,14 @@
"2.76-1"
]
},
"libcbor": {
"dependency_names": [
"libcbor"
],
"versions": [
"0.13.0-1"
]
},
"libccp4c": {
"dependency_names": [
"libccp4c"
Expand Down
9 changes: 9 additions & 0 deletions subprojects/libcbor.wrap
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[wrap-file]
directory = libcbor-0.13.0
source_url = https://github.com/PJK/libcbor/archive/refs/tags/v0.13.0.tar.gz
source_filename = libcbor-0.13.0.tar.gz
source_hash = 95a7f0dd333fd1dce3e4f92691ca8be38227b27887599b21cd3c4f6d6a7abb10
patch_directory = libcbor

[provide]
dependency_names = libcbor
161 changes: 161 additions & 0 deletions subprojects/packagefiles/libcbor/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,161 @@
project(
'libcbor',
'c',
version: '0.13.0',
meson_version: '>=0.59.0',

Check notice on line 5 in subprojects/packagefiles/libcbor/meson.build

View workflow job for this annotation

GitHub Actions / Ubuntu (x86_64)

Minimum Meson version is 0.59.0

0.46.0: format arg in configure_file 0.47.0: User option "feature" 0.49.0: / with string arguments 0.50.0: install arg in configure_file 0.54.0: meson.override_dependency 0.58.0: str.replace 0.59.0: feature_option.allowed(), feature_option.disable_auto_if()
default_options: ['warning_level=3'],
license: 'MIT',
)

cc = meson.get_compiler('c')

tests_opt = get_option('tests').disable_auto_if(meson.is_subproject())

subdir('src/cbor')

src = [
'src/cbor.c',
'src/allocators.c',
'src/cbor/streaming.c',
'src/cbor/internal/encoders.c',
'src/cbor/internal/builder_callbacks.c',
'src/cbor/internal/loaders.c',
'src/cbor/internal/memory_utils.c',
'src/cbor/internal/stack.c',
'src/cbor/internal/unicode.c',
'src/cbor/encoding.c',
'src/cbor/serialization.c',
'src/cbor/arrays.c',
'src/cbor/common.c',
'src/cbor/floats_ctrls.c',
'src/cbor/bytestrings.c',
'src/cbor/callbacks.c',
'src/cbor/strings.c',
'src/cbor/maps.c',
'src/cbor/tags.c',
'src/cbor/ints.c',
]

inc = include_directories('src')

c_args = ['-DCBOR_BUILD=1']

if get_option('default_library') == 'static'
c_args += ['-DCBOR_BUILD_STATIC=1']
endif

libcbor = library(
'cbor',
src,
config_file,
c_args: c_args,
include_directories: inc,
install: true,
version: meson.project_version(),
override_options: ['c_std=c11'],
)

libcbor_dep = declare_dependency(
link_with: libcbor,
include_directories: inc,
)

meson.override_dependency('libcbor', libcbor_dep)

headers = [
config_file,
'src/cbor/streaming.h',
'src/cbor/cbor_export.h',
'src/cbor/data.h',
'src/cbor/encoding.h',
'src/cbor/serialization.h',
'src/cbor/arrays.h',
'src/cbor/common.h',
'src/cbor/floats_ctrls.h',
'src/cbor/bytestrings.h',
'src/cbor/callbacks.h',
'src/cbor/strings.h',
'src/cbor/maps.h',
'src/cbor/tags.h',
'src/cbor/ints.h',
]

install_headers('src/cbor.h')
install_headers(
headers,
subdir: 'cbor',
)

tests = [
'test/array_encoders_test.c',
'test/array_test.c',
'test/bad_inputs_test.c',
'test/bytestring_encoders_test.c',
'test/bytestring_test.c',
'test/cbor_serialize_test.c',
'test/cbor_stream_decode_test.c',
'test/copy_test.c',
'test/fuzz_test.c',
'test/map_encoders_test.c',
'test/map_test.c',
'test/negint_encoders_test.c',
'test/negint_test.c',
'test/pretty_printer_test.c',
'test/stack_over_limit_test.c',
'test/string_encoders_test.c',
'test/string_test.c',
'test/tag_encoders_test.c',
'test/tag_test.c',
'test/uint_encoders_test.c',
'test/uint_test.c',
]

if host_machine.system() != 'windows'
tests += [
'test/callbacks_test.c',
'test/memory_utils_test.c',
'test/unicode_test.c',
]
endif

if cc.get_id() != 'clang-cl'
tests += ['test/float_ctrl_encoders_test.c', 'test/float_ctrl_test.c']
endif

cmocka = dependency(
'cmocka',
required: tests_opt,
)
m = cc.find_library(
'm',
required: false,
)

if cmocka.found() and tests_opt.allowed()
libcbor_test = static_library(
'cbor_test',
['test/assertions.c', 'test/stream_expectations.c', 'test/test_allocator.c'],
include_directories: inc,
dependencies: [libcbor_dep, cmocka, m],
c_args: c_args,
)

foreach path : tests
name = path.split('/')[1].replace('.c', '')
test_exe = executable(
name,
path,
include_directories: inc,
link_with: libcbor_test,
dependencies: [libcbor_dep, cmocka, m],
override_options: ['c_std=c11'],
)

test(
name,
test_exe,
suite: 'libcbor',
should_fail: false,
)
endforeach
endif
26 changes: 26 additions & 0 deletions subprojects/packagefiles/libcbor/meson_options.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
option(
'tests',
type: 'feature',
description: 'Build libcbor tests',
)

option(
'buffer_growth',
type: 'integer',
description: 'Growth factor for buffer resizing',
value: 2,
)

option(
'max_stack_size',
type: 'integer',
description: 'Maximum stack size for nested structures',
value: 2048,
)

option(
'pretty_printer',
type: 'boolean',
description: 'Enable the pretty printer',
value: true,
)
17 changes: 17 additions & 0 deletions subprojects/packagefiles/libcbor/src/cbor/cbor_export.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#ifndef CBOR_EXPORT
# if (defined(__GNUC__) && __GNUC__ >= 4) || defined(__ICC)
# define CBOR_EXPORT __attribute__ ((visibility("default")))
# elif (defined(__SUNPRO_C) || defined(__SUNPRO_CC))
# define CBOR_EXPORT __global
/* Windows is special and you cannot just define entry points unconditionally. */
# elif defined(_WIN32) && !defined(CBOR_BUILD_STATIC)
# ifdef CBOR_BUILD
# define CBOR_EXPORT __declspec(dllexport)
# else
# define CBOR_EXPORT __declspec(dllimport)
# endif
# else
/* nothing else worked, give up and do nothing */
# define CBOR_EXPORT
# endif
#endif
19 changes: 19 additions & 0 deletions subprojects/packagefiles/libcbor/src/cbor/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
version = meson.project_version().split('.')
config = configuration_data()
config.set('CBOR_VERSION_MAJOR', version[0])
config.set('CBOR_VERSION_MINOR', version[1])
config.set('CBOR_VERSION_PATCH', version[2])
config.set('CBOR_BUFFER_GROWTH', get_option('buffer_growth'))
config.set('CBOR_MAX_STACK_SIZE', get_option('max_stack_size'))
config.set('CBOR_PRETTY_PRINTER', get_option('pretty_printer'))
config.set('CBOR_RESTRICT_SPECIFIER', cc.get_id() == 'msvc' ? '' : 'restrict')
config.set('CBOR_INLINE_SPECIFIER', '')

config_file = configure_file(
input: 'configuration.h.in',
output: 'configuration.h',
format: 'cmake',
configuration: config,
install: true,
install_dir: get_option('includedir') / 'cbor',
)
3 changes: 3 additions & 0 deletions tools/sanity_checks.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,9 @@
'libcap': {
'gen_cap_names.py',
},
'libcbor': {
'cbor_export.h',
},
'libexif': {
'def.py',
},
Expand Down
Loading