[gobject-introspection/wip/tingping/meson: 1/4] Initial work on meson port



commit 361d6ef272586c3f6dbee92c2541ac1f03bde3d4
Author: Patrick Griffis <tingping tingping se>
Date:   Mon Oct 23 04:53:04 2017 -0400

    Initial work on meson port

 Makefile-gir.am               |   12 +-
 docs/meson.build              |    2 +
 examples/meson.build          |    3 +
 gir/cairo-1.0.gir.in          |    4 +-
 gir/generate_source_list.py   |   16 +++
 gir/meson.build               |  272 +++++++++++++++++++++++++++++++++++++++++
 girepository/cmph/meson.build |   50 ++++++++
 girepository/meson.build      |  163 ++++++++++++++++++++++++
 giscanner/meson.build         |   74 +++++++++++
 meson.build                   |   91 ++++++++++++++
 meson_options.txt             |   11 ++
 tools/g-ir-tool-template.in   |    4 +
 tools/meson.build             |   54 ++++++++
 13 files changed, 748 insertions(+), 8 deletions(-)
---
diff --git a/Makefile-gir.am b/Makefile-gir.am
index 86ab5bf..1d0da9b 100644
--- a/Makefile-gir.am
+++ b/Makefile-gir.am
@@ -18,8 +18,8 @@ EXTRA_DIST += $(STATIC_GIRSOURCES)
 gir/cairo-1.0.gir: gir/cairo-1.0.gir.in Makefile
        [ -d $(@D) ] || $(mkdir_p) $(@D) ; \
        sed \
-       -e s,%CAIRO_SHARED_LIBRARY%,$(CAIRO_SHARED_LIBRARY), \
-       -e s,%CAIRO_GIR_PACKAGE%,$(CAIRO_GIR_PACKAGE), \
+       -e s,\@CAIRO_SHARED_LIBRARY\@,$(CAIRO_SHARED_LIBRARY), \
+       -e s,\@CAIRO_GIR_PACKAGE\@,$(CAIRO_GIR_PACKAGE), \
        < $< > $@.tmp && mv $@.tmp $@
 BUILT_SOURCES += gir/cairo-1.0.gir
 SUBSTITUTED_GIRSOURCES += gir/cairo-1.0.gir
