[gexiv2] build: Add meson support



commit a18c17896b2e860d23274a5135e740bf3195d447
Author: Jens Georg <mail jensge org>
Date:   Sun May 14 22:56:12 2017 +0200

    build: Add meson support

 .gitignore                               |    2 +
 Makefile.am                              |   11 +++-
 docs/meson.build                         |    1 +
 docs/reference/gexiv2-docs.xml           |    4 -
 docs/reference/meson.build               |    7 ++
 docs/reference/xml/gtkdocentities.ent.in |    8 +++
 docs/reference/xml/meson.build           |   10 +++
 gexiv2/gexiv2-version.h.meson            |   43 ++++++++++++++
 gexiv2/meson.build                       |   91 ++++++++++++++++++++++++++++++
 meson.build                              |   57 +++++++++++++++++++
 meson_options.txt                        |    5 ++
 test/meson.build                         |   46 +++++++++++++++
 vapi/meson.build                         |    3 +
 13 files changed, 283 insertions(+), 5 deletions(-)
---
diff --git a/.gitignore b/.gitignore
index 5252e81..00ad89b 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,4 +1,6 @@
 .libs/
+build
+build-am
 gexiv2/.libs
 gexiv2/.dirstamp
 gexiv2/gexiv2-version.h
diff --git a/Makefile.am b/Makefile.am
index c4ab805..8c937d6 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -29,7 +29,16 @@ EXTRA_DIST = \
        test/data/CaorVN.jpeg \
        test/gexiv2-dump.vala \
        test/python/gexiv2.py \
-       test/python/test_metadata.py
+       test/python/test_metadata.py \
+       docs/meson.build \
+       docs/reference/meson.build \
+       docs/reference/xml/meson.build \
+       docs/reference/xml/gtkdocentities.ent.in \
+       meson.build \
+       gexiv2/meson.build \
+       gexiv2/gexiv2-version.h.meson \
+       vapi/meson.build \
+       meson_options.txt
 
 enumheaders = $(srcdir)/gexiv2/gexiv2-metadata.h \
        $(srcdir)/gexiv2/gexiv2-log.h
diff --git a/docs/meson.build b/docs/meson.build
new file mode 100644
index 0000000..ead14c4
--- /dev/null
+++ b/docs/meson.build
@@ -0,0 +1 @@
+subdir('reference')
diff --git a/docs/reference/gexiv2-docs.xml b/docs/reference/gexiv2-docs.xml
index 2b6dc5c..aee85ba 100644
--- a/docs/reference/gexiv2-docs.xml
+++ b/docs/reference/gexiv2-docs.xml
@@ -26,10 +26,6 @@
       <xi:include href="xml/gexiv2-version.xml"/>
 
   </chapter>
-  <chapter id="object-tree">
-    <title>Object Hierarchy</title>
-    <xi:include href="xml/tree_index.sgml"/>
-  </chapter>
   <index id="api-index-full">
     <title>API Index</title>
     <xi:include href="xml/api-index-full.xml"><xi:fallback /></xi:include>
