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



commit 27679e1652cd5b1d521fd41eb82d7d44e20d72b7
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/meson.build               |   49 ++++++++++++++++
 girepository/cmph/meson.build |   50 +++++++++++++++++
 girepository/meson.build      |  123 +++++++++++++++++++++++++++++++++++++++++
 giscanner/meson.build         |   74 ++++++++++++++++++++++++
 meson.build                   |   89 +++++++++++++++++++++++++++++
 meson_options.txt             |   11 ++++
 tools/meson.build             |   51 +++++++++++++++++
 11 files changed, 460 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/meson.build b/gir/meson.build
new file mode 100644
index 0000000..257804b
--- /dev/null
+++ b/gir/meson.build
@@ -0,0 +1,49 @@
+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)
+
+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..cf0ed76
--- /dev/null
+++ b/girepository/meson.build
@@ -0,0 +1,123 @@
+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',
+]
+
+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..352149e
--- /dev/null
+++ b/meson.build
@@ -0,0 +1,89 @@
+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(),
+  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') # TODO
+
+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
diff --git a/tools/meson.build b/tools/meson.build
new file mode 100644
index 0000000..7f32cbb
--- /dev/null
+++ b/tools/meson.build
@@ -0,0 +1,51 @@
+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
+
+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])
+  configure_file(
+    input: 'g-ir-tool-template.in',
+    output: tool[0],
+    configuration: tools_conf,
+    install: true,
+    install_dir: get_option('bindir'),
+  )
+endforeach
+
+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]