[gtksourceview/wip/chergert/meson] build: Port to the meson build system



commit b62417fb2c071b0e38835e3e9316532309f4e600
Author: Martin Blanchard <martin blanchard codethink co uk>
Date:   Thu Feb 22 11:40:07 2018 +0000

    build: Port to the meson build system
    
    This commit provides an initial port to the meson build system. See
    meson_options.txt for the changes to command line options. For a full
    build of GtkSourceView, the following will work.
    
     meson -Dglade_catalog=true -Dinstall_tests=true -Dgtk_doc=true build/

 data/glade/meson.build                             |  40 +++
 data/meson.build                                   |  25 ++
 docs/meson.build                                   |   3 +
 docs/reference/meson.build                         | 103 ++++++++
 gtksourceview/completion-providers/meson.build     |   1 +
 .../completion-providers/words/meson.build         |  53 ++++
 gtksourceview/meson.build                          | 291 +++++++++++++++++++++
 meson.build                                        | 250 ++++++++++++++++++
 meson_options.txt                                  |  19 ++
 po/meson.build                                     |   4 +
 tests/meson.build                                  |  33 +++
 testsuite/gtksourceview.test.in                    |   5 +
 testsuite/meson.build                              |  72 +++++
 13 files changed, 899 insertions(+)
---
diff --git a/data/glade/meson.build b/data/glade/meson.build
new file mode 100644
index 00000000..0b469c2a
--- /dev/null
+++ b/data/glade/meson.build
@@ -0,0 +1,40 @@
+# Note that we do not install in the detected GLADE_CATALOG_DIR
+# since we may not have permissions to do it, for instance if
+# compiling with a prefix while glade is installed in /usr.
+# We use the variable only to find the dtd file.
+# If you install gtksourceview and glade in different prefixes
+# and want to use the catalog in glade, you will need to set
+# the GLADE_CATALOG_SEARCH_PATH environment variable.
+
+catalog_in = configuration_data()
+catalog_in.set('GSV_API_VERSION', api_version)
+
+catalog_xml = configure_file(
+  input: 'gtksourceview.xml.in',
+  output: 'gtksourceview.xml',
+  configuration: catalog_in,
+  install: true,
+  install_dir: join_paths(
+    datadir,
+    'glade',
+    'catalogs'
+  )
+)
+
+if xmllint_prg.found()
+  catalog_dtd = join_paths(
+    gladeui_dep.get_pkgconfig_variable('catalogdir'),
+   'glade-catalog.dtd'
+  )
+
+  test(
+    'Validate Glade catalogue',
+    xmllint_prg,
+    args: [
+      '--dtdvalid',
+      catalog_dtd,
+      catalog_xml,
+      '--noout',
+    ]
+  )
+endif
diff --git a/data/meson.build b/data/meson.build
new file mode 100644
index 00000000..2ca97a5f
--- /dev/null
+++ b/data/meson.build
@@ -0,0 +1,25 @@
+if install_glade_catalog
+  subdir('glade')
+endif
+
+install_subdir('language-specs',
+    install_dir: pkgdatadir,
+  exclude_files: [ 'Makefile.am',
+                   'check-language.sh',
+                   'lang_v1_to_v2.xslt',
+                   'language-specs.its',
+                   'language-specs.pot',
+                   'testv1.lang',
+                   'ue2gsv.pl',
+                   'update-pot.sh' ]
+)
+
+install_subdir('styles',
+    install_dir: pkgdatadir,
+  exclude_files: [ 'Makefile.am',
+                   'check-style.sh',
+                   'styles.its',
+                   'styles.pot',
+                   'testdark.xml',
+                   'update-pot.sh' ]
+)
diff --git a/docs/meson.build b/docs/meson.build
new file mode 100644
index 00000000..84a9c7a3
--- /dev/null
+++ b/docs/meson.build
@@ -0,0 +1,3 @@
+if build_gtk_doc
+  subdir('reference')
+endif
diff --git a/docs/reference/meson.build b/docs/reference/meson.build
new file mode 100644
index 00000000..4f3a3619
--- /dev/null
+++ b/docs/reference/meson.build
@@ -0,0 +1,103 @@
+glib_prefix = glib_dep.get_pkgconfig_variable('prefix')
+glib_docpath = join_paths(glib_prefix, 'share', 'gtk-doc', 'html')
+
+gtk_prefix = gtk_dep.get_pkgconfig_variable('prefix')
+gtk_docpath = join_paths(gtk_prefix, 'share', 'gtk-doc', 'html')
+
+reference_private_h = [
+  'config.h',
+  'gtksource.h',
+  'gtksourcebuffer-private.h',
+  'gtksourcebufferinputstream.h',
+  'gtksourcebufferinternal.h',
+  'gtksourcebufferoutputstream.h',
+  'gtksourcecompletioncontainer.h',
+  'gtksourcecompletionmodel.h',
+  'gtksourcecompletion-private.h',
+  'gtksourcecompletionwordsbuffer.h',
+  'gtksourcecompletionwordslibrary.h',
+  'gtksourcecompletionwordsproposal.h',
+  'gtksourcecompletionwordsutils.h',
+  'gtksourcecontextengine.h',
+  'gtksourceencoding-private.h',
+  'gtksourceengine.h',
+  'gtksourcegutter-private.h',
+  'gtksourcegutterrendererlines.h',
+  'gtksourcegutterrenderermarks.h',
+  'gtksourcegutterrenderer-private.h',
+  'gtksourceiter.h',
+  'gtksourcelanguage-private.h',
+  'gtksourcemarkssequence.h',
+  'gtksourcepixbufhelper.h',
+  'gtksourceregex.h',
+  'gtksourcestyle-private.h',
+  'gtksourcetypes-private.h',
+  'gtksourceundomanagerdefault.h',
+  'gtksourceutils-private.h',
+]
+
+reference_content_files = files([
+  'lang-tutorial.xml',
+  'porting-guide-3-to-4.xml',
+])
+
+reference_sources = [
+  join_paths(srcdir, 'gtksourceview'),
+  join_paths(builddir, 'gtksourceview'),
+]
+
+into_xml = configure_file(
+         input: 'intro.xml.in',
+         output: 'intro.xml',
+  configuration: config_h
+)
+
+lang_reference_xml = configure_file(
+          input: 'lang-reference.xml.in',
+         output: 'lang-reference.xml',
+  configuration: config_h
+)
+
+style_reference_xml = configure_file(
+          input: 'style-reference.xml.in',
+         output: 'style-reference.xml',
+  configuration: config_h
+)
+
+reference_content_files += [
+  into_xml,
+  lang_reference_xml,
+  style_reference_xml,
+]
+
+gtksourceview_docs_xml = configure_file(
+          input: 'gtksourceview-docs.xml.in',
+         output: 'gtksourceview-docs.xml',
+  configuration: config_h
+)
+
+reference_scan_args = [
+  '--rebuild-types',
+  
'--ignore-decorators=GTK_SOURCE_DEPRECATED\w*\s*\([^)]*\)|GTK_SOURCE_DEPRECATED\w*|GTK_SOURCE_AVAILABLE\w*|_GTK_SOURCE_EXTERN',
+  '--deprecated-guards=GTKSOURCEVIEW_DISABLE_DEPRECATED',
+  '--ignore-headers=' + ' '.join(reference_private_h),
+]
+
+reference_fixxref_args = [
+  '--html-dir=@0@'.format(docpath),
+  '--extra-dir=@0@'.format(join_paths(glib_docpath, 'glib')),
+  '--extra-dir=@0@'.format(join_paths(glib_docpath, 'gobject')),
+  '--extra-dir=@0@'.format(join_paths(glib_docpath, 'gio')),
+  '--extra-dir=@0@'.format(join_paths(gtk_docpath, 'gtk')),
+]
+
+gnome.gtkdoc('@0@.0'.format(package_string),
+           main_xml: join_paths(builddir, '@0@'.format(gtksourceview_docs_xml)),
+  gobject_typesfile: 'gtksourceview-4.0.types',
+            src_dir: reference_sources,
+       dependencies: gtksource_dep,
+      content_files: reference_content_files,
+          scan_args: reference_scan_args,
+       fixxref_args: reference_fixxref_args,
+            install: true
+)
diff --git a/gtksourceview/completion-providers/meson.build b/gtksourceview/completion-providers/meson.build
new file mode 100644
index 00000000..f2613a31
--- /dev/null
+++ b/gtksourceview/completion-providers/meson.build
@@ -0,0 +1 @@
+subdir('words')
diff --git a/gtksourceview/completion-providers/words/meson.build 
b/gtksourceview/completion-providers/words/meson.build
new file mode 100644
index 00000000..7e351c3a
--- /dev/null
+++ b/gtksourceview/completion-providers/words/meson.build
@@ -0,0 +1,53 @@
+completionwords_c_args = [
+  '-DHAVE_CONFIG_H',
+  '-DGTK_SOURCE_COMPILATION',
+  '-DG_LOG_DOMAIN="GtkSourceView"',
+]
+
+completionwords_public_h = [
+  'gtksourcecompletionwords.h',
+]
+
+completionwords_public_c = [
+  'gtksourcecompletionwords.c',
+  'gtksourcecompletionwordsbuffer.c',
+  'gtksourcecompletionwordslibrary.c',
+  'gtksourcecompletionwordsproposal.c',
+  'gtksourcecompletionwordsutils.c',
+]
+
+install_headers(
+  completionwords_public_h,
+  install_dir: join_paths(
+    pkgincludedir,
+    'gtksourceview',
+    'completion-providers',
+    'words'
+  )
+)
+
+completionwords_lib = static_library(
+  package_string + 'completionwords',
+  completionwords_public_c,
+  include_directories: rootdir,
+  dependencies: core_dep,
+  c_args: completionwords_c_args,
+  install: false,
+)
+
+gtksource_libs += [
+  completionwords_lib,
+]
+
+completionwords_dep = declare_dependency(
+  link_with: completionwords_lib,
+  include_directories: rootdir,
+  dependencies: core_dep,
+)
+
+gtksource_deps += completionwords_dep
+
+extra_public_sources += files([
+  'gtksourcecompletionwords.c',
+  'gtksourcecompletionwords.h',
+])
diff --git a/gtksourceview/meson.build b/gtksourceview/meson.build
new file mode 100644
index 00000000..b87fba92
--- /dev/null
+++ b/gtksourceview/meson.build
@@ -0,0 +1,291 @@
+core_public_h = files([
+  'gtksource.h',
+  'gtksourceautocleanups.h',
+  'gtksourcebuffer.h',
+  'gtksourcecompletion.h',
+  'gtksourcecompletioncontext.h',
+  'gtksourcecompletioninfo.h',
+  'gtksourcecompletionitem.h',
+  'gtksourcecompletionproposal.h',
+  'gtksourcecompletionprovider.h',
+  'gtksourceencoding.h',
+  'gtksourcefile.h',
+  'gtksourcefileloader.h',
+  'gtksourcefilesaver.h',
+  'gtksourcegutter.h',
+  'gtksourcegutterrenderer.h',
+  'gtksourcegutterrendererpixbuf.h',
+  'gtksourcegutterrenderertext.h',
+  'gtksourceinit.h',
+  'gtksourcelanguage.h',
+  'gtksourcelanguagemanager.h',
+  'gtksourcemap.h',
+  'gtksourcemark.h',
+  'gtksourcemarkattributes.h',
+  'gtksourceprintcompositor.h',
+  'gtksourceregion.h',
+  'gtksourcesearchcontext.h',
+  'gtksourcesearchsettings.h',
+  'gtksourcespacedrawer.h',
+  'gtksourcestyle.h',
+  'gtksourcestylescheme.h',
+  'gtksourcestyleschemechooser.h',
+  'gtksourcestyleschemechooserbutton.h',
+  'gtksourcestyleschemechooserwidget.h',
+  'gtksourcestyleschememanager.h',
+  'gtksourcetag.h',
+  'gtksourcetypes.h',
+  'gtksourceundomanager.h',
+  'gtksourceutils.h',
+  'gtksourceview.h',
+])
+
+core_public_c = files([
+  'gtksourcebuffer.c',
+  'gtksourcecompletion.c',
+  'gtksourcecompletioncontext.c',
+  'gtksourcecompletioninfo.c',
+  'gtksourcecompletionitem.c',
+  'gtksourcecompletionproposal.c',
+  'gtksourcecompletionprovider.c',
+  'gtksourceencoding.c',
+  'gtksourcefile.c',
+  'gtksourcefileloader.c',
+  'gtksourcefilesaver.c',
+  'gtksourcegutter.c',
+  'gtksourcegutterrenderer.c',
+  'gtksourcegutterrendererpixbuf.c',
+  'gtksourcegutterrenderertext.c',
+  'gtksourceinit.c',
+  'gtksourcelanguage.c',
+  'gtksourcelanguagemanager.c',
+  'gtksourcemap.c',
+  'gtksourcemark.c',
+  'gtksourcemarkattributes.c',
+  'gtksourceprintcompositor.c',
+  'gtksourceregion.c',
+  'gtksourcesearchcontext.c',
+  'gtksourcesearchsettings.c',
+  'gtksourcespacedrawer.c',
+  'gtksourcestyle.c',
+  'gtksourcestylescheme.c',
+  'gtksourcestyleschemechooser.c',
+  'gtksourcestyleschemechooserbutton.c',
+  'gtksourcestyleschemechooserwidget.c',
+  'gtksourcestyleschememanager.c',
+  'gtksourcetag.c',
+  'gtksourceundomanager.c',
+  'gtksourceutils.c',
+  'gtksourceversion.c',
+  'gtksourceview.c',
+])
+
+core_private_c = files([
+  'gtksourcebufferinputstream.c',
+  'gtksourcebufferinternal.c',
+  'gtksourcebufferoutputstream.c',
+  'gtksourcecompletioncontainer.c',
+  'gtksourcecompletionmodel.c',
+  'gtksourcecontextengine.c',
+  'gtksourceengine.c',
+  'gtksourcegutterrendererlines.c',
+  'gtksourcegutterrenderermarks.c',
+  'gtksourceiter.c',
+  'gtksourcelanguage-parser-2.c',
+  'gtksourcemarkssequence.c',
+  'gtksourcepixbufhelper.c',
+  'gtksourceregex.c',
+  'gtksourceundomanagerdefault.c',
+])
+
+core_c_args = [
+  '-DHAVE_CONFIG_H',
+  '-DGTK_SOURCE_COMPILATION',
+  '-DG_LOG_DOMAIN="GtkSourceView"',
+]
+
+core_deps = [
+  libm_dep,
+  glib_dep,
+  gobject_dep,
+  gio_dep,
+  gtk_dep,
+  libxml_dep,
+]
+
+if config_h.has('OS_OSX')
+  core_c_args += '-xobjective-c'
+  core_deps += [
+    cocoa_dep,
+  ]
+endif
+
+core_enums_header = '''
+#if !defined (GTK_SOURCE_H_INSIDE) && !defined (GTK_SOURCE_COMPILATION)
+# error "Only <gtksourceview/gtksource.h> can be included directly."
+#endif
+
+#include <gtksourceview/gtksourceversion.h>
+'''
+
+core_enums = gnome.mkenums_simple('gtksource-enumtypes',
+            sources: core_public_h,
+  identifier_prefix: 'GtkSource',
+      symbol_prefix: 'gtk_source',
+      header_prefix: core_enums_header,
+          decorator: 'GTK_SOURCE_ENUM_EXTERN',
+     install_header: true,
+        install_dir: join_paths(pkgincludedir, 'gtksourceview'),
+)
+
+version_h = configuration_data()
+version_h.set('GTK_SOURCE_MAJOR_VERSION', version_major)
+version_h.set('GTK_SOURCE_MINOR_VERSION', version_minor)
+version_h.set('GTK_SOURCE_MICRO_VERSION', version_micro)
+
+gtksourceversion_h = configure_file(
+          input: 'gtksourceversion.h.in',
+         output: 'gtksourceversion.h',
+  configuration: version_h,
+        install: true,
+    install_dir: join_paths(pkgincludedir, 'gtksourceview'),
+)
+
+core_sources = [
+  core_public_c,
+  core_private_c,
+  core_enums,
+  gtksourceversion_h,
+]
+
+install_headers(
+  core_public_h,
+  install_dir: join_paths(pkgincludedir, 'gtksourceview'),
+)
+
+core_lib = static_library(package_string + 'core', core_sources,
+  include_directories: rootdir,
+         dependencies: core_deps,
+               c_args: core_c_args,
+              install: false
+)
+
+gtksource_libs = [
+  core_lib,
+]
+
+core_enums_h = core_enums.get(1)
+
+core_dep = declare_dependency(
+            link_with: core_lib,
+  include_directories: rootdir,
+         dependencies: core_deps,
+              sources: [core_enums_h]
+)
+
+gtksource_deps = [
+  core_dep,
+]
+
+extra_public_sources = []
+
+subdir('completion-providers')
+
+gtksource_res = gnome.compile_resources(
+  'gtksourceview-gresources',
+  'gtksourceview.gresource.xml'
+)
+
+gtksource_lib = shared_library(package_string, gtksource_res,
+                version: lib_version,
+    include_directories: rootdir,
+           dependencies: gtksource_deps,
+             link_whole: gtksource_libs,
+                 c_args: core_c_args,
+                install: true,
+  gnu_symbol_visibility: 'hidden',
+)
+
+gtksource_dep_sources = [
+  core_enums_h,
+]
+
+if generate_gir
+  gtksource_gir_sources = [
+    core_public_c,
+    core_public_h,
+    core_enums_h,
+    extra_public_sources,
+  ]
+
+  gtksource_gir = gnome.generate_gir(gtksource_lib,
+                sources: gtksource_gir_sources,
+              nsversion: api_version,
+              namespace: 'GtkSource',
+          symbol_prefix: 'gtk_source',
+      identifier_prefix: 'GtkSource',
+        export_packages: [package_string],
+              link_with: gtksource_lib,
+               includes: [ 'Gdk-3.0', 'Gtk-3.0' ],
+                install: true,
+        install_dir_gir: girdir,
+    install_dir_typelib: typelibdir,
+             extra_args: [ '--c-include=gtksourceview/gtksource.h',
+                          '--warn-all' ],
+  )
+
+  gtksource_dep_sources += [
+    gtksource_gir,
+  ]
+
+  if generate_vapi
+    configure_file(
+        input: 'GtkSource.metadata.in',
+       output: 'GtkSource-@0@.metadata'.format(api_version),
+         copy: true,
+    )
+
+    gtksource_vapi = gnome.generate_vapi(package_string,
+            sources: gtksource_gir.get(0),
+      metadata_dirs: join_paths(builddir, 'gtksourceview'),
+            install: true,
+        install_dir: vapidir,
+           packages: [ 'atk',
+                       'gdk-3.0',
+                      'gdk-pixbuf-2.0',
+                      'gio-2.0',
+                      'gtk+-3.0',
+                      'pango',
+                      'cairo' ],
+    )
+  endif
+endif
+
+gtksource_dep = declare_dependency(
+            link_with: gtksource_lib,
+  include_directories: rootdir,
+         dependencies: gtksource_deps,
+              sources: gtksource_dep_sources,
+)
+
+gtksource_pc_reqs = [
+  'glib-2.0 @0@'.format(glib_req),
+  'gobject-2.0 @0@'.format(glib_req),
+  'gio-2.0 @0@'.format(glib_req),
+  'gtk+-3.0 @0@'.format(gtk_req),
+]
+
+gtksource_pc_private_reqs = [
+  'libxml-2.0 @0@'.format(libxml_req),
+]
+
+gtksource_pc = pkg.generate(
+              name: package_string,
+       description: 'Source code editing Gtk+ widget.',
+          requires: gtksource_pc_reqs,
+  requires_private: gtksource_pc_private_reqs,
+           version: version,
+           subdirs: package_string,
+         libraries: gtksource_lib,
+       install_dir: pkgconfigdir,
+)
diff --git a/meson.build b/meson.build
new file mode 100644
index 00000000..11c2cdf6
--- /dev/null
+++ b/meson.build
@@ -0,0 +1,250 @@
+project('gtksourceview', 'c',
+          version: '4.3.0',
+          license: 'LGPL-2.1-or-later',
+    meson_version: '>= 0.50.0',
+  default_options: [ 'c_std=gnu99',
+                     'buildtype=debugoptimized',
+                     'warning_level=2' ],
+)
+
+i18n = import('i18n')
+gnome = import('gnome')
+pkg = import('pkgconfig')
+
+# Versioning
+version = meson.project_version()
+version_arr = version.split('.')
+version_major = version_arr[0].to_int()
+version_minor = version_arr[1].to_int()
+version_micro = version_arr[2].to_int()
+
+api_version = '4'
+
+lib_version = '0.0.0'
+lib_version_arr = version.split('.')
+lib_version_major = version_arr[0].to_int()
+lib_version_minor = version_arr[1].to_int()
+lib_version_micro = version_arr[2].to_int()
+
+package_name = meson.project_name()
+package_string = '@0@-@1@'.format(package_name, api_version)
+
+# Paths
+rootdir = include_directories('.')
+srcdir = meson.source_root()
+builddir = meson.build_root()
+
+prefix = get_option('prefix')
+
+includedir = join_paths(prefix, get_option('includedir'))
+libdir = join_paths(prefix, get_option('libdir'))
+libexecdir = join_paths(prefix, get_option('libexecdir'))
+typelibdir = join_paths(libdir, 'girepository-1.0')
+datadir = join_paths(prefix, get_option('datadir'))
+localedir = join_paths(prefix, get_option('localedir'))
+pkgincludedir = join_paths(includedir, package_string)
+pkgconfigdir = join_paths(libdir, 'pkgconfig')
+pkgdatadir = join_paths(datadir, package_string)
+girdir = join_paths(datadir, 'gir-1.0')
+vapidir = join_paths(datadir, 'vala', 'vapi')
+mandir = join_paths(prefix, get_option('mandir'))
+testexecdir = join_paths(libexecdir, 'installed-tests', package_string)
+testdatadir = join_paths(datadir, 'installed-tests', package_string)
+docpath = join_paths(datadir, 'gtk-doc', 'html', package_string)
+
+# Options
+install_glade_catalog = get_option('glade_catalog')
+generate_gir = get_option('gir')
+generate_vapi = generate_gir and get_option('vapi')
+build_gtk_doc = get_option('gtk_doc')
+
+# Dependencies
+cc = meson.get_compiler('c')
+
+libm_dep = cc.find_library('m', required: false)
+
+glib_req = '>= 2.48'
+gtk_req = '>= 3.20'
+libxml_req = '>= 2.6'
+gladeui_req = '>= 3.9'
+introspection_req  = '>= 1.42.0'
+gtk_doc_req = '>= 1.25'
+
+glib_dep = dependency('glib-2.0', version: glib_req)
+gobject_dep = dependency('gobject-2.0', version: glib_req)
+gio_dep = dependency('gio-2.0', version: glib_req)
+gtk_dep = dependency('gtk+-3.0', version: gtk_req)
+libxml_dep = dependency('libxml-2.0', version: libxml_req)
+
+gtk_quartz_dep = dependency('gtk+-quartz-3.0', version: gtk_doc_req, required: false)
+
+if install_glade_catalog
+  gladeui_dep = dependency('gladeui-2.0', version: gladeui_req)
+else
+  gladeui_dep = []
+endif
+
+if generate_gir
+  introspection_dep = dependency('gobject-introspection-1.0', version: introspection_req)
+else
+  introspection_dep = []
+endif
+
+if generate_vapi
+  vapigen_dep = dependency('vapigen')
+else
+  vapigen_dep = []
+endif
+
+if build_gtk_doc
+  gtk_doc_dep = dependency('gtk-doc', version: gtk_doc_req)
+else
+  gtk_doc_dep = []
+endif
+
+xmllint_prg = find_program('xmllint', required: false)
+
+# Configurations
+add_project_arguments([
+  '-DG_DISABLE_DEPRECATED',
+  '-DGDK_DISABLE_DEPRECATED',
+  '-DGTK_DISABLE_DEPRECATED',
+  '-DGDK_PIXBUF_DISABLE_DEPRECATED',
+], language: 'c')
+
+config_h = configuration_data()
+config_h.set_quoted('GSV_API_VERSION', api_version)
+config_h.set_quoted('GETTEXT_PACKAGE', package_string)
+config_h.set_quoted('DATADIR', datadir)
+
+check_headers = [
+  ['unistd.h', 'HAVE_UNISTD_H'],
+]
+
+foreach header: check_headers
+  if cc.has_header(header.get(0))
+    config_h.set(header.get(1), 1)
+  endif
+endforeach
+
+if build_machine.system() == 'darwin' and gtk_quartz_dep.found()
+  cocoa_dep = dependency('appleframeworks', modules: 'Cocoa', required: false)
+  assert(cocoa_dep.found(), 'Dependency appleframeworks not found')
+  config_h.set_quoted('OS_OSX', 'yes')
+endif
+
+# Compiler flags and warnings
+global_c_args = []
+test_c_args = [
+  '-Wcast-align',
+  '-Wdeclaration-after-statement',
+  '-Werror=address',
+  '-Werror=array-bounds',
+  '-Werror=empty-body',
+  '-Werror=implicit',
+  '-Werror=implicit-function-declaration',
+  '-Werror=incompatible-pointer-types',
+  '-Werror=init-self',
+  '-Werror=int-conversion',
+  '-Werror=int-to-pointer-cast',
+  '-Werror=main',
+  '-Werror=misleading-indentation',
+  '-Werror=missing-braces',
+  '-Werror=missing-include-dirs',
+  '-Werror=nonnull',
+  '-Werror=overflow',
+  '-Werror=parenthesis',
+  '-Werror=pointer-arith',
+  '-Werror=pointer-to-int-cast',
+  '-Werror=return-type',
+  '-Werror=sequence-point',
+  '-Werror=shadow',
+  '-Werror=strict-prototypes',
+  '-Werror=trigraphs',
+  '-Werror=undef',
+  '-Werror=write-strings',
+  '-Wformat-nonliteral',
+  ['-Werror=format-security', '-Werror=format=2' ],
+  '-Wignored-qualifiers',
+  '-Wimplicit-function-declaration',
+  '-Wlogical-op',
+  '-Wmissing-format-attribute',
+  '-Wmissing-include-dirs',
+  '-Wmissing-noreturn',
+  '-Wnested-externs',
+  '-Wno-cast-function-type',
+  '-Wno-missing-field-initializers',
+  '-Wno-sign-compare',
+  '-Wno-unused-parameter',
+  '-Wold-style-definition',
+  '-Wpointer-arith',
+  '-Wstrict-prototypes',
+  '-Wswitch-default',
+  '-Wswitch-enum',
+  '-Wundef',
+  '-Wuninitialized',
+  '-Wunused',
+  '-fno-strict-aliasing',
+]
+if get_option('buildtype') != 'plain'
+  test_c_args += '-fstack-protector-strong'
+endif
+
+foreach arg: test_c_args
+  if cc.has_multi_arguments(arg)
+    global_c_args += arg
+  endif
+endforeach
+
+if cc.has_multi_arguments('-Wmissing-declarations')
+  global_c_args += '-Wmissing-declarations'
+endif
+
+# Detect and set symbol visibility
+if get_option('default_library') != 'static'
+  if host_machine.system() == 'windows'
+    config_h.set('DLL_EXPORT', true)
+    if cc.get_id() == 'msvc'
+      config_h.set('_GTK_SOURCE_EXTERN', '__declspec(dllexport) extern')
+    elif cc.has_argument('-fvisibility=hidden')
+      config_h.set('_GTK_SOURCE_EXTERN', '__attribute__((visibility("default"))) __declspec(dllexport) 
extern')
+    endif
+  elif cc.has_argument('-fvisibility=hidden')
+    config_h.set('_GTK_SOURCE_EXTERN', '__attribute__((visibility("default"))) extern')
+  endif
+endif
+
+add_project_arguments(global_c_args, language: 'c')
+
+configure_file(
+         output: 'config.h',
+  configuration: config_h
+)
+
+subdir('gtksourceview')
+subdir('data')
+subdir('docs')
+subdir('po')
+subdir('tests')
+subdir('testsuite')
+
+summary = [
+  '',
+  '------',
+  'GtkSourceView @0@ (@1@)'.format(version, api_version),
+  '',
+  '  Documentation: @0@'.format(build_gtk_doc),
+  '  Glade catalog: @0@'.format(install_glade_catalog),
+  '  Install tests: @0@'.format(get_option('install_tests')),
+  '  Introspection: @0@'.format(generate_gir),
+  '      Vala vapi: @0@'.format(generate_vapi),
+  '',
+  'Directories:',
+  '         prefix: @0@'.format(prefix),
+  '     includedir: @0@'.format(includedir),
+  '         libdir: @0@'.format(libdir),
+  '        datadir: @0@'.format(datadir),
+  '------',
+]
+
+message('\n'.join(summary))
diff --git a/meson_options.txt b/meson_options.txt
new file mode 100644
index 00000000..a58139e0
--- /dev/null
+++ b/meson_options.txt
@@ -0,0 +1,19 @@
+option('glade_catalog',
+       type: 'boolean', value: false,
+       description: 'Whether to install Glade catalog')
+
+option('install_tests',
+       type: 'boolean', value: false,
+       description: 'Install test programs')
+
+option('gir',
+       type: 'boolean', value: true,
+       description: 'Generate gir data (requires gobject-introspection)')
+
+option('vapi',
+       type: 'boolean', value: true,
+       description: 'Generate vapi data (requires vapigen)')
+
+option('gtk_doc',
+       type: 'boolean', value: false,
+       description: 'Build reference manual (requires gtk-doc)')
diff --git a/po/meson.build b/po/meson.build
new file mode 100644
index 00000000..b182d968
--- /dev/null
+++ b/po/meson.build
@@ -0,0 +1,4 @@
+i18n.gettext(
+  package_string,
+  preset: 'glib'
+)
diff --git a/tests/meson.build b/tests/meson.build
new file mode 100644
index 00000000..e1430fbc
--- /dev/null
+++ b/tests/meson.build
@@ -0,0 +1,33 @@
+tests_c_args = [
+  '-DG_LOG_DOMAIN="GtkSourceView"',
+  '-DTOP_SRCDIR="@0@"'.format(srcdir),
+]
+
+tests_sources = {
+                 'completion': ['test-completion.c'],
+                    'int2str': ['test-int2str.c'],
+                     'search': ['test-search.c'],
+        'search-performances': ['test-search-performances.c'],
+              'space-drawing': ['test-space-drawing.c'],
+  'undo-manager-performances': ['test-undo-manager-performances.c'],
+                     'widget': ['test-widget.c'],
+}
+
+tests_resources = {
+  'completion': 'test-completion.gresource.xml',
+      'search': 'test-search.gresource.xml',
+      'widget': 'test-widget.gresource.xml',
+}
+
+foreach test_name, test_sources: tests_sources
+  if tests_resources.has_key(test_name)
+    test_sources += gnome.compile_resources(
+      'test-@0@-resources'.format(test_name),
+      tests_resources.get(test_name),
+    )
+  endif
+
+  executable('test-@0@'.format(test_name), test_sources,
+          c_args: tests_c_args,
+    dependencies: [gtksource_dep])
+endforeach
diff --git a/testsuite/gtksourceview.test.in b/testsuite/gtksourceview.test.in
new file mode 100644
index 00000000..46a83d5c
--- /dev/null
+++ b/testsuite/gtksourceview.test.in
@@ -0,0 +1,5 @@
+[Test]
+Description=GtkSourceView @test@
+Exec=@testexecdir@/@test@
+Type=session
+Output=TAP
diff --git a/testsuite/meson.build b/testsuite/meson.build
new file mode 100644
index 00000000..3335bca2
--- /dev/null
+++ b/testsuite/meson.build
@@ -0,0 +1,72 @@
+test_env = [
+  'G_TEST_SRCDIR=@0@'.format(meson.current_source_dir()),
+  'G_TEST_BUILDDIR=@0@'.format(meson.current_build_dir()),
+  'G_DEBUG=gc-friendly',
+  'GSETTINGS_BACKEND=memory',
+  'MALLOC_CHECK_=2',
+]
+
+testsuite_c_args = [
+  '-DG_LOG_DOMAIN="GtkSourceView"',
+  '-DTOP_SRCDIR="@0@"'.format(srcdir),
+]
+
+testsuite_sources = [
+  ['test-buffer'],
+  ['test-buffer-input-stream'],
+  ['test-buffer-output-stream'],
+  ['test-completion-model'],
+  ['test-completion-words'],
+  ['test-encoding'],
+  ['test-file-loader'],
+  ['test-file-saver'],
+  ['test-iter'],
+  ['test-language'],
+  ['test-languagemanager'],
+  ['test-mark'],
+  ['test-printcompositor'],
+  ['test-regex'],
+  ['test-region'],
+  ['test-search-context'],
+  ['test-space-drawer'],
+  ['test-stylescheme'],
+  ['test-styleschememanager'],
+  ['test-undo-manager'],
+  ['test-utils'],
+  ['test-view'],
+]
+
+foreach test: testsuite_sources
+  test_name = test.get(0)
+  test_sources = [
+    '@0@.c'.format(test_name),
+  ]
+
+  test_exe = executable(test_name, test_sources,
+          c_args: testsuite_c_args,
+    dependencies: [gtksource_dep],
+         install: get_option('install_tests'),
+     install_dir: testexecdir
+  )
+
+  test(test_name, test_exe, suite: package_string, env: test_env)
+
+  if get_option('install_tests')
+    test_t = configuration_data()
+    test_t.set('testexecdir', testexecdir)
+    test_t.set('test', test_name)
+
+    configure_file(
+              input: 'gtksourceview.test.in',
+             output: '@0@.test'.format(test_name),
+      configuration: test_t,
+            install: true,
+        install_dir: testdatadir
+    )
+  endif
+endforeach
+
+if get_option('install_tests')
+  install_subdir('language-specs', install_dir: testexecdir)
+  install_subdir('styles', install_dir: testexecdir)
+endif


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