[template-glib] build: migrate template-glib to meson
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [template-glib] build: migrate template-glib to meson
- Date: Sat, 3 Jun 2017 00:40:53 +0000 (UTC)
commit 27aecba1598a539a1fe6bcda09ab1d8f7cf7f89c
Author: Christian Hergert <chergert redhat com>
Date: Fri Jun 2 17:38:42 2017 -0700
build: migrate template-glib to meson
AUTHORS | 2 -
Makefile.am | 57 -------
README.md | 2 +
autogen.sh | 31 ----
build-aux/Makefile.am.enums | 52 -------
build-aux/vala.m4 | 135 -----------------
build-aux/vapigen.m4 | 101 -------------
configure.ac | 280 -----------------------------------
data/Makefile.am | 4 -
data/template-glib-1.0.pc.in | 11 --
doc/Makefile.am | 59 --------
examples/Makefile.am | 24 ---
git.mk | 333 ------------------------------------------
meson.build | 93 ++++++++++++
meson_options.txt | 10 ++
src/Makefile.am | 164 ---------------------
src/meson.build | 200 +++++++++++++++++++++++++
src/template-glib.map | 6 +
src/tmpl-branch-node.h | 2 +-
src/tmpl-debug.h.in | 50 +++----
src/tmpl-glib.h | 2 +
src/tmpl-version.h.in | 96 ++++++++++++
tests/Makefile.am | 2 -
23 files changed, 434 insertions(+), 1282 deletions(-)
---
diff --git a/AUTHORS b/AUTHORS
index 1e844dd..b1e715e 100644
--- a/AUTHORS
+++ b/AUTHORS
@@ -1,3 +1 @@
-# Generated by Makefile. Do not edit.
-
Christian Hergert
diff --git a/README.md b/README.md
index 97c2936..af4dd1e 100644
--- a/README.md
+++ b/README.md
@@ -67,6 +67,8 @@ false => false
1 / 3 => .333333
a = (1*3) => (a assigned 3)
a * a => 9
+!true => false
+!!true => true
func min(a,b) = if a < b then a; else b;;
min(1,2) => 1
diff --git a/meson.build b/meson.build
new file mode 100644
index 0000000..7feffd3
--- /dev/null
+++ b/meson.build
@@ -0,0 +1,93 @@
+project('template-glib', 'c',
+ version: '3.25.2',
+ license: 'LGPLv2.1+',
+ meson_version: '>= 0.38.1',
+ default_options: [ 'warning_level=1', 'buildtype=debugoptimized' ],
+)
+
+version_arr = meson.project_version().split('.')
+template_glib_version_major = version_arr[0].to_int()
+template_glib_version_minor = version_arr[1].to_int()
+template_glib_version_micro = version_arr[2].to_int()
+
+apiversion = '1.0'
+soversion = 0
+
+if template_glib_version_minor.is_odd()
+ template_glib_interface_age = 0
+else
+ template_glib_interface_age = template_glib_version_micro
+endif
+
+# maintaining compatibility with the previous libtool versioning
+# current = minor * 100 + micro - interface
+# revision = interface
+current = template_glib_version_minor * 100 + template_glib_version_micro - template_glib_interface_age
+revision = template_glib_interface_age
+libversion = '@0@.@1@.@2@'.format(soversion, current, revision)
+
+config_h = configuration_data()
+config_h.set_quoted('GETTEXT_PACKAGE', 'libtemplate_glib')
+config_h.set_quoted('LOCALEDIR', join_paths(get_option('prefix'), get_option('localedir')))
+
+configure_file(
+ output: 'config.h',
+ configuration: config_h,
+)
+
+add_global_arguments([
+ '-DHAVE_CONFIG_H',
+ '-I' + meson.build_root(),
+ '-I' + join_paths(meson.source_root(), 'src'),
+ '-DTMPL_GLIB_COMPILATION',
+], language: 'c')
+
+cc = meson.get_compiler('c')
+
+global_c_args = []
+test_c_args = [
+ '-Wcast-align',
+ '-Wdeclaration-after-statement',
+ ['-Werror=format-security', '-Werror=format=2'],
+ '-Wformat-nonliteral',
+ '-Wformat-security',
+ '-Wmissing-include-dirs',
+ '-Wnested-externs',
+ '-Wno-missing-field-initializers',
+ '-Wno-sign-compare',
+ '-Wno-strict-aliasing',
+ '-Wno-uninitialized',
+ '-Wno-unused-parameter',
+ '-Wpointer-arith',
+ '-Wredundant-decls',
+ '-Wshadow',
+ '-Wswitch-default',
+ '-Wswitch-enum',
+ '-Wundef',
+]
+if get_option('buildtype') != 'plain'
+ test_c_args += '-fstack-protector-strong'
+endif
+if get_option('enable_profiling')
+ test_c_args += '-pg'
+endif
+
+foreach arg: test_c_args
+ if cc.has_multi_arguments(arg)
+ global_c_args += arg
+ endif
+endforeach
+add_project_arguments(
+ global_c_args,
+ language: 'c'
+)
+
+# Setup various paths that subdirectory meson.build files need
+girdir = join_paths(get_option('datadir'), 'gir-1.0')
+typelibdir = join_paths(get_option('libdir'), 'girepository-1.0')
+vapidir = join_paths(get_option('datadir'), 'vala', 'vapi')
+
+gnome = import('gnome')
+
+subdir('src')
+subdir('tests')
diff --git a/meson_options.txt b/meson_options.txt
new file mode 100644
index 0000000..3837aff
--- /dev/null
+++ b/meson_options.txt
@@ -0,0 +1,10 @@
+
+# Performance and debugging related options
+option('enable_tracing', type: 'boolean', value: false)
+option('enable_profiling', type: 'boolean', value: false)
+
+# Support for multiple languages
+option('with_introspection', type: 'boolean', value: true)
+option('with_vapi', type: 'boolean', value: true)
+
+
diff --git a/src/meson.build b/src/meson.build
new file mode 100644
index 0000000..bc3b679
--- /dev/null
+++ b/src/meson.build
@@ -0,0 +1,200 @@
+libtemplate_glib_header_subdir = 'template-glib-' + apiversion
+libtemplate_glib_header_dir = join_paths(get_option('includedir'), libtemplate_glib_header_subdir)
+
+version_data = configuration_data()
+version_data.set('TMPL_MAJOR_VERSION', template_glib_version_major)
+version_data.set('TMPL_MINOR_VERSION', template_glib_version_minor)
+version_data.set('TMPL_MICRO_VERSION', template_glib_version_micro)
+version_data.set('TMPL_VERSION', meson.project_version())
+version_data.set10('ENABLE_TRACING', get_option('enable_tracing'))
+
+tmpl_version_h = configure_file(
+ input: 'tmpl-version.h.in',
+ output: 'tmpl-version.h',
+ install_dir: libtemplate_glib_header_dir,
+ install: true,
+ configuration: version_data)
+
+tmpl_debug_h = configure_file(
+ input: 'tmpl-debug.h.in',
+ output: 'tmpl-debug.h',
+ install_dir: libtemplate_glib_header_dir,
+ install: true,
+ configuration: version_data)
+
+libtemplate_glib_enum_headers = [
+ 'tmpl-error.h',
+ 'tmpl-expr-types.h',
+]
+
+libtemplate_glib_enums = gnome.mkenums('tmpl-enums',
+ h_template: 'tmpl-enums.h.in',
+ c_template: 'tmpl-enums.c.in',
+ sources: libtemplate_glib_enum_headers,
+ install_header: true,
+ install_dir: libtemplate_glib_header_dir,
+)
+
+libtemplate_glib_generated_headers = [
+ tmpl_debug_h,
+ tmpl_version_h,
+ libtemplate_glib_enums[1],
+]
+
+libtemplate_glib_public_headers = [
+ 'tmpl-error.h',
+ 'tmpl-expr-types.h',
+ 'tmpl-expr.h',
+ 'tmpl-glib.h',
+ 'tmpl-scope.h',
+ 'tmpl-symbol.h',
+ 'tmpl-template-locator.h',
+ 'tmpl-template.h',
+]
+
+libtemplate_glib_public_sources = [
+ 'tmpl-error.c',
+ 'tmpl-expr.c',
+ 'tmpl-scope.c',
+ 'tmpl-symbol.c',
+ 'tmpl-template.c',
+ 'tmpl-template-locator.c',
+
+ libtemplate_glib_enums[0],
+]
+
+libtemplate_glib_deps = [
+ dependency('gio-2.0'),
+ dependency('gobject-introspection-1.0'),
+ cc.find_library('m', required: false),
+]
+
+
+flex = find_program('flex')
+bison = find_program('bison')
+sed = find_program('sed')
+
+tmpl_expr_parser = custom_target('tmpl-expr-parser',
+ input: 'tmpl-expr-parser.y',
+ output: ['tmpl-expr-parser.c', 'tmpl-expr-parser.h'],
+ command: [bison, '@INPUT@', '--defines=@OUTPUT1@', '--output=@OUTPUT0@']
+
+)
+
+# This is an awful workaround, flex files embed options to control the output
+# this fails with meson which wants to output to specific directories
+# and just to avoid any regressions we don't want to modify the autotools files
+tmpl_expr_scanner_flex = custom_target('tmpl-expr-scanner-flex',
+ input: 'tmpl-expr-scanner.l',
+ output: 'tmpl-expr-meson-scanner.l',
+ capture: true,
+ command: [sed, '-e', 's/^%option header-file.*$//',
+ '-e', 's/^%option outfile.*$//', '@INPUT@']
+)
+tmpl_expr_scanner = custom_target('tmpl-expr-scanner',
+ input: tmpl_expr_scanner_flex,
+ output: 'tmpl-expr-scanner.c',
+ command: [flex, '-o', '@OUTPUT@', '@INPUT@']
+)
+
+
+libtemplate_glib_sources = [
+ libtemplate_glib_generated_headers,
+ libtemplate_glib_public_headers,
+ libtemplate_glib_public_sources,
+ tmpl_expr_parser,
+ tmpl_expr_scanner,
+
+ 'tmpl-branch-node.c',
+ 'tmpl-branch-node.h',
+ 'tmpl-condition-node.c',
+ 'tmpl-condition-node.h',
+ 'tmpl-expr-eval.c',
+ 'tmpl-expr-node.c',
+ 'tmpl-expr-node.h',
+ 'tmpl-expr-parser-private.h',
+ 'tmpl-expr-private.h',
+ 'tmpl-gi-private.h',
+ 'tmpl-gi.c',
+ 'tmpl-iter-node.c',
+ 'tmpl-iter-node.h',
+ 'tmpl-iterator.c',
+ 'tmpl-iterator.h',
+ 'tmpl-lexer.c',
+ 'tmpl-lexer.h',
+ 'tmpl-node.c',
+ 'tmpl-node.h',
+ 'tmpl-parser.c',
+ 'tmpl-parser.h',
+ 'tmpl-text-node.c',
+ 'tmpl-text-node.h',
+ 'tmpl-token-input-stream.c',
+ 'tmpl-token-input-stream.h',
+ 'tmpl-token.c',
+ 'tmpl-token.h',
+ 'tmpl-util-private.h',
+ 'tmpl-util.c',
+]
+
+
+libtemplate_glib = library(
+ 'template_glib-' + apiversion,
+ libtemplate_glib_sources,
+
+ link_depends: 'template-glib.map',
+ link_args: [ '-Wl,--version-script,' + join_paths(meson.current_source_dir(), 'template-glib.map') ],
+ dependencies: libtemplate_glib_deps,
+ soversion: soversion,
+ version: libversion,
+ install: true,
+)
+
+libtemplate_glib_dep = declare_dependency(
+ sources: libtemplate_glib_generated_headers,
+ dependencies: libtemplate_glib_deps,
+ link_with: libtemplate_glib,
+ include_directories: include_directories('.'),
+)
+
+if get_option('with_introspection')
+
+ libtemplate_glib_gir = gnome.generate_gir(libtemplate_glib,
+ sources: libtemplate_glib_generated_headers + libtemplate_glib_public_headers +
libtemplate_glib_public_sources,
+ nsversion: apiversion,
+ namespace: 'Template',
+ symbol_prefix: 'tmpl',
+ identifier_prefix: 'Tmpl',
+ link_with: libtemplate_glib,
+ includes: [ 'Gio-2.0' ],
+ install: true,
+ install_dir_gir: girdir,
+ install_dir_typelib: typelibdir,
+ extra_args: [ '--c-include=tmpl-glib.h' ],
+ )
+
+ if get_option('with_vapi')
+
+ libtemplate_glib_vapi = gnome.generate_vapi('libtemplate-glib-' + apiversion,
+ sources: libtemplate_glib_gir[0],
+ packages: [ 'gio-2.0' ],
+ install: true,
+ install_dir: vapidir,
+ )
+
+ endif
+endif
+
+install_headers(libtemplate_glib_public_headers, subdir: libtemplate_glib_header_subdir)
+
+pkgg = import('pkgconfig')
+
+pkgg.generate(
+ libraries: [libtemplate_glib],
+ subdirs: 'libtemplate-glib-@0@'.format(apiversion),
+ version: meson.project_version(),
+ name: 'Template-GLib',
+ filebase: 'template-glib-@0@'.format(apiversion),
+ description: 'A templating library for GLib',
+ requires: 'gio-2.0',
+)
+
diff --git a/src/template-glib.map b/src/template-glib.map
new file mode 100644
index 0000000..272f04f
--- /dev/null
+++ b/src/template-glib.map
@@ -0,0 +1,6 @@
+{
+global:
+ tmpl_*;
+local:
+ *;
+};
diff --git a/src/tmpl-branch-node.h b/src/tmpl-branch-node.h
index 2add310..d60d6b5 100644
--- a/src/tmpl-branch-node.h
+++ b/src/tmpl-branch-node.h
@@ -33,7 +33,7 @@ G_BEGIN_DECLS
G_DECLARE_FINAL_TYPE (TmplBranchNode, tmpl_branch_node, TMPL, BRANCH_NODE, TmplNode)
-TmplNode *tmpl_branch_node_new (TmplExpr *condition);
+TmplNode *tmpl_branch_node_new (TmplExpr *expr);
TmplNode *tmpl_branch_node_branch (TmplBranchNode *self,
TmplScope *scope,
GError **error);
diff --git a/src/tmpl-debug.h.in b/src/tmpl-debug.h.in
index 04cf975..d5fa1d7 100644
--- a/src/tmpl-debug.h.in
+++ b/src/tmpl-debug.h.in
@@ -30,40 +30,38 @@ G_BEGIN_DECLS
# undef TMPL_ENABLE_TRACE
#endif
-#ifndef G_LOG_LEVEL_TRACE
-# define G_LOG_LEVEL_TRACE (1 << G_LOG_LEVEL_USER_SHIFT)
-#endif
+#define TMPL_LOG_LEVEL_TRACE (1 << TMPL_LOG_LEVEL_USER_SHIFT)
#ifdef TMPL_ENABLE_TRACE
-# define TMPL_TRACE_MSG(fmt, ...) \
- g_log(G_LOG_DOMAIN, G_LOG_LEVEL_TRACE, " MSG: %s():%d: "fmt, \
+# define TMPL_TRACE_MSG(fmt, ...) \
+ g_log(G_LOG_DOMAIN, TMPL_LOG_LEVEL_TRACE, " MSG: %s():%d: "fmt, \
G_STRFUNC, __LINE__, ##__VA_ARGS__)
-# define TMPL_PROBE \
- g_log(G_LOG_DOMAIN, G_LOG_LEVEL_TRACE, "PROBE: %s():%d", \
+# define TMPL_PROBE \
+ g_log(G_LOG_DOMAIN, TMPL_LOG_LEVEL_TRACE, "PROBE: %s():%d", \
G_STRFUNC, __LINE__)
-# define TMPL_TODO(_msg) \
- g_log(G_LOG_DOMAIN, G_LOG_LEVEL_TRACE, " TODO: %s():%d: %s", \
+# define TMPL_TODO(_msg) \
+ g_log(G_LOG_DOMAIN, TMPL_LOG_LEVEL_TRACE, " TODO: %s():%d: %s", \
G_STRFUNC, __LINE__, _msg)
-# define TMPL_ENTRY \
- g_log(G_LOG_DOMAIN, G_LOG_LEVEL_TRACE, "ENTRY: %s():%d", \
+# define TMPL_ENTRY \
+ g_log(G_LOG_DOMAIN, TMPL_LOG_LEVEL_TRACE, "ENTRY: %s():%d", \
G_STRFUNC, __LINE__)
-# define TMPL_EXIT \
- G_STMT_START { \
- g_log(G_LOG_DOMAIN, G_LOG_LEVEL_TRACE, " EXIT: %s():%d", \
- G_STRFUNC, __LINE__); \
- return; \
+# define TMPL_EXIT \
+ G_STMT_START { \
+ g_log(G_LOG_DOMAIN, TMPL_LOG_LEVEL_TRACE, " EXIT: %s():%d", \
+ G_STRFUNC, __LINE__); \
+ return; \
} G_STMT_END
-# define TMPL_GOTO(_l) \
- G_STMT_START { \
- g_log(G_LOG_DOMAIN, G_LOG_LEVEL_TRACE, " GOTO: %s():%d ("#_l")", \
- G_STRFUNC, __LINE__); \
- goto _l; \
+# define TMPL_GOTO(_l) \
+ G_STMT_START { \
+ g_log(G_LOG_DOMAIN, TMPL_LOG_LEVEL_TRACE, " GOTO: %s():%d ("#_l")", \
+ G_STRFUNC, __LINE__); \
+ goto _l; \
} G_STMT_END
-# define TMPL_RETURN(_r) \
- G_STMT_START { \
- g_log(G_LOG_DOMAIN, G_LOG_LEVEL_TRACE, " EXIT: %s():%d ", \
- G_STRFUNC, __LINE__); \
- return _r; \
+# define TMPL_RETURN(_r) \
+ G_STMT_START { \
+ g_log(G_LOG_DOMAIN, TMPL_LOG_LEVEL_TRACE, " EXIT: %s():%d ", \
+ G_STRFUNC, __LINE__); \
+ return _r; \
} G_STMT_END
#else
# define TMPL_TODO(_msg)
diff --git a/src/tmpl-glib.h b/src/tmpl-glib.h
index ee8a608..a2aaf31 100644
--- a/src/tmpl-glib.h
+++ b/src/tmpl-glib.h
@@ -24,6 +24,8 @@
G_BEGIN_DECLS
#define TMPL_GLIB_INSIDE
+# include "tmpl-debug.h"
+# include "tmpl-enums.h"
# include "tmpl-error.h"
# include "tmpl-expr.h"
# include "tmpl-expr-types.h"
diff --git a/src/tmpl-version.h.in b/src/tmpl-version.h.in
new file mode 100644
index 0000000..da3df48
--- /dev/null
+++ b/src/tmpl-version.h.in
@@ -0,0 +1,96 @@
+/* tmpl-version.h.in
+ *
+ * Copyright (C) 2015-2017 Christian Hergert <chergert redhat com>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef TMPL_VERSION_H
+#define TMPL_VERSION_H
+
+#if !defined(TMPL_GLIB_INSIDE) && !defined(TMPL_GLIB_COMPILATION)
+#error "Only <tmpl-glib.h> can be included directly."
+#endif
+
+/**
+ * SECTION:tmpl-version
+ * @short_description: Dazzle version checking
+ *
+ * Dazzle provides macros to check the version of the library at compile-time
+ */
+
+/**
+ * TMPL_MAJOR_VERSION:
+ *
+ * Template-GLibl major version component (e.g. 1 if %TMPL_VERSION is 1.2.3)
+ */
+#define TMPL_MAJOR_VERSION (@TMPL_MAJOR_VERSION@)
+
+/**
+ * TMPL_MINOR_VERSION:
+ *
+ * Template-GLibl minor version component (e.g. 2 if %TMPL_VERSION is 1.2.3)
+ */
+#define TMPL_MINOR_VERSION (@TMPL_MINOR_VERSION@)
+
+/**
+ * TMPL_MICRO_VERSION:
+ *
+ * Template-GLibl micro version component (e.g. 3 if %TMPL_VERSION is 1.2.3)
+ */
+#define TMPL_MICRO_VERSION (@TMPL_MICRO_VERSION@)
+
+/**
+ * TMPL_VERSION
+ *
+ * Template-GLibl version.
+ */
+#define TMPL_VERSION (@TMPL_VERSION@)
+
+/**
+ * TMPL_VERSION_S:
+ *
+ * Dazzle version, encoded as a string, useful for printing and
+ * concatenation.
+ */
+#define TMPL_VERSION_S "@TMPL_VERSION@"
+
+#define TMPL_ENCODE_VERSION(major,minor,micro) \
+ ((major) << 24 | (minor) << 16 | (micro) << 8)
+
+/**
+ * TMPL_VERSION_HEX:
+ *
+ * Dazzle version, encoded as an hexadecimal number, useful for
+ * integer comparisons.
+ */
+#define TMPL_VERSION_HEX \
+ (TMPL_ENCODE_VERSION (TMPL_MAJOR_VERSION, TMPL_MINOR_VERSION, TMPL_MICRO_VERSION))
+
+/**
+ * TMPL_CHECK_VERSION:
+ * @major: required major version
+ * @minor: required minor version
+ * @micro: required micro version
+ *
+ * Compile-time version checking. Evaluates to %TRUE if the version
+ * of dazzle is greater than the required one.
+ */
+#define TMPL_CHECK_VERSION(major,minor,micro) \
+ (TMPL_MAJOR_VERSION > (major) || \
+ (TMPL_MAJOR_VERSION == (major) && TMPL_MINOR_VERSION > (minor)) || \
+ (TMPL_MAJOR_VERSION == (major) && TMPL_MINOR_VERSION == (minor) && \
+ TMPL_MICRO_VERSION >= (micro)))
+
+#endif /* TMPL_VERSION_H */
diff --git a/tests/meson.build b/tests/meson.build
new file mode 100644
index 0000000..e69de29
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]