[pygobject] Add meson build definitions



commit 6c815ebdc28921f53050e479915cfe2c40379f8d
Author: Mathieu Duponchelle <mathieu centricular com>
Date:   Fri Apr 20 19:25:50 2018 +0200

    Add meson build definitions

 gi/meson.build                         |  80 +++++++++++++++++++++
 gi/overrides/meson.build               |  14 ++++
 gi/repository/meson.build              |   5 ++
 meson.build                            |  73 +++++++++++++++++++
 meson_options.txt                      |   1 +
 pygtkcompat/meson.build                |   8 +++
 setup.py                               |   3 +
 subprojects/.gitignore                 |   5 ++
 subprojects/glib.wrap                  |   5 ++
 subprojects/gobject-introspection.wrap |   5 ++
 subprojects/libffi.wrap                |   4 ++
 subprojects/proxy-libintl.wrap         |   4 ++
 subprojects/zlib.wrap                  |   4 ++
 tests/__init__.py                      |   2 -
 tests/gimarshallingtestsextra.h        |  13 ++++
 tests/meson.build                      | 126 +++++++++++++++++++++++++++++++++
 16 files changed, 350 insertions(+), 2 deletions(-)
---
diff --git a/gi/meson.build b/gi/meson.build
new file mode 100644
index 00000000..04661b27
--- /dev/null
+++ b/gi/meson.build
@@ -0,0 +1,80 @@
+sources = [
+  'pygboxed.c',
+  'pygenum.c',
+  'pygflags.c',
+  'pyginterface.c',
+  'pygobject-object.c',
+  'pygparamspec.c',
+  'pygpointer.c',
+  'pygoptioncontext.c',
+  'pygoptiongroup.c',
+  'pygspawn.c',
+  'gimodule.c',
+  'pygi-repository.c',
+  'pygi-info.c',
+  'pygi-foreign.c',
+  'pygi-struct.c',
+  'pygi-source.c',
+  'pygi-argument.c',
+  'pygi-resulttuple.c',
+  'pygi-type.c',
+  'pygi-boxed.c',
+  'pygi-closure.c',
+  'pygi-ccallback.c',
+  'pygi-util.c',
+  'pygi-property.c',
+  'pygi-signal-closure.c',
+  'pygi-invoke.c',
+  'pygi-cache.c',
+  'pygi-marshal-cleanup.c',
+  'pygi-basictype.c',
+  'pygi-list.c',
+  'pygi-array.c',
+  'pygi-error.c',
+  'pygi-object.c',
+  'pygi-value.c',
+  'pygi-enum-marshal.c',
+  'pygi-struct-marshal.c',
+  'pygi-hashtable.c']
+
+headers = [
+  'pygobject.h'
+]
+
+install_headers(headers, subdir : 'pygobject-@0@'.format(platform_version))
+
+python_sources = [
+  '_constants.py',
+  'docstring.py',
+  '_error.py',
+  'importer.py',
+  '__init__.py',
+  'module.py',
+  '_option.py',
+  '_ossighelper.py',
+  '_propertyhelper.py',
+  'pygtkcompat.py',
+  '_signalhelper.py',
+  'types.py']
+
+python.install_sources(python_sources,
+  pure : false,
+  subdir : 'gi'
+)
+
+giext = python.extension_module('_gi', sources,
+  dependencies : [python_dep, glib_dep, gi_dep, ffi_dep],
+  include_directories: include_directories('..'),
+  install: true,
+  subdir : 'gi',
+  c_args: ['-DHAVE_CONFIG_H', '-DPY_SSIZE_T_CLEAN'] + python_no_warn_flags
+)
+
+if pycairo_dep.found()
+  gicairoext = python.extension_module('_gi_cairo', ['pygi-foreign-cairo.c'],
+    dependencies : [python_dep, glib_dep, gi_dep, ffi_dep, pycairo_dep],
+    c_args: ['-DHAVE_CONFIG_H', '-DPY_SSIZE_T_CLEAN'] + python_no_warn_flags)
+endif
+
+subdir('overrides')
+subdir('repository')
diff --git a/gi/overrides/meson.build b/gi/overrides/meson.build
new file mode 100644
index 00000000..b8ecae95
--- /dev/null
+++ b/gi/overrides/meson.build
@@ -0,0 +1,14 @@
+python_sources = [
+  'GLib.py',
+  'Gtk.py',
+  'Gdk.py',
+  'GObject.py',
+  'Gio.py',
+  'GIMarshallingTests.py',
+  'Pango.py',
+  'keysyms.py',
+  '__init__.py']
+
+python.install_sources(python_sources,
+  subdir : join_paths('gi', 'overrides')
+)
diff --git a/gi/repository/meson.build b/gi/repository/meson.build
new file mode 100644
index 00000000..fdc136b2
--- /dev/null
+++ b/gi/repository/meson.build
@@ -0,0 +1,5 @@
+python_sources = ['__init__.py']
+
+python.install_sources(python_sources,
+  subdir : join_paths('gi', 'repository')
+)
diff --git a/meson.build b/meson.build
new file mode 100644
index 00000000..357cadbf
--- /dev/null
+++ b/meson.build
@@ -0,0 +1,73 @@
+project('pygobject', 'c',
+  version : '3.27.6',
+  meson_version : '>= 0.36.0',
+  default_options : [ 'warning_level=1',
+                      'buildtype=debugoptimized'])
+
+pygobject_version = meson.project_version()
+version_arr = pygobject_version.split('.')
+pygobject_version_major = version_arr[0].to_int()
+pygobject_version_minor = version_arr[1].to_int()
+pygobject_version_micro = version_arr[2].to_int()
+
+platform_version = '@0@.0'.format(pygobject_version_major)
+
+pymod = import('python')
+python = pymod.find_installation(get_option('python'))
+python_dep = python.dependency(required : true)
+python_no_warn_flags = []
+
+gi_dep = dependency('gobject-introspection-1.0', version : '>= 1.55.0', required : true,
+  fallback: ['gobject-introspection', 'girepo_dep'])
+glib_dep = dependency('glib-2.0', version : '>= 2.55.0', required : true,
+  fallback: ['glib', 'libglib_dep'])
+gobject_dep = dependency('gobject-2.0', version : '>= 2.55.0', required : true,
+  fallback: ['glib', 'libgobject_dep'])
+gio_dep = dependency('gio-2.0', version : '>= 2.55.0', required : true,
+  fallback: ['glib', 'libgio_dep'])
+gmodule_dep = dependency('gmodule-2.0', version : '>= 2.55.0',
+  fallback: ['glib', 'libgmodule_dep'])
+ffi_dep = dependency('libffi', version : '>= 3.0', required : true,
+  fallback : ['libffi', 'ffi_dep'])
+
+cairo_dep = dependency('cairo', required: false)
+cairo_gobject_dep = dependency('cairo-gobject', required: false)
+
+if python.language_version().version_compare('>= 3.0')
+  pycairo_dep = dependency('py3cairo', required: false)
+else
+  pycairo_dep = dependency('pycairo', required: false)
+endif
+
+cdata = configuration_data()
+
+cdata.set('PYGOBJECT_MAJOR_VERSION', pygobject_version_major)
+cdata.set('PYGOBJECT_MINOR_VERSION', pygobject_version_minor)
+cdata.set('PYGOBJECT_MICRO_VERSION', pygobject_version_micro)
+
+configure_file(output : 'config.h', configuration : cdata)
+
+pkgconf = configuration_data()
+
+pkgconf.set('prefix', join_paths(get_option('prefix')))
+pkgconf.set('exec_prefix', '${prefix}')
+pkgconf.set('includedir', '${prefix}/include')
+pkgconf.set('datarootdir', '${prefix}/share')
+pkgconf.set('datadir', '${datarootdir}')
+pkgconf.set('VERSION', pygobject_version)
+
+pkg_install_dir = '@0@/pkgconfig'.format(get_option('libdir'))
+
+configure_file(input : 'pygobject-@0  pc in'.format(platform_version),
+  output : 'pygobject-@0@.pc'.format(platform_version),
+  configuration : pkgconf,
+  install_dir : pkg_install_dir)
+
+configure_file(input : 'PKG-INFO.in',
+  output : 'pygobject-@0@-py@1@.egg-info'.format(pygobject_version, python.language_version()),
+  configuration : pkgconf,
+  install_dir : python.get_install_dir(subdir : 'gi'))
+
+subdir('gi')
+subdir('pygtkcompat')
+subdir('tests')
diff --git a/meson_options.txt b/meson_options.txt
new file mode 100644
index 00000000..3a3d82d6
--- /dev/null
+++ b/meson_options.txt
@@ -0,0 +1 @@
+option('python', type : 'string', value : 'python3')
diff --git a/pygtkcompat/meson.build b/pygtkcompat/meson.build
new file mode 100644
index 00000000..9e43c44b
--- /dev/null
+++ b/pygtkcompat/meson.build
@@ -0,0 +1,8 @@
+python_sources = [
+  '__init__.py',
+  'generictreemodel.py',
+  'pygtkcompat.py']
+
+python.install_sources(python_sources,
+  subdir : 'pygtkcompat'
+)
diff --git a/setup.py b/setup.py
index 0326569f..89029209 100755
--- a/setup.py
+++ b/setup.py
@@ -510,6 +510,9 @@ class build_tests(Command):
                 "--library=gimarshallingtests",
                 "--pkg=glib-2.0",
                 "--pkg=gio-2.0",
