summaryrefslogtreecommitdiff
path: root/json-glib
diff options
context:
space:
mode:
authorThibault Saunier <thibault.saunier@osg.samsung.com>2016-10-27 15:21:23 -0300
committerEmmanuele Bassi <ebassi@gnome.org>2017-03-13 12:29:20 +0000
commit234ae8108f551a1a580a67b14c8823300ec25983 (patch)
tree4076bc59d7d8491a8d24ad4f63519ae4fd7b468f /json-glib
parente6ee5b974d7e1530818229b4b9da20ea3dfec91c (diff)
downloadjson-glib-234ae8108f551a1a580a67b14c8823300ec25983.tar.gz
meson: Add support for building with the meson build system
https://bugzilla.gnome.org/show_bug.cgi?id=773603
Diffstat (limited to 'json-glib')
-rw-r--r--json-glib/json-enum-types.c.in4
-rw-r--r--json-glib/meson.build112
-rw-r--r--json-glib/tests/meson.build34
3 files changed, 150 insertions, 0 deletions
diff --git a/json-glib/json-enum-types.c.in b/json-glib/json-enum-types.c.in
index a2a13b4..da07c46 100644
--- a/json-glib/json-enum-types.c.in
+++ b/json-glib/json-enum-types.c.in
@@ -1,4 +1,8 @@
/*** BEGIN file-header ***/
+#ifndef JSON_COMPILATION
+#define JSON_COMPILATION
+#endif
+
#include "config.h"
#include "json-enum-types.h"
/*** END file-header ***/
diff --git a/json-glib/meson.build b/json-glib/meson.build
new file mode 100644
index 0000000..1857354
--- /dev/null
+++ b/json-glib/meson.build
@@ -0,0 +1,112 @@
+install_header_subdir = 'json-glib-1.0/json-glib'
+install_header_dir = join_paths(get_option('includedir'), install_header_subdir)
+
+source_h = [
+ 'json-builder.h',
+ 'json-generator.h',
+ 'json-gobject.h',
+ 'json-gvariant.h',
+ 'json-parser.h',
+ 'json-path.h',
+ 'json-reader.h',
+ 'json-types.h',
+ 'json-utils.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)
+
+source_c = [
+ 'json-array.c',
+ 'json-builder.c',
+ 'json-debug.c',
+ 'json-gboxed.c',
+ 'json-generator.c',
+ 'json-gobject.c',
+ 'json-gvariant.c',
+ 'json-node.c',
+ 'json-object.c',
+ 'json-parser.c',
+ 'json-path.c',
+ 'json-reader.c',
+ 'json-scanner.c',
+ 'json-serializable.c',
+ 'json-utils.c',
+ 'json-value.c',
+]
+
+version_data = configuration_data()
+version_data.set('JSON_MAJOR_VERSION', json_version_major)
+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())
+
+version_h = configure_file(input: 'json-version.h.in',
+ 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_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,
+)
+
+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]
+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'],
+ )]
+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)
+
+subdir('tests')
diff --git a/json-glib/tests/meson.build b/json-glib/tests/meson.build
new file mode 100644
index 0000000..eb0c304
--- /dev/null
+++ b/json-glib/tests/meson.build
@@ -0,0 +1,34 @@
+tests = [
+ 'array',
+ 'boxed',
+ 'builder',
+ 'generator',
+ 'gvariant',
+ 'invalid',
+ 'node',
+ 'object',
+ 'parser',
+ 'path',
+ 'reader',
+ 'serialize-simple',
+ 'serialize-complex',
+ 'serialize-full',
+]
+
+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'))
+
+if cp.returncode() != 0
+ error('Could not copy file: ' + cp.stderr())
+endif
+
+foreach t: tests
+ exe = executable(t, '@0@.c'.format(t),
+ c_args: json_c_args,
+ dependencies: [json_glib_dep],)
+ test(t, exe)
+endforeach