[gcab/wip/hughsie/meson: 9/9] Port to the Meson buildsystem
- From: Richard Hughes <rhughes src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gcab/wip/hughsie/meson: 9/9] Port to the Meson buildsystem
- Date: Tue, 12 Dec 2017 14:23:27 +0000 (UTC)
commit 954b2a5eccc5ad0f6894abb80c7ac5113e6bebfb
Author: Richard Hughes <richard hughsie com>
Date: Thu Nov 16 21:00:38 2017 +0000
Port to the Meson buildsystem
docs/meson.build | 1 +
docs/reference/meson.build | 15 +++++
libgcab/meson.build | 89 +++++++++++++++++++++++++++++
meson.build | 135 ++++++++++++++++++++++++++++++++++++++++++++
meson_options.txt | 3 +
po/meson.build | 6 ++
6 files changed, 249 insertions(+), 0 deletions(-)
---
diff --git a/docs/meson.build b/docs/meson.build
new file mode 100644
index 0000000..ead14c4
--- /dev/null
+++ b/docs/meson.build
@@ -0,0 +1 @@
+subdir('reference')
diff --git a/docs/reference/meson.build b/docs/reference/meson.build
new file mode 100644
index 0000000..4099e21
--- /dev/null
+++ b/docs/reference/meson.build
@@ -0,0 +1,15 @@
+gcab_docs = configure_file(
+ input : 'gcab-docs.sgml.in',
+ output : 'gcab-docs.sgml',
+ configuration : conf,
+)
+
+gnome.gtkdoc(
+ 'gcab',
+ src_dir : [
+ join_paths(meson.source_root(), 'libgcab'),
+ join_paths(meson.build_root(), 'libgcab'),
+ ],
+ main_sgml : 'gcab-docs.sgml',
+ install : true
+)
diff --git a/libgcab/meson.build b/libgcab/meson.build
new file mode 100644
index 0000000..2b6f1d2
--- /dev/null
+++ b/libgcab/meson.build
@@ -0,0 +1,89 @@
+cargs = [
+ '-DG_LOG_DOMAIN="gcab"',
+]
+
+enum_headers = ['gcab-folder.h', 'gcab-file.h']
+enums = gnome.mkenums(
+ 'gcab-enums',
+ sources : enum_headers,
+ c_template : 'gcab-enums.c.etemplate',
+ h_template : 'gcab-enums.h.etemplate',
+ install_header : true,
+ install_dir : 'libgcab-1.0/libgcab',
+ symbol_prefix : 'gcab',
+ identifier_prefix : 'GCab',
+)
+
+install_headers([
+ 'gcab-cabinet.h',
+ 'gcab-file.h',
+ 'gcab-folder.h',
+ ],
+ subdir : 'libgcab-1.0/libgcab',
+)
+
+mapfile = '../libgcab.syms'
+vflag = '-Wl,--version-script,@0@/@1@'.format(meson.current_source_dir(), mapfile)
+libgcab = shared_library(
+ 'gcab-1.0',
+ enums,
+ sources : [
+ 'gcab-cabinet.c',
+ 'gcab-folder.c',
+ 'gcab-file.c',
+ 'cabinet.c',
+ 'decomp.c',
+ 'glib-compat.c',
+ ],
+ soversion : lt_current,
+ version : lt_version,
+ dependencies : [
+ gio,
+ libz,
+ ],
+ c_args : cargs,
+ include_directories : [
+ include_directories('.'),
+ include_directories('..'),
+ ],
+ link_args : vflag,
+ link_depends : mapfile,
+ install : true
+)
+
+pkgg = import('pkgconfig')
+pkgg.generate(
+ libraries : libgcab,
+ requires : [ 'gio-2.0' ],
+ subdirs : 'libgcab-1.0',
+ version : meson.project_version(),
+ name : 'libgcab',
+ filebase : 'libgcab-1.0',
+ description : 'Cabinet file library',
+)
+
+if get_option('introspection')
+ gir = gnome.generate_gir(libgcab,
+ sources : [
+ 'gcab-cabinet.c',
+ 'gcab-cabinet.h',
+ 'gcab-folder.c',
+ 'gcab-folder.h',
+ 'gcab-file.c',
+ 'gcab-file.h',
+ ],
+ nsversion : '1.0',
+ namespace : 'GCab',
+ symbol_prefix : 'gcab',
+ identifier_prefix : 'GCab',
+ export_packages : 'libgcab',
+ dependencies : [
+ gio,
+ ],
+ includes : [
+ 'Gio-2.0',
+ 'GObject-2.0',
+ ],
+ install : true
+ )
+endif
diff --git a/meson.build b/meson.build
new file mode 100644
index 0000000..cdd65c1
--- /dev/null
+++ b/meson.build
@@ -0,0 +1,135 @@
+project('gcab', 'c',
+ version : '0.8',
+ license : 'LGPL-2.1+',
+ meson_version : '>=0.37.0',
+ default_options : ['warning_level=2', 'c_std=c99'],
+)
+
+# libtool versioning
+lt_current = '0'
+lt_revision = '0'
+lt_age = '0'
+lt_version = '@0@.@1@.@2@'.format(lt_current, lt_age, lt_revision)
+
+# get suported warning flags
+test_args = [
+ '-fstack-protector-strong',
+ '-Waggregate-return',
+ '-Wunused',
+ '-Warray-bounds',
+ '-Wcast-align',
+ '-Wclobbered',
+ '-Wduplicated-branches',
+ '-Wduplicated-cond',
+ '-Wempty-body',
+ '-Wformat=2',
+ '-Wformat-nonliteral',
+ '-Wformat-security',
+ '-Wformat-signedness',
+ '-Wignored-qualifiers',
+ '-Wimplicit-function-declaration',
+ '-Winit-self',
+ '-Wlogical-op',
+ '-Wmissing-declarations',
+ '-Wmissing-format-attribute',
+ '-Wmissing-include-dirs',
+ '-Wmissing-noreturn',
+ '-Wmissing-parameter-type',
+ '-Wmissing-prototypes',
+ '-Wnested-externs',
+ '-Wno-discarded-qualifiers',
+ '-Wno-missing-field-initializers',
+ '-Wno-strict-aliasing',
+ '-Wno-suggest-attribute=format',
+ '-Wno-unused-parameter',
+ '-Wnull-dereference',
+ '-Wold-style-definition',
+ '-Woverride-init',
+ '-Wpointer-arith',
+ '-Wredundant-decls',
+ '-Wreturn-type',
+ '-Wshadow',
+ '-Wsign-compare',
+ '-Wstrict-aliasing',
+ '-Wstrict-prototypes',
+ '-Wswitch-default',
+ '-Wtype-limits',
+ '-Wundef',
+ '-Wuninitialized',
+ '-Wunused-but-set-variable',
+ '-Wunused-variable',
+ '-Wwrite-strings'
+]
+cc = meson.get_compiler('c')
+foreach arg: test_args
+ if cc.has_argument(arg)
+ add_project_arguments(arg, language : 'c')
+ endif
+endforeach
+
+# enable full RELRO where possible
+# FIXME: until https://github.com/mesonbuild/meson/issues/1140 is fixed
+global_link_args = []
+test_link_args = [
+ '-Wl,-z,relro',
+ '-Wl,-z,now',
+]
+foreach arg: test_link_args
+ if cc.has_argument(arg)
+ global_link_args += arg
+ endif
+endforeach
+add_global_link_arguments(
+ global_link_args,
+ language: 'c'
+)
+
+gio = dependency('gio-2.0', version : '>= 2.32.0')
+libz = dependency('zlib')
+
+gnome = import('gnome')
+i18n = import('i18n')
+
+conf = configuration_data()
+conf.set_quoted('GETTEXT_PACKAGE', meson.project_name())
+conf.set_quoted('PACKAGE_NAME', meson.project_name())
+conf.set_quoted('PACKAGE_STRING', meson.project_name())
+conf.set_quoted('VERSION', meson.project_version())
+conf.set_quoted('LOCALEDIR', get_option('localedir'))
+conf.set_quoted('PACKAGE_BUGREPORT', 'FIXME')
+configure_file(
+ output : 'config.h',
+ configuration : conf
+)
+
+install_headers(
+ 'libgcab.h',
+ subdir : 'libgcab-1.0',
+)
+
+subdir('libgcab')
+subdir('po')
+
+if get_option('docs')
+subdir('docs')
+endif
+
+executable(
+ 'gcab',
+ sources : [
+ 'gcab.c',
+ ],
+ include_directories : [
+ include_directories('.'),
+ include_directories('libgcab'),
+ ],
+ dependencies : [
+ gio,
+ ],
+ link_with : [
+ libgcab,
+ ],
+ c_args : cargs,
+ install : true,
+ install_dir : get_option('bindir')
+)
diff --git a/meson_options.txt b/meson_options.txt
new file mode 100644
index 0000000..bbcbbea
--- /dev/null
+++ b/meson_options.txt
@@ -0,0 +1,3 @@
+option('docs', type : 'boolean', value : true, description : 'enable developer documentation')
+option('introspection', type : 'boolean', value : true, description : 'generate GObject Introspection data')
+option('tests', type : 'boolean', value : true, description : 'enable tests')
diff --git a/po/meson.build b/po/meson.build
new file mode 100644
index 0000000..6b9a7bc
--- /dev/null
+++ b/po/meson.build
@@ -0,0 +1,6 @@
+i18n.gettext(meson.project_name(),
+ preset : 'glib',
+ args: [
+ '--default-domain=' + meson.project_name(),
+ ]
+)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]