+                "--cflags-begin",
+                "-I%s" % gi_tests_dir,
+                "--cflags-end",
                 "--output=%s" % gir_path,
             ] + ext.sources + ext.depends)
 
diff --git a/subprojects/.gitignore b/subprojects/.gitignore
new file mode 100644
index 00000000..9c1d4526
--- /dev/null
+++ b/subprojects/.gitignore
@@ -0,0 +1,5 @@
+glib
+libffi
+proxy-libintl
+zlib
+gobject-introspection
diff --git a/subprojects/glib.wrap b/subprojects/glib.wrap
new file mode 100644
index 00000000..c86fea72
--- /dev/null
+++ b/subprojects/glib.wrap
@@ -0,0 +1,5 @@
+[wrap-git]
+directory=glib
+url=git://git.gnome.org/glib
+push-url=ssh://git.gnome.org/git/glib
+revision=master
diff --git a/subprojects/gobject-introspection.wrap b/subprojects/gobject-introspection.wrap
new file mode 100644
index 00000000..561c20a8
--- /dev/null
+++ b/subprojects/gobject-introspection.wrap
@@ -0,0 +1,5 @@
+[wrap-git]
+directory=gobject-introspection
+url=https://gitlab.gnome.org/GNOME/gobject-introspection.git
+push-url=git gitlab gnome org:GNOME/gobject-introspection.git
+revision=master
diff --git a/subprojects/libffi.wrap b/subprojects/libffi.wrap
new file mode 100644
index 00000000..3d15e2a8
--- /dev/null
+++ b/subprojects/libffi.wrap
@@ -0,0 +1,4 @@
+[wrap-git]
+directory=libffi
+url=https://github.com/centricular/libffi.git
+revision=meson
diff --git a/subprojects/proxy-libintl.wrap b/subprojects/proxy-libintl.wrap
new file mode 100644
index 00000000..f32522ee
--- /dev/null
+++ b/subprojects/proxy-libintl.wrap
@@ -0,0 +1,4 @@
+[wrap-git]
+directory=proxy-libintl
+url=https://github.com/centricular/proxy-libintl.git
+revision=master
diff --git a/subprojects/zlib.wrap b/subprojects/zlib.wrap
new file mode 100644
index 00000000..de1e861e
--- /dev/null
+++ b/subprojects/zlib.wrap
@@ -0,0 +1,4 @@
+[wrap-git]
+directory=zlib
+url=https://github.com/centricular/zlib.git
+revision=meson
diff --git a/tests/__init__.py b/tests/__init__.py
index 437c44e7..eaa541d9 100644
--- a/tests/__init__.py
+++ b/tests/__init__.py
@@ -7,8 +7,6 @@ import signal
 import subprocess
 import atexit
 import warnings
