summaryrefslogtreecommitdiff
path: root/json-glib
diff options
context:
space:
mode:
authorEmmanuele Bassi <ebassi@gnome.org>2018-03-06 15:59:52 +0700
committerEmmanuele Bassi <ebassi@gnome.org>2018-03-13 11:12:30 +0000
commit542bb05b1be51a76ced5566b3f59fd5e3e58fa03 (patch)
tree36aa7c5d2d1fee5e726b6901196e5320555016df /json-glib
parent450b5d04e505298c3fc9fbe6108469ac2d2fd44d (diff)
downloadjson-glib-542bb05b1be51a76ced5566b3f59fd5e3e58fa03.tar.gz
Refresh the build system
We should use more idiomatic Meson: - improve the coding style - ensure that the `json_glib_dep` dependency object also includes the introspection data, if enabled - add a separate option for the man page generation - ensure that json-glib can be used as a subproject
Diffstat (limited to 'json-glib')
-rw-r--r--json-glib/meson.build107
-rw-r--r--json-glib/tests/meson.build52
2 files changed, 90 insertions, 69 deletions
diff --git a/json-glib/meson.build b/json-glib/meson.build
index 2cc566c..eb1c793 100644
--- a/json-glib/meson.build
+++ b/json-glib/meson.build
@@ -16,12 +16,15 @@ source_h = [
'json-version-macros.h'
]
-json_glib_enums = gnome.mkenums('json-enum-types',
- sources: source_h,
- h_template: 'json-enum-types.h.in',
- c_template: 'json-enum-types.c.in',
- install_header: true,
- install_dir: install_header_dir)
+json_glib_enums = gnome.mkenums(
+ 'json-enum-types',
+ sources: source_h,
+ h_template: 'json-enum-types.h.in',
+ c_template: 'json-enum-types.c.in',
+ install_header: true,
+ install_dir: install_header_dir,
+)
+
# Keep a reference to the generated header, for internal dependencies
json_enum_types_h = json_glib_enums.get(1)
@@ -50,42 +53,47 @@ version_data.set('JSON_MINOR_VERSION', json_version_minor)
version_data.set('JSON_MICRO_VERSION', json_version_micro)
version_data.set('JSON_VERSION', meson.project_version())
-json_version_h = configure_file(input: 'json-version.h.in',
- output: 'json-version.h',
- configuration: version_data,
- install: true,
- install_dir: install_header_dir)
+json_version_h = configure_file(
+ input: 'json-version.h.in',
+ output: 'json-version.h',
+ configuration: version_data,
+ install: true,
+ install_dir: install_header_dir,
+)
install_headers(source_h + [ 'json-glib.h', ], subdir: install_header_subdir)
json_c_args = [
- '-DJSON_COMPILATION',
'-DG_LOG_DOMAIN="Json"',
+ '-DG_LOG_USE_STRUCTURED=1',
+ '-DJSON_COMPILATION',
'-DJSON_LOCALEDIR="@0@"'.format(json_localedir)
]
-json_lib = library(json_api_name,
- source_c + json_glib_enums,
- version: libversion,
- soversion: soversion,
- include_directories: root_dir,
- dependencies: [ gio_dep, gobject_dep, ],
- c_args: json_c_args + common_cflags,
- link_args: common_ldflags,
- install: true)
+json_lib = library(
+ json_api_name,
+ source_c + json_glib_enums,
+ version: libversion,
+ soversion: soversion,
+ include_directories: root_dir,
+ dependencies: [ gio_dep, gobject_dep, ],
+ c_args: json_c_args + common_cflags,
+ link_args: common_ldflags,
+ install: true,
+)
pkgg = import('pkgconfig')
-
-pkgg.generate(libraries: [ json_lib ],
- subdirs: json_api_name,
- version: json_version,
- name: 'JSON-GLib',
- filebase: json_api_name,
- description: 'JSON Parser for GLib.',
- requires: 'gio-2.0')
-
-gir = find_program('g-ir-scanner', required: false)
-build_gir = gir.found() and get_option('introspection')
+pkgg.generate(
+ libraries: json_lib,
+ subdirs: json_api_name,
+ version: json_version,
+ name: 'JSON-GLib',
+ filebase: json_api_name,
+ description: 'JSON Parser for GLib.',
+ requires: 'gio-2.0',
+)
+
+build_gir = get_option('introspection')
if build_gir
gir_args = [
'--quiet',
@@ -93,22 +101,29 @@ if build_gir
'-DJSON_COMPILATION',
]
- gnome.generate_gir(json_lib,
- sources: source_c + source_h + json_glib_enums + [ json_version_h ],
- namespace: 'Json',
- nsversion: json_api_version,
- identifier_prefix: 'Json',
- symbol_prefix: 'json',
- export_packages: json_api_name,
- includes: [ 'GObject-2.0', 'Gio-2.0', ],
- install: true,
- extra_args: gir_args)
+ json_glib_gir = gnome.generate_gir(
+ json_lib,
+ sources: source_c + source_h + json_glib_enums + [ json_version_h ],
+ namespace: 'Json',
+ nsversion: json_api_version,
+ identifier_prefix: 'Json',
+ symbol_prefix: 'json',
+ export_packages: json_api_name,
+ includes: [ 'GObject-2.0', 'Gio-2.0', ],
+ header: 'json-glib/json-glib.h',
+ install: true,
+ extra_args: gir_args,
+ )
+else
+ json_glib_gir = []
endif
-json_glib_dep = declare_dependency(link_with: json_lib,
- include_directories: root_dir,
- dependencies: [ gobject_dep, gio_dep, ],
- sources: [ json_enum_types_h ])
+json_glib_dep = declare_dependency(
+ link_with: json_lib,
+ include_directories: root_dir,
+ dependencies: [ gobject_dep, gio_dep, ],
+ sources: [ json_enum_types_h, json_glib_gir ],
+)
tools = [
[ 'json-glib-validate', [ 'json-glib-validate.c', ] ],
diff --git a/json-glib/tests/meson.build b/json-glib/tests/meson.build
index a80e8ce..881d902 100644
--- a/json-glib/tests/meson.build
+++ b/json-glib/tests/meson.build
@@ -26,29 +26,35 @@ install_data(test_data, install_dir: installed_test_bindir)
foreach t: tests
installed_test = '@0@.test'.format(t)
- data = custom_target(installed_test,
- output: installed_test,
- command: [
- python3,
- gen_installed_test,
- '--testdir=@0@'.format(installed_test_bindir),
- '--testname=@0@'.format(t),
- '--outdir=@OUTDIR@',
- '--outfile=@0@'.format(installed_test),
- ],
- install: true,
- install_dir: installed_test_datadir)
+ data = custom_target(
+ installed_test,
+ output: installed_test,
+ command: [
+ python3,
+ gen_installed_test,
+ '--testdir=@0@'.format(installed_test_bindir),
+ '--testname=@0@'.format(t),
+ '--outdir=@OUTDIR@',
+ '--outfile=@0@'.format(installed_test),
+ ],
+ install: true,
+ install_dir: installed_test_datadir,
+ )
- exe = executable(t, '@0@.c'.format(t),
- c_args: json_c_args,
- install: true,
- install_dir: installed_test_bindir,
- dependencies: [ json_glib_dep, ])
+ exe = executable(
+ t, '@0@.c'.format(t),
+ c_args: json_c_args,
+ install: true,
+ install_dir: installed_test_bindir,
+ dependencies: [ json_glib_dep, ],
+ )
- test(t, exe,
- args: [ '--tap', '-k' ],
- env: [
- 'G_TEST_SRCDIR=@0@'.format(meson.current_source_dir()),
- 'G_TEST_BUILDDIR=@0@'.format(meson.current_build_dir()),
- ])
+ test(
+ t, exe,
+ args: [ '--tap', '-k' ],
+ env: [
+ 'G_TEST_SRCDIR=@0@'.format(meson.current_source_dir()),
+ 'G_TEST_BUILDDIR=@0@'.format(meson.current_build_dir()),
+ ],
+ )
endforeach