summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNiels De Graef <nielsdegraef@gmail.com>2019-05-08 08:27:38 +0200
committerNiels De Graef <nielsdegraef@gmail.com>2019-05-10 21:12:24 +0200
commitc1b6eec459be77a263087c5ce37c208ab05d4f55 (patch)
tree0ef8c8383e8c1ce4a5c39723214dab6479febbd4
parent790cbf061cc169ea71cc45c5fae57673c49dd97a (diff)
downloadlibrest-c1b6eec459be77a263087c5ce37c208ab05d4f55.tar.gz
Port to the Meson build system
See the [Meson website] for a full reference. To build, test and/or install the librest library, you essentially need the following commands: ``` $ meson build $ ninja -C build $ meson test -C build $ ninja -C build install ``` For the GNOME initiative, see https://wiki.gnome.org/Initiatives/GnomeGoals/MesonPorting [Meson website]: http://mesonbuild.com/ https://gitlab.gnome.org/GNOME/librest/merge_requests/1
-rw-r--r--docs/meson.build1
-rw-r--r--docs/reference/rest/meson.build26
-rw-r--r--examples/meson.build25
-rw-r--r--meson.build90
-rw-r--r--meson_options.txt25
-rw-r--r--rest-extras/meson.build73
-rw-r--r--rest/meson.build107
-rw-r--r--tests/meson.build37
8 files changed, 384 insertions, 0 deletions
diff --git a/docs/meson.build b/docs/meson.build
new file mode 100644
index 0000000..164cf27
--- /dev/null
+++ b/docs/meson.build
@@ -0,0 +1 @@
+subdir('reference/rest')
diff --git a/docs/reference/rest/meson.build b/docs/reference/rest/meson.build
new file mode 100644
index 0000000..d02adf3
--- /dev/null
+++ b/docs/reference/rest/meson.build
@@ -0,0 +1,26 @@
+gnome.gtkdoc('rest',
+ src_dir: [
+ include_directories('../../../rest'),
+ include_directories('../../../rest-extras'),
+ ],
+ main_xml: 'rest-docs.xml',
+ module_version: librest_api_version,
+ dependencies: [
+ librest_deps,
+ librest_dep,
+ librest_extras_dep,
+ librest_extras_deps,
+ ],
+ scan_args: [
+ '--rebuild-types',
+ ],
+ ignore_headers: [
+ 'flickr-proxy-private.h',
+ 'lastfm-proxy-private.h',
+ 'oauth-proxy-private.h',
+ 'oauth2-proxy-private.h',
+ 'rest-private.h',
+ 'rest-proxy-call-private.h',
+ 'sha1.h',
+ ],
+)
diff --git a/examples/meson.build b/examples/meson.build
new file mode 100644
index 0000000..7d16dc7
--- /dev/null
+++ b/examples/meson.build
@@ -0,0 +1,25 @@
+example_names = [
+ 'test-raw',
+ 'test-xml',
+ 'dump-xml',
+ 'post-twitter',
+ 'post-twitter-media',
+ 'get-flickr-favorites',
+ 'lastfm-shout',
+ 'continuous-twitter',
+]
+
+example_deps = [
+ glib_dep,
+ libsoup_dep,
+ librest_dep,
+ librest_extras_dep,
+]
+
+foreach name : example_names
+ example = executable(name,
+ '@0@.c'.format(name),
+ dependencies: example_deps,
+ include_directories: config_h_inc,
+ )
+endforeach
diff --git a/meson.build b/meson.build
new file mode 100644
index 0000000..469fb28
--- /dev/null
+++ b/meson.build
@@ -0,0 +1,90 @@
+project('rest', 'c',
+ version: '0.9.0',
+ license: 'LGPL2.1+',
+ meson_version: '>= 0.49',
+)
+
+# Versioning
+librest_module_version = '0.0.0'
+librest_soversion = '0'
+librest_api_version = '1.0'
+librest_pkg_string = 'rest-@0@'.format(librest_api_version)
+
+# Modules
+gnome = import('gnome')
+pkgconfig = import('pkgconfig')
+
+# CA certificates
+if get_option('ca_certificates')
+ ca_certificates_path = get_option('ca_certificates_path')
+
+ if ca_certificates_path == ''
+ default_certificate_paths = [
+ '/etc/ssl/ca-bundle.pem',
+ '/etc/ssl/certs/ca-certificates.crt',
+ '/etc/pki/tls/certs/ca-bundle.crt',
+ ]
+
+ foreach location : default_certificate_paths
+ if file_exists(location)
+ ca_certificates_path = location
+ break
+ endif
+ endforeach
+ endif
+
+ if ca_certificates_path == ''
+ error('Did not specify system CA list and could not find any in the default locations.')
+ endif
+endif
+
+# Dependencies
+glib_dep = dependency('glib-2.0', version: '>= 2.44')
+gobject_dep = dependency('gobject-2.0', version: '>= 2.44')
+libsoup_dep = dependency('libsoup-2.4', version: '>= 2.42')
+libxml_dep = dependency('libxml-2.0')
+
+# config.h
+conf = configuration_data()
+conf.set_quoted('PACKAGE_NAME', meson.project_name())
+conf.set_quoted('PACKAGE_STRING', '@0@ - @1@'.format(meson.project_name(), meson.project_version()))
+conf.set_quoted('PACKAGE_VERSION', meson.project_version())
+if get_option('ca_certificates')
+ con.set_quoted('REST_SYSTEM_CA_FILE', ca_certificates_path)
+endif
+configure_file(output: 'config.h', configuration: conf)
+config_h_inc = include_directories('.')
+
+# Subdirectories
+subdir('rest')
+subdir('rest-extras')
+subdir('tests')
+if get_option('examples')
+ subdir('examples')
+endif
+if get_option('gtk_doc')
+ subdir('docs')
+endif
+
+# pkg-config
+pkgconfig.generate(librest_lib,
+ name: meson.project_name(),
+ filebase: librest_pkg_string,
+ description: 'RESTful web api query library',
+ subdirs: librest_pkg_string,
+ requires: [ glib_dep, libsoup_dep, libxml_dep, ],
+ variables: [
+ 'apiversion=@0@'.format(librest_api_version),
+ ],
+)
+
+pkgconfig.generate(librest_extras_lib,
+ name: meson.project_name(),
+ filebase: librest_extras_pkg_string,
+ description: 'RESTful web api query library',
+ subdirs: librest_pkg_string,
+ requires: [ glib_dep, libsoup_dep, libxml_dep, ],
+ variables: [
+ 'apiversion=@0@'.format(librest_api_version),
+ ],
+)
diff --git a/meson_options.txt b/meson_options.txt
new file mode 100644
index 0000000..ae4ba54
--- /dev/null
+++ b/meson_options.txt
@@ -0,0 +1,25 @@
+option('ca_certificates',
+ type: 'boolean',
+ value: false,
+ description: 'Whether to use a pre-specified Certificate Authority list (see the ca_certificates_path option)',
+)
+option('ca_certificates_path',
+ type: 'string',
+ value: '',
+ description: 'List of paths to the system Certificate Authority list. If empty, a default set of paths will be tried.',
+)
+option('introspection',
+ type: 'boolean',
+ value: true,
+ description: 'Generate GObject Introspection (.gir) files',
+)
+option('examples',
+ type: 'boolean',
+ value: true,
+ description: 'Build the examples',
+)
+option('gtk_doc',
+ type: 'boolean',
+ value: false,
+ description: 'Build the gtk-doc reference docs',
+)
diff --git a/rest-extras/meson.build b/rest-extras/meson.build
new file mode 100644
index 0000000..b85b388
--- /dev/null
+++ b/rest-extras/meson.build
@@ -0,0 +1,73 @@
+librest_extras_pkg_string = 'rest-extras-@0@'.format(librest_api_version)
+
+librest_extras_sources = [
+ 'flickr-proxy.c',
+ 'flickr-proxy-call.c',
+ 'lastfm-proxy.c',
+ 'lastfm-proxy-call.c',
+ 'youtube-proxy.c',
+]
+
+librest_extras_headers = [
+ 'flickr-proxy.h',
+ 'flickr-proxy-call.h',
+ 'lastfm-proxy.h',
+ 'lastfm-proxy-call.h',
+ 'youtube-proxy.h',
+]
+
+librest_extras_deps = [
+ glib_dep,
+ libsoup_dep,
+ libxml_dep,
+ librest_dep,
+]
+
+librest_extras_c_args = [
+ '-DG_LOG_DOMAIN="Rest"',
+]
+
+librest_extras_lib = library(librest_extras_pkg_string,
+ librest_extras_sources,
+ dependencies: librest_extras_deps,
+ c_args: librest_extras_c_args,
+ include_directories: config_h_inc,
+ version: librest_module_version,
+ soversion: librest_soversion,
+ install: true,
+)
+
+install_headers(librest_extras_headers,
+ subdir: librest_pkg_string / 'rest-extras',
+)
+
+librest_extras_dep = declare_dependency(
+ link_with: librest_extras_lib,
+)
+
+if get_option('introspection')
+ librest_extras_gir = gnome.generate_gir(librest_extras_lib,
+ sources: librest_extras_headers,
+ namespace: 'RestExtras',
+ nsversion: librest_api_version,
+ includes: [ 'GObject-2.0', 'Gio-2.0', 'Soup-2.4' ],
+ extra_args: [ '--accept-unprefixed' ],
+ install: true,
+ )
+endif
+
+# Test suite
+test_runner_c_args = [
+ '-DBUILD_TESTS',
+]
+
+test_runner_bin = executable('test-runner',
+ [ 'test-runner.c', librest_extras_sources ],
+ dependencies: librest_extras_deps,
+ c_args: test_runner_c_args,
+ include_directories: config_h_inc,
+)
+
+test('test-runner', test_runner_bin,
+ suite: 'rest-extras',
+)
diff --git a/rest/meson.build b/rest/meson.build
new file mode 100644
index 0000000..7bf7338
--- /dev/null
+++ b/rest/meson.build
@@ -0,0 +1,107 @@
+librest_enums = gnome.mkenums_simple('rest-enum-types',
+ sources: [ 'rest-proxy.h', 'rest-proxy-call.h' ],
+ install_header: true,
+ install_dir: get_option('includedir') / librest_pkg_string / 'rest',
+)
+
+librest_marshal = gnome.genmarshal('rest-marshal',
+ sources: 'rest-marshal.txt',
+)
+
+librest_sources = [
+ 'rest-param.c',
+ 'rest-params.c',
+ 'rest-proxy.c',
+ 'rest-proxy-auth.c',
+ 'rest-proxy-call.c',
+ 'rest-xml-node.c',
+ 'rest-xml-parser.c',
+ 'rest-main.c',
+ 'oauth-proxy.c',
+ 'oauth-proxy-call.c',
+ 'oauth2-proxy.c',
+ 'oauth2-proxy-call.c',
+ 'sha1.c',
+
+ librest_enums,
+ librest_marshal,
+]
+
+librest_headers = [
+ 'oauth-proxy-call.h',
+ 'oauth-proxy.h',
+ 'oauth2-proxy-call.h',
+ 'oauth2-proxy.h',
+ 'rest-param.h',
+ 'rest-params.h',
+ 'rest-proxy-auth.h',
+ 'rest-proxy-call.h',
+ 'rest-proxy.h',
+ 'rest-xml-node.h',
+ 'rest-xml-parser.h',
+]
+
+librest_deps = [
+ glib_dep,
+ libsoup_dep,
+ libxml_dep,
+]
+
+librest_c_args = [
+ '-DG_LOG_DOMAIN="Rest"',
+]
+
+librest_lib = library('rest-@0@'.format(librest_api_version),
+ librest_sources,
+ dependencies: librest_deps,
+ c_args: librest_c_args,
+ include_directories: config_h_inc,
+ version: librest_module_version,
+ soversion: librest_soversion,
+ install: true,
+)
+
+install_headers(librest_headers,
+ subdir: librest_pkg_string / 'rest',
+)
+
+# GObject Introspection
+if get_option('introspection')
+ librest_gir_extra_args = [
+ '--accept-unprefixed',
+ '--c-include=rest/rest-enum-types.h',
+ ]
+
+ foreach header : librest_headers
+ librest_gir_extra_args += '--c-include=rest/@0@'.format(header)
+ endforeach
+
+ librest_gir = gnome.generate_gir(librest_lib,
+ sources: [ librest_headers, librest_enums[1] ],
+ namespace: 'Rest',
+ nsversion: librest_api_version,
+ includes: [ 'GObject-2.0', 'Gio-2.0', 'Soup-2.4' ],
+ extra_args: librest_gir_extra_args,
+ install: true,
+ )
+endif
+
+librest_dep = declare_dependency(
+ link_with: librest_lib,
+)
+
+# Test suite
+test_runner_c_args = [
+ '-DBUILD_TESTS',
+]
+
+test_runner_bin = executable('test-runner',
+ [ 'test-runner.c', librest_sources ],
+ dependencies: librest_deps,
+ c_args: test_runner_c_args,
+ include_directories: config_h_inc,
+)
+
+test('test-runner', test_runner_bin,
+ suite: 'rest',
+)
diff --git a/tests/meson.build b/tests/meson.build
new file mode 100644
index 0000000..0025fd9
--- /dev/null
+++ b/tests/meson.build
@@ -0,0 +1,37 @@
+test_suites = {
+ 'rest': [
+ 'proxy',
+ 'proxy-continuous',
+ 'threaded',
+ 'oauth',
+ 'oauth-async',
+ 'oauth2',
+ 'xml',
+ 'custom-serialize',
+ ],
+ 'rest-extras': [
+ 'flickr',
+ 'lastfm',
+ ],
+}
+
+test_deps = [
+ glib_dep,
+ libsoup_dep,
+ librest_dep,
+ librest_extras_dep,
+]
+
+foreach suite, test_names : test_suites
+ foreach name : test_names
+ test_bin = executable(name,
+ '@0@.c'.format(name),
+ dependencies: test_deps,
+ include_directories: config_h_inc,
+ )
+
+ test(name, test_bin,
+ suite: suite,
+ )
+ endforeach
+endforeach