-import importlib
-import sys
 import imp
 
 
diff --git a/tests/gimarshallingtestsextra.h b/tests/gimarshallingtestsextra.h
index 0e777b81..bc5f8fe5 100644
--- a/tests/gimarshallingtestsextra.h
+++ b/tests/gimarshallingtestsextra.h
@@ -20,6 +20,7 @@
 #define EXTRA_TESTS
 
 #include <glib-object.h>
+#include <gitestmacros.h>
 
 typedef enum
 {
@@ -35,22 +36,34 @@ typedef enum
   GI_MARSHALLING_TESTS_EXTRA_FLAGS_VALUE2 = (gint)(1 << 31),
 } GIMarshallingTestsExtraFlags;
 
+
+_GI_TEST_EXTERN
 GType gi_marshalling_tests_extra_flags_get_type (void) G_GNUC_CONST;
 #define GI_MARSHALLING_TESTS_TYPE_EXTRA_FLAGS (gi_marshalling_tests_extra_flags_get_type ())
 
+_GI_TEST_EXTERN
 void gi_marshalling_tests_compare_two_gerrors_in_gvalue (GValue *v, GValue *v1);
+_GI_TEST_EXTERN
 void gi_marshalling_tests_ghashtable_enum_none_in (GHashTable *hash_table);
