[tepl] meson: start to port the build system to Meson



commit 512266647acc4b49b17b85283e7937ce90367afe
Author: Sébastien Wilmet <swilmet gnome org>
Date:   Sat Mar 28 20:28:22 2020 +0100

    meson: start to port the build system to Meson

 .gitignore            |   1 +
 meson.build           | 139 +++++++++++++++++++++++++++++++++++++++++++++
 meson_options.txt     |  13 +++++
 po/meson.build        |   4 ++
 tepl/meson.build      | 152 ++++++++++++++++++++++++++++++++++++++++++++++++++
 tepl/symbol.map       |   6 ++
 tests/meson.build     |  16 ++++++
 testsuite/meson.build |  24 ++++++++
 8 files changed, 355 insertions(+)
---
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..84c048a
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1 @@
+/build/
diff --git a/meson.build b/meson.build
new file mode 100644
index 0000000..af79c64
--- /dev/null
+++ b/meson.build
@@ -0,0 +1,139 @@
+# Convention:
+# - Local variables in lower_case.
+# - Global variables in UPPER_CASE.
+# See: https://github.com/mesonbuild/meson/issues/2607
+
+project(
+  'tepl', 'c',
+  meson_version: '>= 0.53',
+  version: '4.5.0',
+  default_options: ['warning_level=2']
+)
+
+GNOME = import('gnome')
+PKG_CONFIG = import('pkgconfig')
+I18N = import('i18n')
+
+# Libtool versioning
+#
+# For development releases (if the minor package version is odd), keep the same
+# Libtool version.
+#
+# For a new minor stable release (when incrementing the minor package version
+# to an even number), apply the following algorithm step by step:
+# 1. If the library source code has changed at all since the last
+#    update, then increment REVISION.
+# 2. If any exported functions or data have been added, removed, or
+#    changed since the last update, increment CURRENT and set REVISION
+#    to 0.
+# 3. If any exported functions or data have been added since the last
+#    public release, increment AGE.
+# 4. If any exported functions or data have been removed since the last
+#    public release, set AGE to 0.
+#
+# When incrementing the API version (usually for a new major package version),
+# set CURRENT, REVISION and AGE to 0 since it's like a new library.
+lt_current = 1
+lt_revision = 0
+lt_age = 1
+TEPL_LT_VERSION = '@0@.@1@.@2@'.format(lt_current, lt_revision, lt_age)
+
+# API version, used for parallel installability.
+TEPL_API_VERSION = '4'
+
+TEPL_PUBLIC_DEPS = [
+  dependency('gio-2.0', version: '>= 2.56'),
+  dependency('gtk+-3.0', version: '>= 3.22'),
+  dependency('gtksourceview-4', version: '>= 4.0'),
+  dependency('amtk-5', version: '>= 5.0')
+]
+TEPL_PRIVATE_DEPS = [
+  dependency('libxml-2.0', version: '>= 2.5'),
+  dependency('uchardet')
+]
+TEPL_DEPS = [TEPL_PUBLIC_DEPS, TEPL_PRIVATE_DEPS]
+
+# config.h
+
+config_data = configuration_data()
+GETTEXT_PACKAGE_NAME = 'tepl-' + TEPL_API_VERSION
+config_data.set_quoted('GETTEXT_PACKAGE', GETTEXT_PACKAGE_NAME)
+config_data.set10('ENABLE_GVFS_METADATA', get_option('gvfs_metadata'))
+configure_file(
+  output: 'config.h',
+  configuration: config_data
+)
+
+# Misc
+
+ROOT_INCLUDE_DIR = include_directories('.')
+
+add_project_arguments(
+  '-DG_LOG_DOMAIN="@0@"'.format(meson.project_name()),
+  language: 'c'
+)
+
+#####
+# CFLAGS
+# Try to mimic the AX_COMPILER_FLAGS Autotools macro.
+# Some flags are missing when using only the builtin warning_level meson option,
+# even at the maximum level.
+# The following warning_cflags suppose that warning_level=2.
+
+warning_cflags = [
+  '-fno-strict-aliasing',
+  '-Wundef',
+  '-Wnested-externs',
+  '-Wwrite-strings',
+  '-Wpointer-arith',
+  '-Wmissing-declarations',
+  '-Wmissing-prototypes',
+  '-Wstrict-prototypes',
+  '-Wredundant-decls',
+  '-Wno-unused-parameter',
+  '-Wno-missing-field-initializers',
+  '-Wdeclaration-after-statement',
+  '-Wformat=2',
+  '-Wold-style-definition',
+  '-Wcast-align',
+  '-Wformat-nonliteral',
+  '-Wformat-security',
+  '-Wsign-compare',
+  '-Wstrict-aliasing',
+  '-Wshadow',
+  '-Winline',
+  '-Wpacked',
+  '-Wmissing-format-attribute',
+  '-Wmissing-noreturn',
+  '-Winit-self',
+  '-Wredundant-decls',
+  '-Wmissing-include-dirs',
+  '-Wunused-but-set-variable',
+  '-Warray-bounds',
+  '-Wimplicit-function-declaration',
+  '-Wreturn-type',
+  '-Wswitch-enum',
+  '-Wswitch-default',
+  '-Wduplicated-cond',
+  '-Wduplicated-branches',
+  '-Wlogical-op',
+  '-Wrestrict',
+  '-Wnull-dereference',
+  '-Wjump-misses-init',
+  '-Wdouble-promotion'
+]
+
+c_compiler = meson.get_compiler('c')
+supported_warning_cflags = c_compiler.get_supported_arguments(warning_cflags)
+add_project_arguments(supported_warning_cflags, language: 'c')
+##### end CFLAGS
+
+subdir('po')
+subdir('tepl')
+subdir('tests')
+subdir('testsuite')
+
+summary('API version', TEPL_API_VERSION)
+summary('Prefix', get_option('prefix'))
+summary('GVfs metadata', get_option('gvfs_metadata'))
+summary('API documentation', get_option('gtk_doc'))
diff --git a/meson_options.txt b/meson_options.txt
new file mode 100644
index 0000000..2068642
--- /dev/null
+++ b/meson_options.txt
@@ -0,0 +1,13 @@
+option(
+  'gtk_doc',
+  type: 'boolean', value: false,
+  description: 'Build API reference (requires gtk-doc)'
+)
+
+# Using GVfs to store metadata is recommended on platforms that support it.
+# Otherwise there is a fallback implementation, but it's less optimal.
+option(
+  'gvfs_metadata',
+  type: 'boolean', value: true,
+  description: 'Use GVfs to store additional file metadata'
+)
diff --git a/po/meson.build b/po/meson.build
new file mode 100644
index 0000000..efd359d
--- /dev/null
+++ b/po/meson.build
@@ -0,0 +1,4 @@
+I18N.gettext(
+  GETTEXT_PACKAGE_NAME,
+  preset: 'glib'
+)
diff --git a/tepl/meson.build b/tepl/meson.build
new file mode 100644
index 0000000..8bc7080
--- /dev/null
+++ b/tepl/meson.build
@@ -0,0 +1,152 @@
+tepl_public_headers = [
+  'tepl.h',
+  'tepl-abstract-factory.h',
+  'tepl-abstract-factory-vala.h',
+  'tepl-application.h',
+  'tepl-application-window.h',
+  'tepl-buffer.h',
+  'tepl-encoding.h',
+  'tepl-file.h',
+  'tepl-file-loader.h',
+  'tepl-file-metadata.h',
+  'tepl-file-saver.h',
+  'tepl-fold-region.h',
+  'tepl-gutter-renderer-folds.h',
+  'tepl-info-bar.h',
+  'tepl-init.h',
+  'tepl-io-error-info-bars.h',
+  'tepl-iter.h',
+  'tepl-menu-shell.h',
+  'tepl-metadata-manager.h',
+  'tepl-metadata-store.h',
+  'tepl-notebook.h',
+  'tepl-tab.h',
+  'tepl-tab-group.h',
+  'tepl-tab-label.h',
+  'tepl-types.h',
+  'tepl-utils.h',
+  'tepl-view.h'
+]
+
+tepl_public_c_files = [
+  'tepl-abstract-factory.c',
+  'tepl-abstract-factory-vala.c',
+  'tepl-application.c',
+  'tepl-application-window.c',
+  'tepl-buffer.c',
+  'tepl-encoding.c',
+  'tepl-file.c',
+  'tepl-file-loader.c',
+  'tepl-file-metadata.c',
+  'tepl-file-saver.c',
+  'tepl-fold-region.c',
+  'tepl-gutter-renderer-folds.c',
+  'tepl-info-bar.c',
+  'tepl-init.c',
+  'tepl-io-error-info-bars.c',
+  'tepl-iter.c',
+  'tepl-menu-shell.c',
+  'tepl-metadata-manager.c',
+  'tepl-metadata-store.c',
+  'tepl-notebook.c',
+  'tepl-tab.c',
+  'tepl-tab-group.c',
+  'tepl-tab-label.c',
+  'tepl-utils.c',
+  'tepl-view.c'
+]
+
+tepl_private_headers = [
+  'tepl-buffer-input-stream.h',
+  'tepl-close-confirm-dialog-single.h',
+  'tepl-encoding-converter.h',
+  'tepl-encoding-private.h',
+  'tepl-file-content.h',
+  'tepl-file-content-loader.h',
+  'tepl-io-error-info-bar.h',
+  'tepl-progress-info-bar.h',
+  'tepl-signal-group.h',
+  'tepl-tab-saving.h'
+]
+
+tepl_private_c_files = [
+  'tepl-buffer-input-stream.c',
+  'tepl-close-confirm-dialog-single.c',
+  'tepl-encoding-converter.c',
+  'tepl-file-content.c',
+  'tepl-file-content-loader.c',
+  'tepl-io-error-info-bar.c',
+  'tepl-progress-info-bar.c',
+  'tepl-signal-group.c',
+  'tepl-tab-saving.c'
+]
+
+headers_install_dir = get_option('includedir') / 'tepl-@0@/tepl/'.format(TEPL_API_VERSION)
+install_headers(
+  tepl_public_headers,
+  install_dir: headers_install_dir
+)
+
+tepl_enum_types = GNOME.mkenums_simple(
+  'tepl-enum-types',
+  sources: tepl_public_headers,
+  install_header: true,
+  install_dir: headers_install_dir
+)
+
+tepl_static_lib = static_library(
+  'tepl-static',
+  [tepl_public_c_files,
+   tepl_private_c_files,
+   tepl_enum_types],
+  pic: true, # tepl_static_lib is linked in a shared library.
+  include_directories: ROOT_INCLUDE_DIR,
+  dependencies: TEPL_DEPS,
+  c_args: '-DTEPL_COMPILATION'
+)
+
+# For unit tests, to be able to test private functions.
+TEPL_STATIC_DEP = declare_dependency(
+  include_directories: ROOT_INCLUDE_DIR,
+  link_with: tepl_static_lib,
+  sources: tepl_enum_types[1],
+  dependencies: TEPL_DEPS
+)
+
+symbol_map = join_paths(meson.current_source_dir(), 'symbol.map')
+
+tepl_shared_lib = shared_library(
+  'tepl-@0@'.format(TEPL_API_VERSION),
+  link_whole: tepl_static_lib,
+  link_args: '-Wl,--version-script,' + symbol_map,
+  link_depends: symbol_map,
+  version: TEPL_LT_VERSION,
+  install: true
+)
+
+PKG_CONFIG.generate(
+  filebase: 'tepl-@0@'.format(TEPL_API_VERSION),
+  name: 'Tepl',
+  description: 'Text editor product line',
+  libraries: tepl_shared_lib,
+  subdirs: 'tepl-@0@'.format(TEPL_API_VERSION),
+  requires: TEPL_PUBLIC_DEPS,
+  requires_private: TEPL_PRIVATE_DEPS
+)
+
+GNOME.generate_gir(
+  tepl_shared_lib,
+  export_packages: 'tepl-@0@'.format(TEPL_API_VERSION),
+  header: 'tepl/tepl.h',
+  identifier_prefix: 'Tepl',
+  include_directories: ROOT_INCLUDE_DIR,
+  includes: ['Gtk-3.0', 'GtkSource-4', 'Amtk-5'],
+  install: true,
+  namespace: 'Tepl',
+  nsversion: TEPL_API_VERSION,
+  sources: [
+    tepl_public_headers,
+    tepl_public_c_files,
+    tepl_enum_types
+  ]
+)
diff --git a/tepl/symbol.map b/tepl/symbol.map
new file mode 100644
index 0000000..a81c09c
--- /dev/null
+++ b/tepl/symbol.map
@@ -0,0 +1,6 @@
+{
+global:
+  tepl_*;
+local:
+  *;
+};
diff --git a/tests/meson.build b/tests/meson.build
new file mode 100644
index 0000000..ab9d15b
--- /dev/null
+++ b/tests/meson.build
@@ -0,0 +1,16 @@
+interactive_tests = [
+  # executable name, sources
+  ['test-fold-region', 'test-fold-region.c'],
+  ['test-tab', 'test-tab.c'],
+
+  ['test-gutter-renderer-folds',
+   ['test-gutter-renderer-folds.c',
+    'tepl-gutter-renderer-folds-sub.c']],
+]
+
+foreach test : interactive_tests
+  executable(
+    test[0], test[1],
+    dependencies: TEPL_STATIC_DEP
+  )
+endforeach
diff --git a/testsuite/meson.build b/testsuite/meson.build
new file mode 100644
index 0000000..32befa8
--- /dev/null
+++ b/testsuite/meson.build
@@ -0,0 +1,24 @@
+unit_tests = [
+  'test-buffer-input-stream',
+  'test-encoding',
+  'test-encoding-converter',
+  'test-file',
+  'test-file-content',
+  'test-file-loader',
+  'test-file-metadata',
+  'test-file-saver',
+  'test-fold-region',
+  'test-info-bar',
+  'test-metadata-store',
+  'test-notebook',
+  'test-utils'
+]
+
+foreach test_name : unit_tests
+  test_exe = executable(
+    test_name,
+    test_name + '.c',
+    dependencies: TEPL_STATIC_DEP
+  )
+  test(test_name, test_exe)
+endforeach


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