diff --git a/docs/reference/meson.build b/docs/reference/meson.build
new file mode 100644
index 0000000..cc91e64
--- /dev/null
+++ b/docs/reference/meson.build
@@ -0,0 +1,7 @@
+subdir('xml')
+gnome.gtkdoc('gexiv2',
+             main_xml : 'gexiv2-docs.xml',
+             src_dir : [join_paths(meson.source_root(), 'gexiv2'),
+                        join_paths(meson.build_root(), 'gexiv2')],
+             dependencies : gexiv2,
+             install : true)
diff --git a/docs/reference/xml/gtkdocentities.ent.in b/docs/reference/xml/gtkdocentities.ent.in
new file mode 100644
index 0000000..f12c9ff
--- /dev/null
+++ b/docs/reference/xml/gtkdocentities.ent.in
@@ -0,0 +1,8 @@
+<!ENTITY package "@PACKAGE@">
+<!ENTITY package_bugreport "@PACKAGE_BUGREPORT@">
+<!ENTITY package_name "@PACKAGE_NAME@">
+<!ENTITY package_string "@PACKAGE_STRING@">
+<!ENTITY package_tarname "@PACKAGE_TARNAME@">
+<!ENTITY package_url "@PACKAGE_URL@">
+<!ENTITY package_version "@PACKAGE_VERSION@">
+<!ENTITY package_api_version "@PACKAGE_API_VERSION@">
diff --git a/docs/reference/xml/meson.build b/docs/reference/xml/meson.build
new file mode 100644
index 0000000..02c2d88
--- /dev/null
+++ b/docs/reference/xml/meson.build
@@ -0,0 +1,10 @@
+ent_conf = configuration_data()
+ent_conf.set('PACKAGE', 'GExiv2')
+ent_conf.set('PACKAGE_BUGREPORT', 'https://bugzilla.gnome.org/enter_bug.cgi?product=Shotwell')
+ent_conf.set('PACKAGE_NAME', 'gexiv2')
+ent_conf.set('PACKAGE_STRING', 'GExiv2')
+ent_conf.set('PACKAGE_TARNAME', 'gexiv2-' + meson.project_version())
+ent_conf.set('PACKAGE_URL', 'https://wiki.gnome.org/Projects/gexiv2')
+ent_conf.set('PACKAGE_VERSION', meson.project_version())
+ent_conf.set('PACKAGE_API_VERSION', '0.10')
+configure_file(input: 'gtkdocentities.ent.in', output: 'gtkdocentities.ent', configuration: ent_conf)
diff --git a/gexiv2/gexiv2-version.h.meson b/gexiv2/gexiv2-version.h.meson
new file mode 100644
index 0000000..bae4834
--- /dev/null
+++ b/gexiv2/gexiv2-version.h.meson
@@ -0,0 +1,43 @@
+/*
+ * gexiv2-version.h
+ *
+ * This is free software. See COPYING for details.
+ */
+
+#ifndef __GEXIV2_VERSION_H__
+#define __GEXIV2_VERSION_H__
+
+#include <glib-object.h>
+
+G_BEGIN_DECLS
+
+#mesondefine GEXIV2_MAJOR_VERSION
+#mesondefine GEXIV2_MINOR_VERSION
+#mesondefine GEXIV2_MICRO_VERSION
+
+/**
+ * GEXIV2_CHECK_VERSION:
+ * @major: the major version to check for
+ * @minor: the minor version to check for
+ * @micro: the micro version to check for
+ *
+ * Returns: TRUE if the gexiv2 library version is greater than or equal to the supplied version
+ * requirement.
+ */
+#define GEXIV2_CHECK_VERSION(major, minor, micro) \
+    (GEXIV2_MAJOR_VERSION > (major) || \
+     (GEXIV2_MAJOR_VERSION == (major) && GEXIV2_MINOR_VERSION > (minor)) || \
+     (GEXIV2_MAJOR_VERSION == (major) && GEXIV2_MINOR_VERSION == (minor) && \
+      GEXIV2_MICRO_VERSION >= (micro)))
+
+/**
+ * gexiv2_get_version:
+ *
+ * Returns: The gexiv2 library's version number as a formatted decimal XXYYZZ, where XX is the
+ * major version, YY is the minor version, and ZZ is the micro version.  For example, version
+ * 0.6.1 will be returned as 000601.
+ */
+gint gexiv2_get_version (void);
+
+G_END_DECLS
+#endif
diff --git a/gexiv2/meson.build b/gexiv2/meson.build
new file mode 100644
index 0000000..67f4381
--- /dev/null
+++ b/gexiv2/meson.build
@@ -0,0 +1,91 @@
+pkg = import('pkgconfig')
+
+as_version = meson.project_version().split('.')
+
+gexiv2_include_dir = join_paths(get_option('includedir'), 'gexiv2')
+
+config = configuration_data()
+config.set('GEXIV2_MAJOR_VERSION', as_version[0])
+config.set('GEXIV2_MINOR_VERSION', as_version[1])
+config.set('GEXIV2_MICRO_VERSION', as_version[2])
+
+version_header = configure_file(input: 'gexiv2-version.h.meson',
+                                output: 'gexiv2-version.h',
+                                configuration: config,
+                                install_dir : gexiv2_include_dir)
+
+gexiv2_enum_headers = ['gexiv2-metadata.h', 'gexiv2-log.h']
+
+gexiv2_headers = gexiv2_enum_headers + ['gexiv2.h',
+                  'gexiv2-managed-stream.h',
+                  'gexiv2-preview-properties.h',
+                  'gexiv2-preview-image.h',
+                  'gexiv2-startup.h']
+
+enum_sources = gnome.mkenums('gexiv2-enums',
+                             sources : gexiv2_enum_headers,
+                             h_template : 'gexiv2-enums.h.template',
+                             c_template : 'gexiv2-enums.cpp.template',
+                             identifier_prefix : 'gexiv2',
+                             symbol_prefix : 'GExiv2',
+                             install_header : true,
+                             install_dir : gexiv2_include_dir)
+
+install_headers(gexiv2_headers, subdir : 'gexiv2')
+
+gexiv2 = library('gexiv2',
+                 ['gexiv2-metadata.cpp',
+                  'gexiv2-metadata-exif.cpp',
+                  'gexiv2-metadata-gps.cpp',
+                  'gexiv2-metadata-iptc.cpp',
+                  'gexiv2-metadata-xmp.cpp',
+                  'gexiv2-stream-io.cpp',
+                  'gexiv2-preview-properties.cpp',
+                  'gexiv2-preview-image.cpp',
+                  'gexiv2-log.cpp',
+                  'gexiv2-startup.cpp',
+                  'gexiv2-log-private.h',
+                  'gexiv2-metadata-private.h',
+                  'gexiv2-stream-io.h',
+                  'gexiv2-preview-properties-private.h',
+                  'gexiv2-preview-image-private.h'] +
+                 gexiv2_headers +
+                 [version_header] +
+                 enum_sources,
+                 include_directories : include_directories('..'),
+                 version : '2',
+                 soversion: '2.0.0',
+                 dependencies : [gobject, exiv2],
+                 install : true)
+
+pkg.generate(
+    description : 'GObject bindings for exiv2',
+    libraries : gexiv2,
+    version : meson.project_version(),
+    name : 'GExiv2',
+    filebase : 'gexiv2',
+    requires_private : 'exiv2',
+    requires : ['glib-2.0', 'gobject-2.0']
+    )
+
+# set unconditionally
+typelib_path = meson.current_build_dir()
+
+if introspection_available
+  gir = gnome.generate_gir(gexiv2,
+      sources : ['gexiv2-preview-properties.h',
+                 'gexiv2-preview-image.h',
+                 'gexiv2-startup.h',
+                 'gexiv2-metadata.h',
+                 'gexiv2-log.h',
+                 version_header,
+                 enum_sources.get(1)
+                 ],
+      namespace : 'GExiv2',
+      nsversion : '0.10',
+      symbol_prefix : 'gexiv2',
+      identifier_prefix : 'GExiv2',
+      export_packages : 'gexiv2',
+      includes : ['GObject-2.0'],
+      install : true)
+endif
diff --git a/meson.build b/meson.build
new file mode 100644
index 0000000..5ea3aff
--- /dev/null
+++ b/meson.build
@@ -0,0 +1,57 @@
+project('gexiv2', ['c', 'cpp'], version : '0.10.6')
+gnome = import('gnome')
+pkg = import('pkgconfig')
+
+exiv2 = dependency('exiv2', version : '>= 0.21')
+gobject = dependency('gobject-2.0', version : '>= 2.26.1')
+
+gir = find_program('g-ir-scanner', required: false)
+vapigen = find_program('vapigen', required: false)
+vala = find_program('valac', required: false)
+
+introspection_available = gir.found() and not get_option('disable-introspection')
+vapi_available = introspection_available and vapigen.found() and not get_option('disable-vala')
+
+subdir('gexiv2')
+
+if get_option('enable-gtk-doc')
+  subdir('docs')
+endif
+
+if vapi_available
+  subdir('vapi')
+endif
+
+python2_available = false
+python3_available = false
+python_gi_test_args = ['-c', 'import gi; print(gi._overridesdir)']
+python2_girdir = get_option('python2-girdir')
+python3_girdir = get_option('python3-girdir')
+
+if introspection_available
+  python2 = find_program('python2', required : false)
+  if python2.found()
+    py2gi = run_command(python2, python_gi_test_args)
+    if py2gi.returncode() == 0
+      python2_available = true
+      if python2_girdir == 'auto'
+        python2_girdir = py2gi.stdout()
+      endif
+      install_data('GExiv2.py', install_dir : python2_girdir)
+    endif
+  endif
+
+  python3 = find_program('python3', required : false)
+  if python3.found()
+    py3gi = run_command(python3, python_gi_test_args)
+    if py3gi.returncode() == 0
+      python3_available = true
+      if python3_girdir == 'auto'
+        python3_girdir = py3gi.stdout()
+      endif
+      install_data('GExiv2.py', install_dir : python3_girdir)
+    endif
+  endif
+endif
+
+subdir('test')
diff --git a/meson_options.txt b/meson_options.txt
new file mode 100644
index 0000000..0eab157
--- /dev/null
+++ b/meson_options.txt
@@ -0,0 +1,5 @@
+option('enable-gtk-doc', type: 'boolean', value: false, description: 'Enable generating the API reference 
(depends on GTK-Doc)')
+option('disable-introspection', type: 'boolean', value : false, description: 'Disable GObject Introspection')
+option('disable-vala', type: 'boolean', value: false, description: 'Disable generation of vala vapi file')
+option('python2-girdir', type: 'string', value : 'auto', description : 'Installation dir for PyGObject2 
overrides')
+option('python3-girdir', type: 'string', value : 'auto', description : 'Installation dir for PyGObject3 
overrides')
diff --git a/test/meson.build b/test/meson.build
new file mode 100644
index 0000000..f94f7c7
--- /dev/null
+++ b/test/meson.build
@@ -0,0 +1,46 @@
+test_sample_path = join_paths(meson.current_source_dir(), 'data')
+python_module_path = join_paths(meson.current_source_dir(), 'python')
+
+test_env = ['G_SLICE=always-malloc',
+            'GI_TYPELIB_PATH=@0@'.format(typelib_path),
+            'PYTHONPATH=@0@'.format(python_module_path),
+            'TEST_DATA_DIR=@0@'.format(test_sample_path),
+            'LD_LIBRARY_PATH=@0@'.format(typelib_path),
+            ]
+
+regression_test = executable('gexiv2-regression', 'gexiv2-regression.c',
+                             dependencies : gobject,
+                             c_args : '-DSAMPLE_PATH="@0@"'.format(test_sample_path),
+                             link_with : gexiv2)
+
+test('regression', regression_test, env : test_env)
+
+if vapi_available
+  valac = find_program('valac')
+  if valac.found()
+    add_languages('vala')
+    executable('gexiv2-dump',
+               'gexiv2-dump.vala',
+               include_directories : include_directories('..'),
+               dependencies : [gobject, vapi],
+               link_with : gexiv2)
+  endif
+endif
+
+if python2_available
+  python2_test_conf = configuration_data()
+  python2_test_conf.set('PYTHON2_PATH', python2.path())
+  python2_test = configure_file(input: 'python2-test.in',
+                                output : 'python2-test',
+                                configuration: python2_test_conf)
+  test('python2', find_program(python2_test), env : test_env)
+endif
+
+if python3_available
+  python3_test_conf = configuration_data()
+  python3_test_conf.set('PYTHON3_PATH', python3.path())
+  python3_test = configure_file(input: 'python3-test.in',
+                                output : 'python3-test',
+                                configuration: python3_test_conf)
+  test('python3', find_program(python3_test), env : test_env)
+endif
diff --git a/vapi/meson.build b/vapi/meson.build
new file mode 100644
index 0000000..a71303a
--- /dev/null
+++ b/vapi/meson.build
@@ -0,0 +1,3 @@
+vapi = gnome.generate_vapi('gexiv2',
+                           sources : gir.get(0),
+                           install : true)


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