[geocode-glib/wip/meson] wip: Port to meson



commit 5f6b165d663388729c38c5bbb525b258bf206bf1
Author: Zeeshan Ali <zeenix gmail com>
Date:   Mon Oct 31 12:28:29 2016 +0100

    wip: Port to meson

 geocode-glib/geocode-enum-types.c.in |   40 ++++++++++++++++
 geocode-glib/geocode-enum-types.h.in |   24 ++++++++++
 geocode-glib/geocode-glib.c          |    1 +
 geocode-glib/meson.build             |   85 ++++++++++++++++++++++++++++++++++
 geocode-glib/tests/meson.build       |   47 +++++++++++++++++++
 meson.build                          |   47 +++++++++++++++++++
 meson_options.txt                    |    9 ++++
 7 files changed, 253 insertions(+), 0 deletions(-)
---
diff --git a/geocode-glib/geocode-enum-types.c.in b/geocode-glib/geocode-enum-types.c.in
new file mode 100644
index 0000000..50b09f7
--- /dev/null
+++ b/geocode-glib/geocode-enum-types.c.in
@@ -0,0 +1,40 @@
+/*** BEGIN file-header ***/
+
+#include "config.h"
+
+#include <geocode-glib/geocode-glib.h>
+#include <geocode-glib/geocode-enum-types.h>
+
+/*** END file-header ***/
+
+/*** BEGIN file-production ***/
+/* enumerations from "@filename@" */
+/*** END file-production ***/
+
+/*** BEGIN value-header ***/
+GType
+@enum_name@_get_type (void)
+{
+        static GType etype = 0;
+        if (G_UNLIKELY(etype == 0)) {
+            static const G@Type@Value values[] = {
+/*** END value-header ***/
+
+/*** BEGIN value-production ***/
+                { @VALUENAME@, "@VALUENAME@", "@valuenick@" },
+/*** END value-production ***/
+
+/*** BEGIN value-tail ***/
+                { 0, NULL, NULL }
+            };
+            etype = g_@type@_register_static (g_intern_static_string ("@EnumName@"), values);
+        }
+
+        return etype;
+}
+
+/*** END value-tail ***/
+
+/*** BEGIN file-tail ***/
+
+/*** END file-tail ***/
diff --git a/geocode-glib/geocode-enum-types.h.in b/geocode-glib/geocode-enum-types.h.in
new file mode 100644
index 0000000..ce603f6
--- /dev/null
+++ b/geocode-glib/geocode-enum-types.h.in
@@ -0,0 +1,24 @@
+/*** BEGIN file-header ***/
+#ifndef __GEOCODE_ENUM_TYPES_H__
+#define __GEOCODE_ENUM_TYPES_H__
+
+#include <glib-object.h>
+
+G_BEGIN_DECLS
+/*** END file-header ***/
+
+/*** BEGIN file-production ***/
+
+/* enumerations from "@filename@" */
+/*** END file-production ***/
+
+/*** BEGIN value-header ***/
+GType @enum_name@_get_type (void);
+#define @ENUMPREFIX@_TYPE_@ENUMSHORT@ (@enum_name@_get_type ())
+/*** END value-header ***/
+
+/*** BEGIN file-tail ***/
+G_END_DECLS
+
+#endif /* __GEOCODE_ENUM_TYPES_H__ */
+/*** END file-tail ***/
diff --git a/geocode-glib/geocode-glib.c b/geocode-glib/geocode-glib.c
index fdd9ceb..b89439d 100644
--- a/geocode-glib/geocode-glib.c
+++ b/geocode-glib/geocode-glib.c
@@ -27,6 +27,7 @@
 #include <libsoup/soup.h>
 #include <langinfo.h>
 #include <geocode-glib/geocode-glib-private.h>
