[gexiv2] Modernise the project building
- From: Jens Georg <jensgeorg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gexiv2] Modernise the project building
- Date: Sun, 15 Aug 2021 19:27:54 +0000 (UTC)
commit f30cb113b47451c8543f8af6fba7f8aa78d05694
Author: postscript-dev <postscript-dev outlook com>
Date: Sun Aug 15 21:20:44 2021 +0200
Modernise the project building
Add require checks for all enabled optional dependencies
Add error messages for build options that require other build options
Remove Python 2 support as this is EOL
Replace detection of Python and gi module with meson's find_installation().
Add project_url variable to build files.
Add project_api_version variable to build files.
Add license string to build file.
Delete gexiv2.pc.in file as this is not used by the build. Meson creates the file dynamically.
!51
build-aux/org.gnome.GExiv2-oldstable.json | 3 +-
build-aux/org.gnome.GExiv2-stable.json | 3 +-
build-aux/org.gnome.GExiv2.json | 3 +-
debian/control | 13 -----
debian/python-gexiv2.install | 1 -
debian/rules | 2 +-
docs/reference/xml/meson.build | 4 +-
gexiv2.pc.in | 12 -----
gexiv2/meson.build | 9 ++--
meson.build | 63 ++++++++++------------
meson_options.txt | 4 +-
test/meson.build | 25 +++------
test/python/{gexiv2.py => gexiv2.py.in} | 12 +----
test/python/meson.build | 10 ++++
.../{test_metadata.py => test_metadata.py.in} | 2 +-
test/python2-test.in | 4 --
tools/meson.build | 14 +++--
17 files changed, 68 insertions(+), 116 deletions(-)
---
diff --git a/build-aux/org.gnome.GExiv2-oldstable.json b/build-aux/org.gnome.GExiv2-oldstable.json
index 7632064..506d6b0 100644
--- a/build-aux/org.gnome.GExiv2-oldstable.json
+++ b/build-aux/org.gnome.GExiv2-oldstable.json
@@ -48,8 +48,7 @@
"/share/gir-1.0"
],
"config-opts" : [
- "-Dpython2-girdir=no",
- "-Dpython3-girdir=no"
+ "-Dpython3=no"
],
"build-options" : {
"env" : {
diff --git a/build-aux/org.gnome.GExiv2-stable.json b/build-aux/org.gnome.GExiv2-stable.json
index c34690d..fc5c9d5 100644
--- a/build-aux/org.gnome.GExiv2-stable.json
+++ b/build-aux/org.gnome.GExiv2-stable.json
@@ -49,8 +49,7 @@
"/share/gir-1.0"
],
"config-opts" : [
- "-Dpython2-girdir=no",
- "-Dpython3-girdir=no"
+ "-Dpython3=no"
],
"build-options" : {
"env" : {
diff --git a/build-aux/org.gnome.GExiv2.json b/build-aux/org.gnome.GExiv2.json
index a990853..be97119 100644
--- a/build-aux/org.gnome.GExiv2.json
+++ b/build-aux/org.gnome.GExiv2.json
@@ -49,8 +49,7 @@
"/share/gir-1.0"
],
"config-opts" : [
- "-Dpython2-girdir=no",
- "-Dpython3-girdir=no"
+ "-Dpython3=no"
],
"build-options" : {
"env" : {
diff --git a/debian/control b/debian/control
index 76f3d9a..442969b 100644
--- a/debian/control
+++ b/debian/control
@@ -13,8 +13,6 @@ Build-Depends: debhelper (>= 7),
libgirepository1.0-dev (>= 0.9.12),
gir1.2-glib-2.0,
python3-gi,
- python-gi,
- python:any,
python3:any,
dh-python,
valac,
@@ -75,17 +73,6 @@ Description: GObject introspection data for the GExiv2 library.
It can be used by packages using the GIRepository format to generate
dynamic bindings.
-Package: python-gexiv2
-Architecture: any
-Depends: gir1.2-gexiv2-0.10 (= ${binary:Version}),
- libgexiv2-2 (= ${binary:Version}),
- python-gi,
- ${python:Depends},
- ${misc:Depends}
-Description: GExiv2 GObject introspection overrides for Python (Python2)
- gexiv2 is a GObject-based wrapper around the Exiv2 library. It makes the basic
- features of Exiv2 available to GNOME applications.
-
Package: python3-gexiv2
Architecture: any
Depends: gir1.2-gexiv2-0.10 (= ${binary:Version}),
diff --git a/debian/rules b/debian/rules
index 845912d..cea1764 100755
--- a/debian/rules
+++ b/debian/rules
@@ -15,7 +15,7 @@ export DEB_BUILD_MAINT_OPTIONS = hardening=+all
%:
- dh $@ --parallel --with gir --with python2 --with python3
+ dh $@ --parallel --with gir --with python3
# dh_make generated override targets
diff --git a/docs/reference/xml/meson.build b/docs/reference/xml/meson.build
index 4112eef..63811c1 100644
--- a/docs/reference/xml/meson.build
+++ b/docs/reference/xml/meson.build
@@ -4,7 +4,7 @@ ent_conf.set('PACKAGE_BUGREPORT', 'https://gitlab.gnome.org/GNOME/gexiv2/issues/
ent_conf.set('PACKAGE_NAME', 'gexiv2')
ent_conf.set('PACKAGE_STRING', 'GExiv2 ' + meson.project_version())
ent_conf.set('PACKAGE_TARNAME', 'gexiv2-' + meson.project_version())
-ent_conf.set('PACKAGE_URL', 'https://wiki.gnome.org/Projects/gexiv2')
+ent_conf.set('PACKAGE_URL', project_url)
ent_conf.set('PACKAGE_VERSION', meson.project_version())
-ent_conf.set('PACKAGE_API_VERSION', '0.10')
+ent_conf.set('PACKAGE_API_VERSION', project_api_version)
configure_file(input: 'gtkdocentities.ent.in', output: 'gtkdocentities.ent', configuration: ent_conf)
diff --git a/gexiv2/meson.build b/gexiv2/meson.build
index fcea1ff..98d5d05 100644
--- a/gexiv2/meson.build
+++ b/gexiv2/meson.build
@@ -75,7 +75,7 @@ pc_deps = ['glib-2.0', 'gobject-2.0', 'gio-2.0']
pkg.generate(
description : 'GObject bindings for exiv2',
- url : 'https://wiki.gnome.org/Projects/gexiv2',
+ url : project_url,
libraries : gexiv2,
version : meson.project_version(),
name : 'GExiv2',
@@ -87,7 +87,8 @@ pkg.generate(
# set unconditionally
typelib_path = meson.current_build_dir()
-if introspection_available
+vapi = disabler()
+if get_option('introspection')
gir = gnome.generate_gir(gexiv2,
sources : ['gexiv2-preview-properties.h',
'gexiv2-preview-image.h',
@@ -98,7 +99,7 @@ if introspection_available
enum_sources.get(1)
],
namespace : 'GExiv2',
- nsversion : '0.10',
+ nsversion : project_api_version,
symbol_prefix : 'gexiv2',
identifier_prefix : 'GExiv2',
export_packages : 'gexiv2',
@@ -106,7 +107,7 @@ if introspection_available
header : 'gexiv2/gexiv2.h',
install : true)
- if vapi_available
+ if get_option('vapi')
vapi = gnome.generate_vapi('gexiv2',
sources : gir.get(0),
install : true,
diff --git a/meson.build b/meson.build
index 8a79ba4..6128f25 100644
--- a/meson.build
+++ b/meson.build
@@ -2,12 +2,18 @@ project(
'gexiv2',
['c', 'cpp'],
version : '0.13.0',
- meson_version : '>=0.48',
+ license: 'GPL-2.0-or-later',
+ meson_version : '>=0.51',
default_options : [
'cpp_std=c++11'
]
)
+project_api_version = '0.10'
+message('Project API version: ' + project_api_version)
+
+project_url = 'https://wiki.gnome.org/Projects/gexiv2'
+
gnome = import('gnome')
pkg = import('pkgconfig')
@@ -16,6 +22,7 @@ gobject = dependency('gobject-2.0', version : '>= 2.46.0')
gio = dependency('gio-2.0', version : '>= 2.46.0')
cc = meson.get_compiler('c')
math = cc.find_library('m', required : false)
+python3 = import('python').find_installation('python3', modules: 'gi', required: get_option('python3'))
bmff_test = '''#include <exiv2/exiv2.h>
#ifndef EXV_ENABLE_BMFF
@@ -25,10 +32,14 @@ bmff_test = '''#include <exiv2/exiv2.h>
bmff_available = cc.compiles(bmff_test, name : 'BMFF support in exiv2', dependencies : [exiv2])
-gir = find_program('g-ir-scanner', required: false)
+find_program('g-ir-scanner', required: get_option('introspection'))
-introspection_available = gir.found() and get_option('introspection')
-vapi_available = introspection_available and add_languages('vala', required: get_option('vapi')) and
get_option('vapi')
+if get_option('vapi')
+ if get_option('introspection') == false
+ error('\'vapi\' build option requires \'introspection\' to be enabled.')
+ endif
+ vapi_available = add_languages('vala', required: true)
+endif
subdir('gexiv2')
@@ -36,40 +47,24 @@ if get_option('gtk_doc')
subdir('docs')
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
- if python2_girdir != 'no'
- 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().strip()
- endif
- install_data('GExiv2.py', install_dir : python2_girdir)
- endif
- endif
+if get_option('python3') == false
+ warning('\'python3\' is disabled, any Python tests will not be run.')
+else
+ if get_option('introspection') == false
+ error('Build option \'python3\' requires \'introspection\' to be enabled.')
endif
- if python3_girdir != 'no'
- 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().strip()
- endif
- install_data('GExiv2.py', install_dir : python3_girdir)
- endif
+ girdir = get_option('python3_girdir')
+ if girdir == 'auto'
+ python3_output = run_command(python3, ['-c', 'import gi; print(gi._overridesdir)'])
+ if python3_output.returncode() != 0
+ error('Finding the Python 3 gi/override path: ' + python3_output.stderr())
endif
+ girdir = python3_output.stdout().strip()
endif
+
+ message('Installing \'GExiv2.py\' into \'' + girdir + '\'')
+ python3.install_sources('GExiv2.py', subdir : girdir)
endif
subdir('test')
diff --git a/meson_options.txt b/meson_options.txt
index 8dd0319..5e76789 100644
--- a/meson_options.txt
+++ b/meson_options.txt
@@ -2,5 +2,5 @@ option('gtk_doc', type: 'boolean', value: false, description: 'Enable or disable
option('introspection', type: 'boolean', value : true, description: 'Enable or disable GObject
Introspection')
option('vapi', type: 'boolean', value: true, description: 'Enable or disable generation of vala vapi file')
option('tools', type: 'boolean', value: true, description: 'Enable or disable building the commandline
tools')
-option('python2_girdir', type: 'string', value : 'auto', description : 'Installation dir for PyGObject2
overrides (default = auto, no disables python2)')
-option('python3_girdir', type: 'string', value : 'auto', description : 'Installation dir for PyGObject3
overrides (default = auto, no disables python3)')
+option('python3_girdir', type: 'string', value : 'auto', description : 'Installation dir for PyGObject3
overrides (default = auto)')
+option('python3', type: 'boolean', value : true, description : 'Enable or disable using Python 3 (and
PyGObject module)')
diff --git a/test/meson.build b/test/meson.build
index 1f6bfe1..c4f287d 100644
--- a/test/meson.build
+++ b/test/meson.build
@@ -1,5 +1,5 @@
test_sample_path = join_paths(meson.current_source_dir(), 'data')
-python_module_path = join_paths(meson.current_source_dir(), 'python')
+python_module_path = join_paths(meson.current_build_dir(), 'python')
test_env = environment()
test_env.set('G_SLICE', 'always-malloc')
@@ -19,20 +19,11 @@ regression_test = executable('gexiv2-regression', 'gexiv2-regression.c',
test('regression', regression_test, env : test_env)
-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
+subdir('python')
-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
+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)
diff --git a/test/python/gexiv2.py b/test/python/gexiv2.py.in
similarity index 80%
rename from test/python/gexiv2.py
rename to test/python/gexiv2.py.in
index c1d4940..4e01ff5 100644
--- a/test/python/gexiv2.py
+++ b/test/python/gexiv2.py.in
@@ -22,17 +22,7 @@
import unittest
import os
-
-# Workaround pkutil.extend_path in dist-packages/gi/overrides/__init__.py
-# not helping us here for obscure reasons when using python2 (the following
-# is useless in python3).
-import gi.overrides
-gi.overrides.__path__.append(os.path.join(os.path.dirname(__file__),
- 'gi', 'overrides'))
-gi.overrides.__path__.append(os.path.join(os.path.dirname(__file__), '..', '..'))
-
-
-gi.require_version('GExiv2', '0.10')
+gi.require_version('GExiv2', '@PROJECT_API_VERSION@')
from gi.repository import GExiv2
diff --git a/test/python/meson.build b/test/python/meson.build
new file mode 100644
index 0000000..783ba0b
--- /dev/null
+++ b/test/python/meson.build
@@ -0,0 +1,10 @@
+python_conf = configuration_data()
+python_conf.set('PROJECT_API_VERSION', project_api_version)
+
+gexiv2_py_file = configure_file(input: 'gexiv2.py.in',
+ output : 'gexiv2.py',
+ configuration: python_conf)
+
+test_metadata_py_file = configure_file(input: 'test_metadata.py.in',
+ output : 'test_metadata.py',
+ configuration: python_conf)
diff --git a/test/python/test_metadata.py b/test/python/test_metadata.py.in
similarity index 99%
rename from test/python/test_metadata.py
rename to test/python/test_metadata.py.in
index 9d325df..a27aff2 100644
--- a/test/python/test_metadata.py
+++ b/test/python/test_metadata.py.in
@@ -31,7 +31,7 @@ import tempfile
PY3K = sys.version_info[0] == 3
import gi
-gi.require_version('GExiv2', '0.10')
+gi.require_version('GExiv2', '@PROJECT_API_VERSION@')
from gi.repository import GExiv2, GLib
from fractions import Fraction
diff --git a/tools/meson.build b/tools/meson.build
index f6af618..714a788 100644
--- a/tools/meson.build
+++ b/tools/meson.build
@@ -1,8 +1,6 @@
-if vapi_available
- executable('gexiv2-tool',
- 'gexiv2-tool.vala',
- include_directories : include_directories('..'),
- dependencies : [gobject, vapi, gio],
- vala_args: ['--disable-since-check'],
- link_with : gexiv2)
-endif
+executable('gexiv2-tool',
+ 'gexiv2-tool.vala',
+ include_directories : include_directories('..'),
+ dependencies : [gobject, vapi, gio],
+ vala_args: ['--disable-since-check'],
+ link_with : gexiv2)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]