mirror of
https://github.com/json-c/json-c.git
synced 2026-09-07 08:36:50 +08:00
Merge pull request #948 from thesamesam/meson
meson: wire up `disable_extra_libs` option
This commit is contained in:
@@ -75,6 +75,9 @@ library version. Generally, unless we're doing a major release, change:
|
|||||||
to
|
to
|
||||||
VERSION x.y+1.z
|
VERSION x.y+1.z
|
||||||
|
|
||||||
|
Update the version in meson.build (both at the top, and down under
|
||||||
|
'# Build library')
|
||||||
|
|
||||||
git commit -a -m "Bump version to ${release}"
|
git commit -a -m "Bump version to ${release}"
|
||||||
|
|
||||||
If we're doing a major release (SONAME bump), also bump the version
|
If we're doing a major release (SONAME bump), also bump the version
|
||||||
|
|||||||
+49
-42
@@ -1,5 +1,5 @@
|
|||||||
|
|
||||||
project('json-c', 'c', version: '0.18.99',
|
project('json-c', 'c', version: '0.19.99',
|
||||||
meson_version: '>=0.54.0',
|
meson_version: '>=0.54.0',
|
||||||
license: 'MIT',
|
license: 'MIT',
|
||||||
default_options: ['buildtype=release', 'warning_level=2'])
|
default_options: ['buildtype=release', 'warning_level=2'])
|
||||||
@@ -11,6 +11,8 @@ conf_data = configuration_data()
|
|||||||
jconf_data = configuration_data()
|
jconf_data = configuration_data()
|
||||||
conf_data.set('VERSION', meson.project_version())
|
conf_data.set('VERSION', meson.project_version())
|
||||||
|
|
||||||
|
libjson_deps = []
|
||||||
|
|
||||||
has_std_lib = cc.has_header('stdlib.h')
|
has_std_lib = cc.has_header('stdlib.h')
|
||||||
has_std_arg = cc.has_header('stdarg.h')
|
has_std_arg = cc.has_header('stdarg.h')
|
||||||
has_string = cc.has_header('string.h')
|
has_string = cc.has_header('string.h')
|
||||||
@@ -20,10 +22,8 @@ if has_std_lib and has_std_arg and has_string and has_float
|
|||||||
conf_data.set('STDC_HEADERS', 1, description : 'Define to 1 if you have the ANSI C header files.')
|
conf_data.set('STDC_HEADERS', 1, description : 'Define to 1 if you have the ANSI C header files.')
|
||||||
endif
|
endif
|
||||||
|
|
||||||
bsd_dep = dependency('libbsd', required: false)
|
|
||||||
|
|
||||||
headers = {
|
headers = {
|
||||||
'bsd/stdlib.h': bsd_dep,
|
'bsd/stdlib.h': [],
|
||||||
'dlfcn.h': [],
|
'dlfcn.h': [],
|
||||||
'endian.h': [],
|
'endian.h': [],
|
||||||
'fcntl.h': [],
|
'fcntl.h': [],
|
||||||
@@ -63,30 +63,44 @@ if cc.has_header('stdint.h')
|
|||||||
jconf_data.set('JSON_C_HAVE_STDINT_H', 1, description : 'Define to 1 if you have the <stdint.h> header file.')
|
jconf_data.set('JSON_C_HAVE_STDINT_H', 1, description : 'Define to 1 if you have the <stdint.h> header file.')
|
||||||
endif
|
endif
|
||||||
|
|
||||||
funcs = [
|
bsd_dep = []
|
||||||
'open',
|
if get_option('extra_libs')
|
||||||
'realloc',
|
_bsd_dep = dependency('libbsd', required: false)
|
||||||
'setlocale',
|
if _bsd_dep.found()
|
||||||
'strdup',
|
bsd_dep = [ _bsd_dep ]
|
||||||
'strerror',
|
endif
|
||||||
'uselocale',
|
|
||||||
'duplocale',
|
|
||||||
'vsyslog',
|
|
||||||
'getrandom',
|
|
||||||
'getrusage',
|
|
||||||
'strtoll',
|
|
||||||
'strtoull',
|
|
||||||
'arc4random',
|
|
||||||
'vasprintf',
|
|
||||||
]
|
|
||||||
|
|
||||||
if conf_data.has('HAVE_STRINGS_H')
|
|
||||||
funcs += ['strcasecmp', 'strncasecmp']
|
|
||||||
endif
|
endif
|
||||||
|
|
||||||
foreach f : funcs
|
funcs = {
|
||||||
|
'arc4random': bsd_dep,
|
||||||
|
'open': [],
|
||||||
|
'realloc': [],
|
||||||
|
'setlocale': [],
|
||||||
|
'strdup': [],
|
||||||
|
'strerror': [],
|
||||||
|
'uselocale': [],
|
||||||
|
'duplocale': [],
|
||||||
|
'vsyslog': [],
|
||||||
|
'getrandom': [],
|
||||||
|
'getrusage': [],
|
||||||
|
'strtoll': [],
|
||||||
|
'strtoull': [],
|
||||||
|
'vasprintf': [],
|
||||||
|
}
|
||||||
|
|
||||||
|
if conf_data.has('HAVE_STRINGS_H')
|
||||||
|
funcs += {'strcasecmp': [], 'strncasecmp': []}
|
||||||
|
endif
|
||||||
|
|
||||||
|
|
||||||
|
foreach f, d : funcs
|
||||||
if cc.has_function(f)
|
if cc.has_function(f)
|
||||||
conf_data.set('HAVE_@0@'.format(f.to_upper()), 1, description : 'Define to 1 if you have the `@0@` function.'.format(f))
|
conf_data.set('HAVE_@0@'.format(f.to_upper()), 1, description : 'Define to 1 if you have the `@0@` function.'.format(f))
|
||||||
|
else
|
||||||
|
if d.length() > 0 and cc.has_function(f, dependencies: d)
|
||||||
|
conf_data.set('HAVE_@0@'.format(f.to_upper()), 1, description : 'Define to 1 if you have the `@0@` function.'.format(f))
|
||||||
|
libjson_deps += d
|
||||||
|
endif
|
||||||
endif
|
endif
|
||||||
endforeach
|
endforeach
|
||||||
|
|
||||||
@@ -251,14 +265,18 @@ endif
|
|||||||
# Include directories
|
# Include directories
|
||||||
inc = include_directories('.')
|
inc = include_directories('.')
|
||||||
|
|
||||||
|
# Math library (needed for INFINITY, isnan, etc.)
|
||||||
|
m_dep = cc.find_library('m', required: false)
|
||||||
|
libjson_deps += [m_dep]
|
||||||
|
|
||||||
# Build library
|
# Build library
|
||||||
libjson = library('json-c',
|
libjson = library('json-c',
|
||||||
sources,
|
sources,
|
||||||
include_directories: inc,
|
include_directories: inc,
|
||||||
dependencies: bsd_dep,
|
dependencies: libjson_deps,
|
||||||
install: true,
|
install: true,
|
||||||
link_args: sym,
|
link_args: sym,
|
||||||
version: '5.4.0',
|
version: '5.5.0',
|
||||||
soversion: '5',
|
soversion: '5',
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -283,19 +301,11 @@ endif
|
|||||||
install_headers(installed_headers, subdir: 'json-c')
|
install_headers(installed_headers, subdir: 'json-c')
|
||||||
|
|
||||||
# pkg-config file
|
# pkg-config file
|
||||||
configure_file(
|
pkg = import('pkgconfig')
|
||||||
input: 'json-c.pc.in',
|
pkg.generate(
|
||||||
output: 'json-c.pc',
|
libjson,
|
||||||
install: true,
|
description: 'A JSON implementation in C',
|
||||||
install_dir: get_option('libdir') / 'pkgconfig',
|
subdirs: 'json-c',
|
||||||
configuration: {
|
|
||||||
'prefix': get_option('prefix'),
|
|
||||||
'exec_prefix': get_option('prefix'),
|
|
||||||
'libdir': get_option('libdir'),
|
|
||||||
'includedir': get_option('includedir'),
|
|
||||||
'VERSION': meson.project_version(),
|
|
||||||
'LIBS': '',
|
|
||||||
}
|
|
||||||
)
|
)
|
||||||
|
|
||||||
# Optional apps
|
# Optional apps
|
||||||
@@ -303,7 +313,4 @@ if get_option('build_apps') and host_machine.system() != 'windows'
|
|||||||
subdir('apps')
|
subdir('apps')
|
||||||
endif
|
endif
|
||||||
|
|
||||||
# Optional tests
|
|
||||||
if get_option('buildtype') == 'debug'
|
|
||||||
subdir('tests')
|
subdir('tests')
|
||||||
endif
|
|
||||||
|
|||||||
+1
-1
@@ -4,7 +4,7 @@ option('disable_thread_local_storage', type: 'boolean', value: false, descriptio
|
|||||||
option('enable_rdrand', type: 'boolean', value: false, description: 'Enable RDRAND Hardware RNG')
|
option('enable_rdrand', type: 'boolean', value: false, description: 'Enable RDRAND Hardware RNG')
|
||||||
option('enable_threading', type: 'boolean', value: false, description: 'Enable partial threading support')
|
option('enable_threading', type: 'boolean', value: false, description: 'Enable partial threading support')
|
||||||
option('override_get_random_seed', type: 'boolean', value: false, description: 'Override json_c_get_random_seed()')
|
option('override_get_random_seed', type: 'boolean', value: false, description: 'Override json_c_get_random_seed()')
|
||||||
option('disable_extra_libs', type: 'boolean', value: false, description: 'Avoid linking extra libraries like libbsd')
|
option('extra_libs', type: 'boolean', value: true, description: 'Allow linking extra libraries like libbsd')
|
||||||
option('disable_json_pointer', type: 'boolean', value: false, description: 'Disable JSON pointer support')
|
option('disable_json_pointer', type: 'boolean', value: false, description: 'Disable JSON pointer support')
|
||||||
option('disable_json_patch', type: 'boolean', value: false, description: 'Disable JSON patch support')
|
option('disable_json_patch', type: 'boolean', value: false, description: 'Disable JSON patch support')
|
||||||
option('newlocale_needs_freelocale', type: 'boolean', value: false, description: 'FreeBSD workaround for newlocale')
|
option('newlocale_needs_freelocale', type: 'boolean', value: false, description: 'FreeBSD workaround for newlocale')
|
||||||
|
|||||||
+3
-1
@@ -4,6 +4,7 @@ test_lib = static_library(
|
|||||||
objects: libjson.extract_all_objects(
|
objects: libjson.extract_all_objects(
|
||||||
recursive: false,
|
recursive: false,
|
||||||
),
|
),
|
||||||
|
build_by_default: false,
|
||||||
install: false,
|
install: false,
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -65,7 +66,8 @@ foreach t : test_cases
|
|||||||
name = t[0]
|
name = t[0]
|
||||||
expected = t[1]
|
expected = t[1]
|
||||||
exe = executable(name, name + '.c',
|
exe = executable(name, name + '.c',
|
||||||
dependencies: test_deps
|
dependencies: test_deps,
|
||||||
|
build_by_default: false
|
||||||
)
|
)
|
||||||
|
|
||||||
test(name, exe,
|
test(name, exe,
|
||||||
|
|||||||
Reference in New Issue
Block a user