@@ -47,10 +47,10 @@ if WITH_GLIBSRC
      GModule_2_0_gir_DOCSRC = $(GLIBSRC)/gmodule/*.c
      Gio_2_0_gir_DOCSRC = $(GLIBSRC)/gio/*.c
 else
-    GLib_2_0_gir_DOCSRC = 
-    GObject_2_0_gir_DOCSRC = 
-    GModule_2_0_gir_DOCSRC = 
-    Gio_2_0_gir_DOCSRC = 
+    GLib_2_0_gir_DOCSRC =
+    GObject_2_0_gir_DOCSRC =
+    GModule_2_0_gir_DOCSRC =
+    Gio_2_0_gir_DOCSRC =
 
 endif
 
diff --git a/docs/meson.build b/docs/meson.build
new file mode 100644
index 0000000..1ffde1f
--- /dev/null
+++ b/docs/meson.build
@@ -0,0 +1,2 @@
+install_man('g-ir-compiler.1', 'g-ir-generate.1', 'g-ir-scanner.1')
+install_data('gir-1.2.rnc', install_dir: join_paths(get_option('datadir'), 'gir-1.0'))
diff --git a/examples/meson.build b/examples/meson.build
new file mode 100644
index 0000000..6cc214b
--- /dev/null
+++ b/examples/meson.build
@@ -0,0 +1,3 @@
+executable('glib-print', 'glib-print.c',
+  dependencies: girepo_dep,
+)
diff --git a/gir/cairo-1.0.gir.in b/gir/cairo-1.0.gir.in
index 73c993a..60113e6 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 0000000..96aaa50
--- /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 0000000..986d8cb
--- /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
diff --git a/girepository/cmph/meson.build b/girepository/cmph/meson.build
new file mode 100644
index 0000000..0c0e0af
--- /dev/null
+++ b/girepository/cmph/meson.build
@@ -0,0 +1,50 @@
+cmph_sources = [
+  'bdz.c',
+  'bdz_ph.c',
+  'bmz8.c',
+  'bmz.c',
+  'brz.c',
+  'buffer_entry.c',
+  'buffer_manager.c',
+  'chd.c',
+  'chd_ph.c',
+  'chm.c',
+  'cmph.c',
+  'cmph_structs.c',
+  'compressed_rank.c',
+  'compressed_seq.c',
+  'fch_buckets.c',
+  'fch.c',
+  'graph.c',
+  'hash.c',
+  'jenkins_hash.c',
+  'miller_rabin.c',
+  'select.c',
+  'vqueue.c',
+  'vstack.c',
+]
+
+cmph_deps = [
+  gobject_dep,
+  cc.find_library('m', required: false),
+]
+
+cmph = static_library('cmph',
+  sources: cmph_sources,
+  c_args: gi_hidden_visibility_cflags,
+  dependencies: cmph_deps,
+)
+
+cmph_dep = declare_dependency(
+  link_with: cmph,
+  include_directories: include_directories('.'),
+)
+
+cmph_test = executable('cmph-bdz-test', '../cmph-bdz-test.c',
+  dependencies: [
+    cmph_dep,
+    gobject_dep,
+  ]
+)
+
+test('cmph-bdz-test', cmph_test)
diff --git a/girepository/meson.build b/girepository/meson.build
new file mode 100644
index 0000000..5348624
--- /dev/null
+++ b/girepository/meson.build
@@ -0,0 +1,163 @@
+subdir('cmph')
+
+girepo_gthash_lib = static_library('girepository-gthash',
+  sources: 'gthash.c',
+  c_args: gi_hidden_visibility_cflags,
+  dependencies: [
+    cmph_dep,
+    gobject_dep,
+  ],
+)
+
+girepo_gthash_dep = declare_dependency(
+  link_with: girepo_gthash_lib,
+  dependencies: gobject_dep,
+  include_directories: include_directories('.'),
+)
+
+girepo_internals_lib = static_library('girepository-internals',
+  sources: [
+    'girmodule.c',
+    'girnode.c',
+    'giroffsets.c',
+    'girparser.c',
+    'girwriter.c',
+  ],
+  c_args: gi_hidden_visibility_cflags,
+  dependencies: [girepo_gthash_dep, libffi_dep],
+)
+
+girepo_internals_dep = declare_dependency(
+  link_with: girepo_internals_lib,
+  dependencies: libffi_dep,
+  include_directories: include_directories('.'),
+)
+
+girepo_headers = [
+  'giarginfo.h',
+  'gibaseinfo.h',
+  'gicallableinfo.h',
+  'giconstantinfo.h',
+  'gienuminfo.h',
+  'gifieldinfo.h',
+  'gifunctioninfo.h',
+  'giinterfaceinfo.h',
+  'giobjectinfo.h',
+  'gipropertyinfo.h',
+  'giregisteredtypeinfo.h',
+  'girepository.h',
+  'girffi.h',
+  'gisignalinfo.h',
+  'gistructinfo.h',
+  'gitypeinfo.h',
+  'gitypelib.h',
+  'gitypes.h',
+  'giunioninfo.h',
+  'giversionmacros.h',
+  'givfuncinfo.h',
+]
+
+girepo_sources = [
+  'gdump.c',
+  'giarginfo.c',
+  'gibaseinfo.c',
+  'gicallableinfo.c',
+  'giconstantinfo.c',
+  'gienuminfo.c',
+  'gifieldinfo.c',
+  'gifunctioninfo.c',
+  'ginvoke.c',
+  'giinterfaceinfo.c',
+  'giobjectinfo.c',
+  'gipropertyinfo.c',
+  'giregisteredtypeinfo.c',
+  'girepository.c',
+  'girffi.c',
+  'gisignalinfo.c',
+  'gistructinfo.c',
+  'gitypeinfo.c',
+  'gitypelib.c',
+  'giunioninfo.c',
+  'givfuncinfo.c',
+]
+
+# Used in gir/meson.build
+girepo_gir_sources = files(
+  'giarginfo.c',
+  'gibaseinfo.c',
+  'gicallableinfo.c',
+  'giconstantinfo.c',
+  'gienuminfo.c',
+  'gifieldinfo.c',
+  'gifunctioninfo.c',
+  'giinterfaceinfo.c',
+  'giobjectinfo.c',
+  'gipropertyinfo.c',
+  'giregisteredtypeinfo.c',
+  'girepository.c',
+  'gisignalinfo.c',
+  'gistructinfo.c',
+  'gitypeinfo.c',
+  'giunioninfo.c',
+  'givfuncinfo.c',
+  'giarginfo.h',
+  'gibaseinfo.h',
+  'gicallableinfo.h',
+  'giconstantinfo.h',
+  'gienuminfo.h',
+  'gifieldinfo.h',
+  'gifunctioninfo.h',
+  'giinterfaceinfo.h',
+  'giobjectinfo.h',
+  'gipropertyinfo.h',
+  'giregisteredtypeinfo.h',
+  'girepository.h',
+  'gisignalinfo.h',
+  'gistructinfo.h',
+  'gitypeinfo.h',
+  'gitypelib.h',
+  'gitypes.h',
+  'giunioninfo.h',
+  'givfuncinfo.h',
+)
+
+install_headers(girepo_headers, subdir: 'gobject-introspection-1.0')
+
+girepo_lib = shared_library('girepository-1.0',
+  sources: girepo_sources,
+  c_args: gi_hidden_visibility_cflags + ['-DG_IREPOSITORY_COMPILATION'],
+  dependencies: [
+    gio_dep,
+    gmodule_dep,
+    girepo_internals_dep,
+    dependency('gio-2.0'),
+  ],
+  version: '1.0.0',
+  install: true,
+)
+
+install_data('gdump.c',
+  install_dir: join_paths(get_option('datadir'), 'gobject-introspection-1.0')
+)
+
+girepo_dep = declare_dependency(
+  link_with: girepo_lib,
+  dependencies: gio_dep,
+  include_directories: include_directories('.'),
+)
+
+gthash_test = executable('gthash-test', 'gthash-test.c',
+  dependencies: girepo_gthash_dep,
+)
+
+test('gthash-test', gthash_test)
+
+if giounix_dep.found()
+  executable('gi-dump-types', 'gi-dump-types.c',
+    dependencies: [
+      girepo_dep,
+      gmodule_dep,
+      giounix_dep,
+    ]
+  )
+endif
diff --git a/giscanner/meson.build b/giscanner/meson.build
new file mode 100644
index 0000000..3bc4d01
--- /dev/null
+++ b/giscanner/meson.build
@@ -0,0 +1,74 @@
+pkglibdir = join_paths(get_option('libdir'), meson.project_name())
+giscannerdir = join_paths(pkglibdir, 'giscanner')
+install_data([
+  '__init__.py',
+  'annotationmain.py',
+  'annotationparser.py',
+  'ast.py',
+  'cachestore.py',
+  'ccompiler.py',
+  'codegen.py',
+  'docmain.py',
+  'docwriter.py',
+  'dumper.py',
+  'introspectablepass.py',
+  'girparser.py',
+  'girwriter.py',
+  'gdumpparser.py',
+  'libtoolimporter.py',
+  'maintransformer.py',
+  'message.py',
+  'msvccompiler.py',
+  'shlibs.py',
+  'scannermain.py',
+  'sectionparser.py',
+  'sourcescanner.py',
+  'testcodegen.py',
+  'transformer.py',
+  'utils.py',
+  'xmlwriter.py',
+], install_dir: giscannerdir)
+
+install_data([
+  'collections/__init__.py',
+  'collections/counter.py',
+  'collections/ordereddict.py',
+], install_dir: join_paths(giscannerdir, 'collections'))
+
+install_subdir('doctemplates', install_dir: giscannerdir)
+
+flex = find_program('flex')
+bison = find_program('bison')
+
+scannerparser = custom_target('scannerparser',
+    input: 'scannerparser.y',
+   output: ['scannerparser.c', 'scannerparser.h'],
+  command: [bison, '@INPUT@', '--defines=@OUTPUT1@', '--output=@OUTPUT0@']
+
+)
+
+scannerlexer = custom_target('scannerlexer',
+    input: 'scannerlexer.l',
+   output: 'scannerlexer.c',
+  command: [flex, '-o', '@OUTPUT@', '@INPUT@']
+)
+
+giscanner_lib = static_library('giscanner',
+  sources: [
+    'sourcescanner.c',
+    scannerparser,
+    scannerlexer,
+  ],
+  dependencies: gio_dep,
+)
+
+# TODO: -export-symbols-regex "init_giscanner|PyInit__giscanner"
+py3.extension_module('_giscanner', 'giscannermodule.c',
+  link_with: giscanner_lib,
+  dependencies: [
+    gobject_dep,
+    dependency('python3'),
+  ],
+  install: true,
+  install_dir: giscannerdir,
+)
diff --git a/meson.build b/meson.build
new file mode 100644
index 0000000..069f45c
--- /dev/null
+++ b/meson.build
@@ -0,0 +1,91 @@
+project('gobject-introspection', 'c',
+  version: '1.55.0',
+  meson_version: '>= 0.40.0',
+  default_options: [
+    'warning_level=1',
+    'buildtype=debugoptimized',
+  ],
+)
+
+py3 = import('python3')
+
+cc = meson.get_compiler('c')
+config = configuration_data()
+config.set_quoted('GIR_SUFFIX', 'gir-1.0')
+config.set_quoted('GIR_DIR', join_paths(get_option('prefix'), get_option('datadir'), 'gir-1.0'))
+config.set_quoted('GOBJECT_INTROSPECTION_LIBDIR', join_paths(get_option('prefix'), get_option('libdir')))
+
+foreach type : ['char', 'short', 'int', 'long']
+  size = cc.sizeof(type)
+  if size == -1
+    error('Failed to get size of @0@'.format(type))
+  endif
+  config.set('SIZEOF_@0@'.format(type.to_upper()), size)
+endforeach
+
+configure_file(
+  configuration: config,
+  output: 'config.h'
+)
+
+add_project_arguments([
+    '-I' + meson.build_root(),
+    '-DHAVE_CONFIG_H',
+  ] language: 'c',
+)
+
+gi_hidden_visibility_cflags = []
+if cc.has_argument('-fvisibility=hidden')
+  gi_hidden_visibility_cflags = [
+    '-D_GI_EXTERN=__attribute__((visibility("default"))) extern',
+    '-fvisibility=hidden',
+  ]
+endif
+
+gobject_dep = dependency('gobject-2.0', version: '>= 2.55.0')
+gio_dep = dependency('gio-2.0')
+giounix_dep = dependency('gio-unix-2.0', required: false)
+gmodule_dep = dependency('gmodule-2.0')
+libffi_dep = dependency('libffi')
+
+subdir('girepository')
+subdir('tools')
+subdir('giscanner')
+subdir('gir')
+subdir('examples')
+subdir('docs')
+subdir('tests')
+
+install_data('Makefile.introspection', install_dir: join_paths(get_option('datadir'), 
'gobject-introspection-1.0'))
+install_data('m4/introspection.m4', install_dir: join_paths(get_option('datadir'), 'aclocal'))
+
+prefix = get_option('prefix')
+pkgconfig_conf = configuration_data()
+pkgconfig_conf.set('prefix', prefix)
+pkgconfig_conf.set('exec_prefix', '${prefix}')
+pkgconfig_conf.set('bindir', join_paths(prefix, get_option('bindir')))
+pkgconfig_conf.set('libdir', join_paths(prefix, get_option('libdir')))
+pkgconfig_conf.set('datarootdir', join_paths(prefix, get_option('datadir')))
+pkgconfig_conf.set('datadir', '${datarootdir}')
+pkgconfig_conf.set('includedir', join_paths(prefix, get_option('includedir')))
+pkgconfig_conf.set('EXEEXT', '') # TODO?
+pkgconfig_conf.set('VERSION', meson.project_version())
+pkgconfig_conf.set('FFI_PC_CFLAGS', libffi_dep.get_pkgconfig_variable('Cflags'))
+pkgconfig_conf.set('FFI_PC_PACKAGES', 'libffi')
+pkgconfig_conf.set('FFI_PC_LIBS', libffi_dep.get_pkgconfig_variable('Libs'))
+
+configure_file(
+  input: 'gobject-introspection-no-export-1.0.pc.in',
+  output: 'gobject-introspection-no-export-1.0.pc',
+  configuration: pkgconfig_conf,
+  install: true,
+  install_dir: join_paths(get_option('libdir'), 'pkgconfig'),
+)
+
+configure_file(
+  input: 'gobject-introspection-1.0.pc.in',
+  output: 'gobject-introspection-1.0.pc',
+  configuration: pkgconfig_conf,
+  install: true,
+  install_dir: join_paths(get_option('libdir'), 'pkgconfig'),
+)
diff --git a/meson_options.txt b/meson_options.txt
new file mode 100644
index 0000000..e9d21e9
--- /dev/null
+++ b/meson_options.txt
@@ -0,0 +1,11 @@
+option('cairo', type: 'boolean',
+  description: 'Use cairo for tests'
+)
+
+option('doctool', type: 'boolean',
+  description: 'Install g-ir-doc-tool'
+)
+
+option('glib-src-dir', type: 'string',
+  description: 'Source directory for glib - needed to add docs to gir'
+)
diff --git a/tools/g-ir-tool-template.in b/tools/g-ir-tool-template.in
old mode 100644
new mode 100755
index edc68a4..2eac21f
--- a/tools/g-ir-tool-template.in
+++ b/tools/g-ir-tool-template.in
@@ -62,5 +62,9 @@ if srcdir is not None:
 
 sys.path.insert(0, pylibdir)
 
+builddir = os.getenv('UNINSTALLED_INTROSPECTION_BUILDDIR', None)
+if builddir is not None:
+    sys.path.insert(0, os.path.join(builddir, 'giscanner'))
+
 from giscanner.@TOOL_MODULE@ import @TOOL_FUNCTION@
 sys.exit(@TOOL_FUNCTION@(sys.argv))
diff --git a/tools/meson.build b/tools/meson.build
new file mode 100644
index 0000000..73817ec
--- /dev/null
+++ b/tools/meson.build
@@ -0,0 +1,54 @@
+libdir_abs = join_paths(get_option('prefix'), get_option('libdir'))
+datadir_abs = join_paths(get_option('prefix'), get_option('datadir'))
+python_path = py3.find_python().path()
+
+tools = [
+  ['g-ir-scanner', 'scannermain', 'scanner_main'],
+  ['g-ir-annotation-tool', 'annotationmain', 'annotation_main'],
+]
+if get_option('doctool')
+  tools += [['g-ir-doc-tool', 'docmain', 'doc_main']]
+endif
+
+tool_output = []
+foreach tool : tools
+  tools_conf = configuration_data()
+  tools_conf.set('libdir', libdir_abs)
+  tools_conf.set('datarootdir', datadir_abs)
+  tools_conf.set('PYTHON', python_path)
+
+  tools_conf.set('TOOL_MODULE', tool[1])
+  tools_conf.set('TOOL_FUNCTION', tool[2])
+  tool_output += configure_file(
+    input: 'g-ir-tool-template.in',
+    output: tool[0],
+    configuration: tools_conf,
+    install: true,
+    install_dir: get_option('bindir'),
+  )
+endforeach
+
+girscanner = tool_output[0]
+
+gircompiler = executable('g-ir-compiler', 'compiler.c',
+  c_args: '-DGIREPO_DEFAULT_SEARCH_PATH="@0"'.format(libdir_abs),
+  dependencies: [
+    girepo_internals_dep,
+    girepo_dep,
+  ],
+  install: true,
+)
+
+girgenerate = executable('g-ir-generate', 'generate.c',
+  c_args: '-DGIREPO_DEFAULT_SEARCH_PATH="@0"'.format(libdir_abs),
+  dependencies: [
+    girepo_internals_dep,
+    girepo_dep,
+  ],
+  install: true,
+)
+
+girinspect = executable('g-ir-inspect', 'g-ir-inspect.c',
+  dependencies: girepo_dep,
+  install: true,
+)


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