+_GI_TEST_EXTERN
 GHashTable * gi_marshalling_tests_ghashtable_enum_none_return (void);
 
+_GI_TEST_EXTERN
 gchar * gi_marshalling_tests_filename_copy (gchar *path_in);
+_GI_TEST_EXTERN
 gboolean gi_marshalling_tests_filename_exists (gchar *path);
+_GI_TEST_EXTERN
 gchar * gi_marshalling_tests_filename_to_glib_repr (gchar *path_in, gsize *len);
 
+_GI_TEST_EXTERN
 GIMarshallingTestsExtraEnum * gi_marshalling_tests_enum_array_return_type (gsize *n_members);
 
+_GI_TEST_EXTERN
 void gi_marshalling_tests_extra_flags_large_in (GIMarshallingTestsExtraFlags value);
 
+_GI_TEST_EXTERN
 gchar *gi_marshalling_tests_extra_utf8_full_return_invalid (void);
+_GI_TEST_EXTERN
 void gi_marshalling_tests_extra_utf8_full_out_invalid (gchar **utf8);
 
 #endif /* EXTRA_TESTS */
diff --git a/tests/meson.build b/tests/meson.build
new file mode 100644
index 00000000..4b012590
--- /dev/null
+++ b/tests/meson.build
@@ -0,0 +1,126 @@
+gnome = import('gnome')
+
+host_system = host_machine.system()
+
+cc = meson.get_compiler('c')
+
+visibility_args = []
+if get_option('default_library') != 'static'
+  if host_system == 'windows'
+    visibility_args += ['-DDLL_EXPORT']
+    if cc.get_id() == 'msvc'
+      visibility_args += ['-D_GI_EXTERN=__declspec(dllexport) extern']
+    elif cc.has_argument('-fvisibility=hidden')
+      visibility_args += ['-D_GI_EXTERN=__attribute__((visibility("default"))) __declspec(dllexport) extern']
+      visibility_args += ['-fvisibility=hidden']
+    endif
+  elif cc.has_argument('-fvisibility=hidden')
+    visibility_args += ['-D_GI_EXTERN=__attribute__((visibility("default"))) extern']
+    visibility_args += ['-fvisibility=hidden']
+  endif
+endif
+
+if gi_dep.type_name() == 'pkgconfig'
+  gi_datadir = gi_dep.get_pkgconfig_variable('gidatadir')
+  regress_sources = [join_paths(gi_datadir, 'tests', 'regress.c')]
+  regress_headers = [join_paths(gi_datadir, 'tests', 'regress.h')]
+  regress_incdir = include_directories(join_paths(gi_datadir, 'tests'))
+  marshalling_sources = [join_paths(gi_datadir, 'tests', 'gimarshallingtests.c')]
+  marshalling_headers = [join_paths(gi_datadir, 'tests', 'gimarshallingtests.h')]
+else
+  gi_subproject = subproject('gobject-introspection')
+  regress_sources = gi_subproject.get_variable('test_regress_sources')
+  regress_headers = gi_subproject.get_variable('test_regress_headers')
+  regress_incdir = gi_subproject.get_variable('test_regress_incdirs')
+  marshalling_sources = gi_subproject.get_variable('test_marshalling_sources')
+  marshalling_headers = gi_subproject.get_variable('test_marshalling_headers')
+  gi_datadir = join_paths(meson.source_root(), 'subprojects', 'gobject-introspection', 'tests')
+endif
+
+marshalling_sources += ['gimarshallingtestsextra.c']
+
+marshalling_headers += ['gimarshallingtestsextra.h']
+
+marshalling_lib = library(
+  'gimarshallingtests',
+  sources : marshalling_sources,
+  dependencies : [glib_dep, gobject_dep, gio_dep, gmodule_dep],
+  include_directories : regress_incdir,
+  c_args: visibility_args,
+)
+
+gnome.generate_gir(
+  marshalling_lib,
+  sources : marshalling_sources + marshalling_headers,
+  nsversion : '1.0',
+  namespace : 'GIMarshallingTests',
+  dependencies : [glib_dep, gobject_dep, gio_dep, gmodule_dep],
+  symbol_prefix : 'gi_marshalling_tests',
+  includes : ['Gio-2.0'],
+  build_by_default : true,
+)
+
+regress_sources += ['regressextra.c']
+
+regress_headers += ['regressextra.h']
+
+regress_deps = [glib_dep, gobject_dep, gio_dep, gmodule_dep]
+regress_c_args = []
+
+if cairo_dep.found() and cairo_gobject_dep.found()
+  regress_deps += [cairo_dep, cairo_gobject_dep]
+else
+  regress_c_args += ['-D_GI_DISABLE_CAIRO']
+endif
+
+regress_lib = library(
+  'regress',
+  sources : regress_sources,
+  dependencies : regress_deps,
+  include_directories : regress_incdir,
+  c_args: regress_c_args + visibility_args,
+)
+
+gnome.generate_gir(
+  regress_lib,
+  sources : regress_sources + regress_headers,
+  nsversion : '1.0',
+  namespace : 'Regress',
+  includes : ['Gio-2.0', 'cairo-1.0'],
+  build_by_default : true,
+  dependencies : regress_deps,
+  extra_args: regress_c_args,
+)
+
+helper_sources = [
+  'testhelpermodule.c',
+  'test-floating.c',
+  'test-thread.c',
+  'test-unknown.c']
+
+helperext = python.extension_module('testhelper', helper_sources,
+  dependencies : [python_dep, glib_dep, gobject_dep],
+  c_args: ['-DPY_SSIZE_T_CLEAN'],
+  include_directories: include_directories(join_paths('..', 'gi'))
+)
+
+schemas = gnome.compile_schemas(build_by_default: true)
+
+envdata = environment()
+envdata.append('GI_TYPELIB_PATH', meson.current_build_dir())
+if gi_dep.type_name() == 'internal'
+  envdata.append('GI_TYPELIB_PATH', join_paths(meson.build_root(), 'subprojects', 'gobject-introspection', 
'gir'))
+endif
+
+if host_machine.system() == 'linux'
+    envdata.prepend('LD_LIBRARY_PATH', meson.current_build_dir())
+endif
+if host_machine.system() == 'windows'
+    envdata.prepend('PATH', join_paths(get_option('prefix'), get_option('bindir')))
+endif
+envdata.append('PYTHONPATH', join_paths(meson.current_build_dir(), '..'))
+envdata.append('TESTS_BUILDDIR', meson.current_build_dir())
+
+test('pygobject-test-suite', python,
+  args : [join_paths(meson.current_source_dir(), 'runtests.py')],
+  env : envdata)


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