+#include <config.h>
 
 /**
  * SECTION:geocode-glib
diff --git a/geocode-glib/meson.build b/geocode-glib/meson.build
new file mode 100644
index 0000000..cc7c57c
--- /dev/null
+++ b/geocode-glib/meson.build
@@ -0,0 +1,85 @@
+header_subdir = 'geocode-glib-' + gclib_api_version + '/geocode-glib'
+header_dir = get_option('includedir') + '/' + header_subdir
+
+headers = [ 'geocode-glib.h',
+            'geocode-location.h',
+            'geocode-forward.h',
+            'geocode-reverse.h',
+            'geocode-error.h',
+            'geocode-place.h',
+            'geocode-bounding-box.h',
+            'geocode-backend.h',
+            'geocode-mock-backend.h',
+            'geocode-nominatim.h' ]
+
+generated_sources = gnome.mkenums('geocode-enum-types',
+                                  h_template: 'geocode-enum-types.h.in',
+                                  c_template: 'geocode-enum-types.c.in',
+                                  sources: headers,
+                                  install_header: true,
+                                  install_dir: header_dir)
+
+
+public_sources = [ 'geocode-location.c',
+                   'geocode-forward.c',
+                   'geocode-reverse.c',
+                   'geocode-glib.c',
+                   'geocode-error.c',
+                   'geocode-place.c',
+                   'geocode-bounding-box.c',
+                   'geocode-backend.c',
+                   'geocode-mock-backend.c',
+                   'geocode-nominatim.c' ] + generated_sources
+
+sources = public_sources + [ 'geocode-glib-private.h' ]
+
+deps = [ dependency('gio-2.0', version: '>= 2.34'),
+                dependency('json-glib-1.0', version: '>= 0.99.2'),
+                dependency('libsoup-2.4', version: '>= 2.42') ]
+libm = cc.find_library('m', required: false)
+if libm.found()
+    deps += [ libm ]
+endif
+
+include = include_directories('..')
+exports_file = join_paths(meson.current_source_dir(), 'geocode-glib.symbols')
+link_args = '-export-symbols ' + exports_file
+
+libgcglib = shared_library('geocode-glib',
+                           sources,
+                           dependencies: deps,
+                           include_directories: include,
+                           link_args: link_args,
+                           install: true)
+
+install_headers(headers, subdir: header_subdir)
+
+gir = find_program('g-ir-scanner', required: false)
+cross_build = meson.is_cross_build()
+disable_gir = get_option('disable-introspection')
+
+if gir.found() and not cross_build and not disable_gir
+  gir_args = [
+    '--quiet',
+       '--c-include=geocode-glib/geocode-glib.h'
+  ]
+
+  gnome.generate_gir(libgcglib,
+                     sources: public_sources + headers,
+                     namespace: 'GeocodeGlib',
+                     nsversion: gclib_api_version,
+                     identifier_prefix: 'Geocode',
+                     symbol_prefix: 'geocode',
+                     export_packages: 'geocode-glib-1.0',
+                     dependencies: deps,
+                     includes: [ 'GObject-2.0',
+                                 'Gio-2.0',
+                                 'Json-1.0',
+                                 'Soup-2.4' ],
+                     install: true,
+                     extra_args: gir_args)
+endif
+
+if get_option('enable-installed-tests')
+    subdir('tests')
+endif
diff --git a/geocode-glib/tests/meson.build b/geocode-glib/tests/meson.build
new file mode 100644
index 0000000..b1b428d
--- /dev/null
+++ b/geocode-glib/tests/meson.build
@@ -0,0 +1,47 @@
+install_dir = get_option('libexecdir') + '/installed-tests/geocode-glib-1.0'
+
+e = executable('geo-uri',
+               'geo-uri.c',
+               dependencies: deps,
+               include_directories: include,
+               link_with: libgcglib,
+               install: true,
+               install_dir: install_dir)
+test('Geo URI', e)
+
+e = executable('geocode-glib',
+               'geocode-nominatim-test.h',
+               'geocode-nominatim-test.c',
+               'geocode-glib.c',
+               dependencies: deps,
+               include_directories: include,
+               link_with: libgcglib,
+               install: true,
+               install_dir: install_dir)
+env = ['G_TEST_SRCDIR=' + meson.current_source_dir()]
+test('API test', e, env: env)
+
+e = executable('mock-backend',
+               'mock-backend.c',
+               dependencies: deps,
+               include_directories: include,
+               link_with: libgcglib,
+               install: true,
+               install_dir: install_dir)
+test('Test mock backend', e)
+
+install_data('locale_format.json',
+             'locale_name.json',
+             'nominatim-area.json',
+             'nominatim-no-results.json',
+             'nominatim-rio.json',
+             'osm_type0.json',
+             'osm_type1.json',
+             'osm_type2.json',
+             'pub.json',
+             'rev.json',
+             'rev_fail.json',
+             'search.json',
+             'search_lat_long.json',
+             'xep.json',
+             install_dir: install_dir)
diff --git a/meson.build b/meson.build
new file mode 100644
index 0000000..c7eac62
--- /dev/null
+++ b/meson.build
@@ -0,0 +1,47 @@
+project('geocode-glib', 'c', version: '3.20.1')
+
+gclib_version = meson.project_version() # set in project() below
+ver_arr = gclib_version.split('.')
+
+gclib_major_version = ver_arr[0]
+gclib_minor_version = ver_arr[1]
+gclib_micro_version = ver_arr[2]
+
+gclib_api_version='1.0'
+
+conf = configuration_data()
+conf.set_quoted('VERSION', gclib_version)
+conf.set_quoted('PACKAGE_VERSION', gclib_version)
+conf.set_quoted('PACKAGE_NAME', 'geocode-glib')
+conf.set_quoted('GETTEXT_PACKAGE', 'geocode-glib')
+conf.set_quoted('PACKAGE_TARNAME', 'geocode-glib')
+conf.set_quoted('PACKAGE_STRING', 'geocode-glib ' + gclib_version)
+conf.set_quoted('PACKAGE_URL', 'https://wiki.gnome.org/Apps/Boxes')
+conf.set_quoted('PACKAGE_BUGREPORT', 'https://bugzilla.gnome.org/enter_bug.cgi?product=geocode-glib')
+conf.set_quoted('TEST_SRCDIR', meson.source_root() + '/data/')
+datadir = get_option('prefix') + '/' + get_option('datadir')
+conf.set_quoted('GEOCODE_LOCALEDIR', datadir + '/locale')
+
+configure_file(output: 'config.h', configuration : conf)
+
+gnome = import('gnome')
+
+add_global_arguments('-Wall', language: 'c')
+cc = meson.get_compiler('c')
+if cc.get_id() == 'gcc'
+    add_global_arguments('-Wchar-subscripts',
+                         '-Wmissing-declarations',
+                         '-Wmissing-prototypes',
+                         '-Wnested-externs',
+                         '-Wpointer-arith',
+                         '-Wcast-align',
+                         '-Wsign-compare',
+                         '-Wredundant-decls',
+                         '-fno-strict-aliasing',
+                         language: 'c')
+endif
+
+subdir('geocode-glib')
+#subdir('po')
+#subdir('icons')
+#subdir('docs')
diff --git a/meson_options.txt b/meson_options.txt
new file mode 100644
index 0000000..9ff8b61
--- /dev/null
+++ b/meson_options.txt
@@ -0,0 +1,9 @@
+option('enable-installed-tests',
+       type: 'boolean', value: false,
+       description: 'Build & install test programs')
+option('disable-introspection',
+        type: 'boolean', value: false,
+        description: 'Whether to disable the introspection generation')
+option('enable-gtk-doc',
+       type: 'boolean', value: false,
+       description: 'Whether to generate the API reference for Geocode-GLib')


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]