summaryrefslogtreecommitdiff
path: root/gir
diff options
context:
space:
mode:
authorPatrick Griffis <tingping@tingping.se>2017-10-23 04:53:04 -0400
committerNirbheek Chauhan <nirbheek@centricular.com>2018-03-10 19:05:19 +0530
commit69fe98bdccc9c1c50e51bdfffa26cddacf07b575 (patch)
treef3cf06942548616e072fbad478c008bb77b516a3 /gir
parent81c7db8c53cc4dc1a7bb772fdca1bd5ec78708eb (diff)
downloadgobject-introspection-69fe98bdccc9c1c50e51bdfffa26cddacf07b575.tar.gz
Initial work on meson port
Diffstat (limited to 'gir')
-rw-r--r--gir/cairo-1.0.gir.in4
-rwxr-xr-xgir/generate_source_list.py16
-rw-r--r--gir/meson.build272
3 files changed, 290 insertions, 2 deletions
diff --git a/gir/cairo-1.0.gir.in b/gir/cairo-1.0.gir.in
index 73c993ab..60113e6e 100644
--- a/gir/cairo-1.0.gir.in
+++ b/gir/cairo-1.0.gir.in
@@ -3,9 +3,9 @@
xmlns="http://www.gtk.org/introspection/core/1.0"
xmlns:c="http://www.gtk.org/introspection/c/1.0"
xmlns:glib="http://www.gtk.org/introspection/glib/1.0">
- <package name="%CAIRO_GIR_PACKAGE%"/>
+ <package name="@CAIRO_GIR_PACKAGE@"/>
<namespace name="cairo" version="1.0"
- shared-library="%CAIRO_SHARED_LIBRARY%"
+ shared-library="@CAIRO_SHARED_LIBRARY@"
c:identifier-prefixes="cairo"
c:symbol-prefixes="cairo">
<record name="Context" c:type="cairo_t" foreign="1"
diff --git a/gir/generate_source_list.py b/gir/generate_source_list.py
new file mode 100755
index 00000000..96aaa50f
--- /dev/null
+++ b/gir/generate_source_list.py
@@ -0,0 +1,16 @@
+#!/usr/bin/env python3
+
+import sys
+from glob import glob
+
+output_file = sys.argv[1]
+glob_strs = sys.argv[2].split(',')
+filter_str = tuple(sys.argv[3].split(','))
+extra_files = sys.argv[4:]
+
+with open(output_file, 'w') as file_:
+ for s in glob_strs:
+ for f in glob(s):
+ if filter_str == ' ' or not f.endswith(filter_str):
+ file_.write(f + '\n')
+ file_.write('\n'.join(extra_files))
diff --git a/gir/meson.build b/gir/meson.build
new file mode 100644
index 00000000..986d8cbf
--- /dev/null
+++ b/gir/meson.build
@@ -0,0 +1,272 @@
+cairo_conf = configuration_data()
+if host_machine.system() == 'win32'
+ # TODO: Might not use libtool name
+ cairo_library_name = 'libcairo-gobject-2.dll'
+elif host_machine.system() == 'darwin'
+ cairo_library_name = 'libcairo-gobject.2.dylib'
+else
+ cairo_library_name = 'libcairo-gobject.so.2'
+# TODO: OpenBSD = libcairo-gobject.so
+endif
+
+cairo_conf.set('CAIRO_SHARED_LIBRARY', cairo_library_name)
+cairo_conf.set('CAIRO_GIR_PACKAGE', 'cairo-gobject')
+
+cairo_gir = configure_file(
+ input: 'cairo-1.0.gir.in',
+ output: 'cairo-1.0.gir',
+ configuration: cairo_conf,
+)
+
+gir_files = [
+ cairo_gir,
+ 'DBus-1.0.gir',
+ 'DBusGLib-1.0.gir',
+ 'fontconfig-2.0.gir',
+ 'freetype2-2.0.gir',
+ 'GL-1.0.gir',
+ 'libxml2-2.0.gir',
+ 'xft-2.0.gir',
+ 'xlib-2.0.gir',
+ 'xfixes-4.0.gir',
+ 'xrandr-1.3.gir',
+ 'win32-1.0.gir',
+]
+
+typelibdir = join_paths(get_option('libdir'), 'girepository-1.0')
+girdir = join_paths(get_option('datadir'), 'gir-1.0')
+install_data(gir_files, install_dir: girdir)
+
+scanner_command = [
+ find_program('env'),
+ 'UNINSTALLED_INTROSPECTION_SRCDIR=' + meson.source_root(),
+ 'UNINSTALLED_INTROSPECTION_BUILDDIR=' + meson.build_root(),
+ girscanner,
+ '--output=@OUTPUT@',
+ '--warn-all',
+ '--no-libtool',
+ '--external-library',
+ '--reparse-validate',
+]
+
+# GLib
+glib_includedir = join_paths(gobject_dep.get_pkgconfig_variable('includedir'), 'glib-2.0')
+glib_libincludedir = join_paths(gobject_dep.get_pkgconfig_variable('libdir'), 'glib-2.0/include')
+glib_srcdir = get_option('glib-src-dir')
+
+glib_glob = glib_includedir + '/glib/*.h'
+if glib_srcdir != ''
+ glib_glob += ',' + glib_srcdir + '/glib/*.c'
+endif
+
+glib_sources_file = custom_target('glib-sources-file',
+ input: 'glib-2.0.c',
+ output: 'glib-sources.list',
+ command: [
+ find_program('generate_source_list.py'),
+ '@OUTPUT@',
+ glib_glob,
+ 'glib-autocleanups.h',
+ glib_libincludedir + '/glibconfig.h',
+ glib_includedir + '/gobject/glib-types.h',
+ '@INPUT@',
+ ]
+)
+
+glib_gir = custom_target('gir-glib',
+ input: glib_sources_file,
+ output: 'GLib-2.0.gir',
+ install: true,
+ install_dir: girdir,
+ command: scanner_command + [
+ '--identifier-prefix=G',
+ '--symbol-prefix=g',
+ '--symbol-prefix=glib',
+ '--c-include=glib.h',
+ '--namespace=GLib',
+ '--nsversion=2.0',
+ '--pkg=glib-2.0',
+ '--library=glib-2.0',
+ '--library=gobject-2.0',
+ '--cflags-begin',
+ '-I' + glib_includedir,
+ '-I' + glib_libincludedir,
+ '-DGLIB_COMPILATION',
+ '-D__G_I18N_LIB_H__',
+ '-DGETTEXT_PACKAGE=Dummy',
+ '--cflags-end',
+ '--filelist=@INPUT@',
+ ]
+)
+
+gir_files += glib_gir
+
+# GObject
+gobject_glob = glib_includedir + '/gobject/*.h'
+if glib_srcdir != ''
+ gobject_glob += ',' + glib_srcdir + '/gobject/*.c'
+endif
+
+gobject_sources_file = custom_target('gobject-sources-file',
+ input: 'gobject-2.0.c',
+ output: 'gobject-sources.list',
+ command: [
+ find_program('generate_source_list.py'),
+ '@OUTPUT@',
+ gobject_glob,
+ 'glib-types.h',
+ '@INPUT@',
+ ]
+)
+
+gobject_gir = custom_target('gir-gobject',
+ input: gobject_sources_file,
+ output: 'GObject-2.0.gir',
+ depends: glib_gir,
+ install: true,
+ install_dir: girdir,
+ command: scanner_command + [
+ '--identifier-prefix=G',
+ '--symbol-prefix=g',
+ '--c-include=glib-object.h',
+ '--namespace=GObject',
+ '--nsversion=2.0',
+ '--pkg=gobject-2.0',
+ '--library=gobject-2.0',
+ '--include-uninstalled=' + glib_gir.full_path(),
+ '--cflags-begin',
+ '-I' + glib_includedir,
+ '-I' + glib_libincludedir,
+ '-DGOBJECT_COMPILATION',
+ '--cflags-end',
+ '--filelist=@INPUT@',
+ ]
+)
+
+gir_files += gobject_gir
+
+# GModule
+gir_files += custom_target('gir-gmodule',
+ input: 'gmodule-2.0.c', # TODO: glib sources
+ output: 'GModule-2.0.gir',
+ depends: glib_gir,
+ install: true,
+ install_dir: girdir,
+ command: scanner_command + [
+ '--identifier-prefix=G',
+ '--symbol-prefix=g',
+ '--c-include=gmodule.h',
+ '--namespace=GModule',
+ '--nsversion=2.0',
+ '--pkg=gmodule-2.0',
+ '--library=gmodule-2.0',
+ '--include-uninstalled=' + glib_gir.full_path(),
+ '--cflags-begin',
+ '-I' + glib_includedir,
+ '-I' + glib_libincludedir,
+ '--cflags-end',
+ glib_includedir + '/gmodule.h',
+ '@INPUT@',
+ ]
+)
+
+# Gio
+gio_command = scanner_command + [
+ '--identifier-prefix=G',
+ '--symbol-prefix=g',
+ '--c-include=gio/gio.h',
+ '--namespace=Gio',
+ '--nsversion=2.0',
+ '--pkg=gio-2.0',
+ '--library=gio-2.0',
+ '--include-uninstalled=' + gobject_gir.full_path(),
+ '--cflags-begin',
+ '-DGIO_COMPILATION',
+ '-DG_SETTINGS_ENABLE_BACKEND',
+ '-I' + glib_includedir,
+ '--cflags-end',
+ '--filelist=@INPUT@',
+]
+
+gio_glob = glib_includedir + '/gio/*.h'
+if glib_srcdir != ''
+ gio_glob += ',' + glib_srcdir + '/gio/*.c'
+endif
+
+if giounix_dep.found()
+ giounix_includedir = giounix_dep.get_pkgconfig_variable('includedir') + '/gio-unix-2.0'
+ gio_glob += ',' + giounix_includedir + '/gio/*.h'
+
+ get_header_list = '''
+from glob import glob
+from os.path import basename
+
+print(','.join(basename(f) for f in glob('@0@/gio/*.h')))
+'''.format(giounix_includedir)
+
+ ret = run_command(py3.find_python(), '-c', get_header_list)
+ if ret.returncode() != 0
+ error('Failed to get gio header list')
+ endif
+ gio_headers = ret.stdout().strip().split(',')
+ foreach header : gio_headers
+ gio_command += '--c-include=gio/' + header
+ endforeach
+
+ gio_command += '--pkg=gio-unix-2.0'
+endif
+
+gio_sources_file = custom_target('gio-sources-file',
+ input: 'gio-2.0.c',
+ output: 'gio-sources.list',
+ command: [
+ find_program('generate_source_list.py'),
+ '@OUTPUT@',
+ gio_glob,
+ ' ',
+ '@INPUT@',
+ ]
+)
+
+gir_files += custom_target('gir-gio',
+ input: gio_sources_file,
+ output: 'Gio-2.0.gir',
+ depends: gobject_gir,
+ install: true,
+ install_dir: girdir,
+ command: gio_command,
+)
+
+# GIRepository
+gir_files += custom_target('gir-girepository',
+ input: girepo_gir_sources,
+ output: 'GIRepository-2.0.gir',
+ depends: gobject_gir,
+ install: true,
+ install_dir: girdir,
+ command: scanner_command + [
+ '--identifier-prefix=GI',
+ '--symbol-prefix=g',
+ '--c-include=girepository.h',
+ '--namespace=GIRepository',
+ '--nsversion=2.0',
+ '--pkg=gobject-introspection-1.0',
+ '--library=girepository-1.0',
+ '--include-uninstalled=' + gobject_gir.full_path(),
+ '--cflags-begin',
+ '-DGI_COMPILATION',
+ '-I' + meson.source_root() + '/girepository',
+ '--cflags-end',
+ '@INPUT@',
+ ]
+)
+
+foreach gir : gir_files
+ custom_target('generate-typelib-@0@'.format(gir).underscorify(),
+ input: gir,
+ output: '@BASENAME@.typelib',
+ command: [gircompiler, '-o', '@OUTPUT@', '@INPUT@'],
+ install: true,
+ install_dir: typelibdir,
+ )
+endforeach