[gnome-desktop-testing/wip/no-autotools: 7/8] Add a Meson build system




commit 55627f5deb3ccc0a15d5b02918a5d45447a115dd
Author: Simon McVittie <smcv collabora com>
Date:   Tue Jun 29 17:05:13 2021 +0100

    Add a Meson build system
    
    Prerequisite for #4. Additionally, this adds some more compiler warnings,
    broadly similar to those used in libostree and bubblewrap.
    
    Signed-off-by: Simon McVittie <smcv collabora com>

 .gitignore        |  1 +
 install-hook.py   | 24 ++++++++++++++
 meson.build       | 96 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
 meson_options.txt |  9 ++++++
 4 files changed, 130 insertions(+)
---
diff --git a/.gitignore b/.gitignore
index 8155f14..2d7e1a1 100644
--- a/.gitignore
+++ b/.gitignore
@@ -35,6 +35,7 @@ m4/lt~obsolete.m4
 stamp-h1
 *~
 \#*\#
+/_build*
 
 GSystem-1.0.gir
 GSystem-1.0.typelib
diff --git a/install-hook.py b/install-hook.py
new file mode 100755
index 0000000..b087fce
--- /dev/null
+++ b/install-hook.py
@@ -0,0 +1,24 @@
+#!/usr/bin/env python3
+# Copyright 2021 Collabora Ltd.
+# SPDX-License-Identifier: LGPL-2.0-or-later
+
+import os
+import sys
+
+os.symlink(
+    'gnome-desktop-testing-runner',
+    os.path.join(
+        os.environ['MESON_INSTALL_DESTDIR_PREFIX'],
+        sys.argv[1],
+        'ginsttest-runner',
+    )
+)
+os.symlink(
+    'gnome-desktop-testing-runner',
+    os.path.join(
+        os.environ['MESON_INSTALL_DESTDIR_PREFIX'],
+        sys.argv[2],
+        'man1',
+        'ginsttest-runner.1',
+    )
+)
diff --git a/meson.build b/meson.build
new file mode 100644
index 0000000..0c13bd7
--- /dev/null
+++ b/meson.build
@@ -0,0 +1,96 @@
+# Copyright 2021 Collabora Ltd.
+# SPDX-License-Identifier: LGPL-2.0-or-later
+
+project(
+  'gnome-desktop-testing',
+  'c',
+  version : '2018.1',
+  meson_version : '>=0.49.0',
+  default_options : [
+    'warning_level=2',
+  ],
+)
+
+cc = meson.get_compiler('c')
+
+add_project_arguments(
+  cc.get_supported_arguments([
+    '-Werror=aggregate-return',
+    '-Werror=empty-body',
+    '-Werror=implicit-function-declaration',
+    '-Werror=incompatible-pointer-types',
+    '-Werror=init-self',
+    '-Werror=int-conversion',
+    '-Werror=misleading-indentation',
+    '-Werror=missing-declarations',
+    '-Werror=missing-include-dirs',
+    '-Werror=missing-prototypes',
+    '-Werror=overflow',
+    '-Werror=parenthesis',
+    '-Werror=pointer-arith',
+    '-Werror=return-type',
+    '-Werror=shadow',
+    '-Werror=strict-prototypes',
+    '-Werror=switch-default',
+    '-Wswitch-enum',
+
+    # deliberately not warning about these
+    '-Wno-declaration-after-statement',
+    '-Wno-missing-field-initializers',
+    '-Wno-unused-parameter',
+    '-Wno-error=declaration-after-statement',
+    '-Wno-error=missing-field-initializers',
+    '-Wno-error=unused-parameter',
+  ]),
+  language : 'c',
+)
+
+if (
+  cc.has_argument('-Werror=format=2')
+  and cc.has_argument('-Werror=format-security')
+  and cc.has_argument('-Werror=format-nonliteral')
+)
+  add_project_arguments([
+    '-Werror=format=2',
+    '-Werror=format-security',
+    '-Werror=format-nonliteral',
+  ], language : 'c')
+endif
+
+include_dirs = include_directories('.')
+
+gio_unix_dep = dependency('gio-unix-2.0', version : '>=2.50')
+libsystemd_dep = dependency('libsystemd', required : get_option('systemd'))
+
+cdata = configuration_data()
+cdata.set_quoted('DATADIR', get_option('prefix') / get_option('datadir'))
+cdata.set_quoted('LIBEXECDIR', get_option('prefix') / get_option('libexecdir'))
+cdata.set('GLIB_VERSION_MAX_ALLOWED', 'GLIB_VERSION_2_50')
+cdata.set('GLIB_VERSION_MIN_REQUIRED', 'GLIB_VERSION_2_50')
+
+if libsystemd_dep.found()
+  cdata.set('HAVE_SYSTEMD', 1)
+endif
+
+configure_file(
+  output : 'config.h',
+  configuration : cdata,
+)
+
+executable(
+  'gnome-desktop-testing-runner',
+  ['src/gnome-desktop-testing-runner.c'],
+  include_directories : include_dirs,
+  install : true,
+  dependencies : [gio_unix_dep, libsystemd_dep],
+)
+
+install_man(
+  ['gnome-desktop-testing-runner.1'],
+)
+
+meson.add_install_script(
+  'install-hook.py',
+  get_option('bindir'),
+  get_option('mandir'),
+)
diff --git a/meson_options.txt b/meson_options.txt
new file mode 100644
index 0000000..81f84bb
--- /dev/null
+++ b/meson_options.txt
@@ -0,0 +1,9 @@
+# Copyright 2021 Collabora Ltd.
+# SPDX-License-Identifier: LGPL-2.0-or-later
+
+option(
+  'systemd',
+  type : 'feature',
+  description : 'enable optional libsystemd support',
+  value : 'auto',
+)


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