[json-glib] Update the Meson build
- From: Emmanuele Bassi <ebassi src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [json-glib] Update the Meson build
- Date: Mon, 13 Mar 2017 12:31:32 +0000 (UTC)
commit 629681dfb80cd5c5688cb05cc21a0174d5660949
Author: Emmanuele Bassi <ebassi gnome org>
Date: Mon Mar 13 11:49:05 2017 +0000
Update the Meson build
Clean up the coding style, and make it a bit more idiomatic.
https://bugzilla.gnome.org/show_bug.cgi?id=773603
json-glib/meson.build | 110 ++++++++++++++++++++++---------------------
json-glib/tests/meson.build | 25 ++++++----
meson.build | 16 +++---
3 files changed, 78 insertions(+), 73 deletions(-)
---
diff --git a/json-glib/meson.build b/json-glib/meson.build
index 1857354..87a40c8 100644
--- a/json-glib/meson.build
+++ b/json-glib/meson.build
@@ -1,6 +1,8 @@
install_header_subdir = 'json-glib-1.0/json-glib'
install_header_dir = join_paths(get_option('includedir'), install_header_subdir)
+configure_file(output: 'config.h', configuration: cdata)
+
source_h = [
'json-builder.h',
'json-generator.h',
@@ -15,11 +17,11 @@ source_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)
+ 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)
source_c = [
'json-array.c',
@@ -47,66 +49,66 @@ version_data.set('JSON_MICRO_VERSION', json_version_micro)
version_data.set('JSON_VERSION', meson.project_version())
version_h = configure_file(input: 'json-version.h.in',
- output: 'json-version.h',
- install_dir: install_header_dir,
- configuration: version_data)
+ output: 'json-version.h',
+ install_dir: install_header_dir,
+ configuration: version_data)
install_headers(source_h, subdir: install_header_subdir)
localedir = join_paths(get_option('prefix'), get_option('localedir'))
-json_c_args = ['-DJSON_COMPILATION', '-DG_LOG_DOMAIN="Json"', '-DJSON_LOCALEDIR="@0@"'.format(localedir)]
+json_c_args = [
+ '-DJSON_COMPILATION',
+ '-DG_LOG_DOMAIN="Json"',
+ '-DJSON_LOCALEDIR="@0@"'.format(localedir)
+]
json_lib = library('json-glib-1.0',
- source_c,
- version: libversion,
- soversion: soversion,
- include_directories: root_dir,
- dependencies: [gio_dep, gobject_dep],
- c_args: json_c_args + extra_args,
- install: true,
-)
+ source_c,
+ version: libversion,
+ soversion: soversion,
+ include_directories: root_dir,
+ dependencies: [ gio_dep, gobject_dep, ],
+ c_args: json_c_args + extra_args,
+ install: true)
pkgg = import('pkgconfig')
-pkgg.generate(
- libraries: [json_lib],
- subdirs: '.',
- version: json_version,
- name: 'JSON-GLib',
- filebase: 'json-glib-@0@'.format(apiversion),
- description: 'JSON Parser for GLib.',
- requires: 'glib-2.0 gio-2.0'
-)
-
-json_gen_sources = [json_glib_enums, version_h]
+pkgg.generate(libraries: [ json_lib ],
+ subdirs: '.',
+ version: json_version,
+ name: 'JSON-GLib',
+ filebase: 'json-glib-@0@'.format(apiversion),
+ description: 'JSON Parser for GLib.',
+ requires: 'glib-2.0 gio-2.0')
+
+json_gen_sources = [ json_glib_enums, version_h ]
if build_gir
- json_gen_sources += [gnome.generate_gir(json_lib,
- sources: source_c + source_h,
- namespace: 'Json',
- nsversion: apiversion,
- identifier_prefix: 'Json',
- symbol_prefix: 'json',
- export_packages: 'json-glib-1.0',
- includes: ['GObject-2.0', 'Gio-2.0' ],
- install: true,
- extra_args: ['-DJSON_COMPILATION'],
- )]
+ json_gen_sources += gnome.generate_gir(json_lib,
+ sources: source_c + source_h,
+ namespace: 'Json',
+ nsversion: apiversion,
+ identifier_prefix: 'Json',
+ symbol_prefix: 'json',
+ export_packages: 'json-glib-1.0',
+ includes: [ 'GObject-2.0', 'Gio-2.0', ],
+ install: true,
+ extra_args: ['-DJSON_COMPILATION'])
endif
json_glib_dep = declare_dependency(link_with: json_lib,
- include_directories: root_dir,
- dependencies: [gobject_dep, gio_dep],
- # Everything that uses libjson needs this built to compile
- sources: json_gen_sources,
-)
-
-json_glib_validate = executable('json-glib-validate',
- 'json-glib-validate.c',
- c_args: json_c_args,
- dependencies: json_glib_dep)
-
-json_glib_format = executable('json-glib-format',
- 'json-glib-format.c',
- c_args: json_c_args,
- dependencies: json_glib_dep)
+ include_directories: root_dir,
+ dependencies: [ gobject_dep, gio_dep, ],
+ sources: json_gen_sources)
+
+tools = [
+ [ 'json-glib-validate', [ 'json-glib-validate.c', ] ],
+ [ 'json-glib-format', [ 'json-glib-format.c', ] ],
+]
+
+foreach t: tools
+ bin_name = t[0]
+ bin_sources = t[1]
+
+ executable(bin_name, bin_sources, c_args: json_c_args, dependencies: json_glib_dep)
+endforeach
subdir('tests')
diff --git a/json-glib/tests/meson.build b/json-glib/tests/meson.build
index eb0c304..9cab4bc 100644
--- a/json-glib/tests/meson.build
+++ b/json-glib/tests/meson.build
@@ -17,18 +17,21 @@ tests = [
python3 = find_program('python3')
-cp = run_command(python3, '-c',
- 'from shutil import copyfile; copyfile("@0@", "@1@")'.format(
- 'stream-load.json',
- meson.current_build_dir() + '/stream-load.json'))
+test_data = [
+ 'stream-load.json',
+]
-if cp.returncode() != 0
- error('Could not copy file: ' + cp.stderr())
-endif
+foreach d: test_data
+ copy = 'from shutil import copyfile; copyfile("@0@", "@1@")'.format(d,
join_paths(meson.current_build_dir(), d))
+ cp = run_command(python3, '-c', copy)
+ if cp.returncode() != 0
+ error('Could not copy file: ' + cp.stderr())
+ endif
+endforeach
foreach t: tests
- exe = executable(t, '@0@.c'.format(t),
- c_args: json_c_args,
- dependencies: [json_glib_dep],)
- test(t, exe)
+ exe = executable(t, '@0@.c'.format(t),
+ c_args: json_c_args,
+ dependencies: [ json_glib_dep, ])
+ test(t, exe)
endforeach
diff --git a/meson.build b/meson.build
index 9437eb9..a2cdcb2 100644
--- a/meson.build
+++ b/meson.build
@@ -1,8 +1,10 @@
-project('json-glib', 'c',
- version: '1.2.3',
- meson_version: '>= 0.37.1',
- default_options: [ 'warning_level=1',
- 'buildtype=debugoptimized' ])
+project('json-glib', 'c', version: '1.2.3',
+ license: 'LGPLv2.1+',
+ default_options: [
+ 'warning_level=1',
+ 'buildtype=debugoptimized',
+ ],
+ meson_version: '>= 0.37.1')
# Versionning
@@ -60,13 +62,11 @@ if get_option('default_library') != 'static'
extra_args += ['-fvisibility=hidden']
endif
else
- cdata.set('_JSON_EXTERN', '__attribute__((visibility("default")))')
+ cdata.set('_JSON_EXTERN', '__attribute__((visibility("default"))) extern')
extra_args += ['-fvisibility=hidden']
endif
endif
-configure_file(output: 'config.h', configuration: cdata)
-
root_dir = include_directories('.')
gnome = import('gnome')
gir = find_program('g-ir-scanner', required: false)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]