[osinfo-db-tools PATCH v2 08/16] Add support to meson build system

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

 



Meson build system is a way simpler and easier to understand build
system that can provide (with some work-arounds here and there) the same
functionalities currently available with our current build system
(autotools).

For now, as meson support is not fully complete* and requires a quite
new version of meson still not present in all systems supported on
libvirt-jenkis-ci, let's keep autotools around so more extensive testing
if meson's functionalities can be done before actually removing
autotools support.

*: the support is not fully complete as there's still no equivalent of
`make syntax-check` provided.

Signed-off-by: Fabiano Fidêncio <fidencio@xxxxxxxxxx>
---
 build-aux/dist.sh |  11 +++
 meson.build       | 218 ++++++++++++++++++++++++++++++++++++++++++++++
 po/meson.build    |   2 +
 tests/meson.build |  21 +++++
 tools/meson.build |  97 +++++++++++++++++++++
 5 files changed, 349 insertions(+)
 create mode 100755 build-aux/dist.sh
 create mode 100644 meson.build
 create mode 100644 po/meson.build
 create mode 100644 tests/meson.build
 create mode 100644 tools/meson.build

diff --git a/build-aux/dist.sh b/build-aux/dist.sh
new file mode 100755
index 0000000..422d593
--- /dev/null
+++ b/build-aux/dist.sh
@@ -0,0 +1,11 @@
+#!/bin/sh
+
+SOURCE_ROOT=$1
+BUILD_ROOT=$2
+
+$SOURCE_ROOT/build-aux/gitlog-to-changelog > $MESON_DIST_ROOT/ChangeLog
+
+cp $BUILD_ROOT/{mingw-,}osinfo-db-tools.spec $MESON_DIST_ROOT/
+
+out="`git log --pretty=format:'%aN <%aE>' | sort -u`"
+perl -p -e "s/#authorslist#// and print '$out'" < $SOURCE_ROOT/AUTHORS.in > $MESON_DIST_ROOT/AUTHORS
diff --git a/meson.build b/meson.build
new file mode 100644
index 0000000..97ad60c
--- /dev/null
+++ b/meson.build
@@ -0,0 +1,218 @@
+project(
+    'osinfo-db-tools', 'c',
+    version: '1.6.0',
+    license: 'GPLv2+',
+    meson_version: '>= 0.49.0'
+)
+
+osinfo_db_tools_prefix = get_option('prefix')
+
+# those directories have to be known by the project
+osinfo_db_tools_datadir = join_paths(osinfo_db_tools_prefix, get_option('datadir'))
+osinfo_db_tools_localedir = join_paths(osinfo_db_tools_prefix, get_option('localedir'))
+osinfo_db_tools_pkgdatadir = join_paths(osinfo_db_tools_datadir, meson.project_name())
+osinfo_db_tools_sysconfdir = join_paths(osinfo_db_tools_prefix, get_option('sysconfdir'))
+
+# those directories will have files installed in
+osinfo_db_tools_bindir = join_paths(osinfo_db_tools_prefix, get_option('bindir'))
+osinfo_db_tools_docdir = join_paths(osinfo_db_tools_datadir, 'doc', meson.project_name())
+osinfo_db_tools_licensedir = join_paths(osinfo_db_tools_datadir, 'license', meson.project_name())
+osinfo_db_tools_mandir = join_paths(osinfo_db_tools_prefix, get_option('mandir'))
+
+# spec files
+osinfo_db_tools_spec_data = configuration_data()
+osinfo_db_tools_spec_data.set('VERSION', meson.project_version())
+
+specs = ['osinfo-db-tools.spec', 'mingw-osinfo-db-tools.spec']
+foreach spec: specs
+    configure_file(
+        input: spec + '.in',
+        output: spec,
+        configuration: osinfo_db_tools_spec_data
+    )
+endforeach
+
+# ninja dist helper
+meson.add_dist_script('build-aux/dist.sh', meson.source_root(), meson.build_root())
+
+# dependencies
+#  glib stuff
+glib_version = '2.36'
+glib_version_info = '>= @0@'.format(glib_version)
+glib_dep = dependency('glib-2.0', version: glib_version_info)
+gio_dep = dependency('gio-2.0', version: glib_version_info)
+gobject_dep = dependency('gobject-2.0', version: glib_version_info)
+
+#  everything else
+libarchive_dep = dependency('libarchive', version: '>= 3.0.0')
+libxml_dep = dependency('libxml-2.0', version: '>= 2.6.0')
+json_glib_dep = dependency('json-glib-1.0')
+
+#  common dependencies
+osinfo_db_tools_common_dependencies = [gobject_dep, gio_dep, glib_dep]
+
+# arguments
+osinfo_db_tools_cflags = []
+
+#  glib stuff
+osinfo_db_tools_cflags += [
+    '-DGLIB_MIN_REQUIRED_VERSION="0"'.format(glib_version),
+    '-DGLIB_MAX_ALLOWED_VERSION="0"'.format(glib_version)
+]
+
+#  directories used
+osinfo_db_tools_cflags += [
+    '-DPKGDATADIR="@0@"'.format(osinfo_db_tools_pkgdatadir),
+    '-DDATA_DIR="@0@"'.format(osinfo_db_tools_datadir),
+    '-DSYSCONFDIR="@0@"'.format(osinfo_db_tools_sysconfdir),
+    '-DLOCALEDIR="@0@"'.format(osinfo_db_tools_localedir),
+]
+
+#  gettext package name
+osinfo_db_tools_cflags += ['-DGETTEXT_PACKAGE="0"'.format(meson.project_name())]
+
+#  cflags to check whether the compiler supports them or not
+osinfo_db_tools_check_cflags = [
+  '-W',
+  '-Waddress',
+  '-Waggressive-loop-optimizations',
+  '-Wall',
+  '-Warray-bounds',
+  '-Wattributes',
+  '-Wbuiltin-macro-redefined',
+  '-Wcast-align',
+  '-Wchar-subscripts',
+  '-Wclobbered',
+  '-Wcomment',
+  '-Wcomments',
+  '-Wcoverage-mismatch',
+  '-Wcpp',
+  '-Wdate-time',
+  '-Wdeprecated-declarations',
+  '-Wdisabled-optimization',
+  '-Wdiv-by-zero',
+  '-Wdouble-promotion',
+  '-Wempty-body',
+  '-Wendif-labels',
+  '-Wenum-compare',
+  '-Wextra',
+  '-Wformat-contains-nul',
+  '-Wformat-extra-args',
+  '-Wformat-security',
+  '-Wformat-y2k',
+  '-Wformat-zero-length',
+  '-Wfree-nonheap-object',
+  '-Wignored-qualifiers',
+  '-Wimplicit',
+  '-Wimplicit-function-declaration',
+  '-Wimplicit-int',
+  '-Winit-self',
+  '-Winline',
+  '-Wint-to-pointer-cast',
+  '-Winvalid-memory-model',
+  '-Winvalid-pch',
+  '-Wjump-misses-init',
+  '-Wlogical-op',
+  '-Wmain',
+  '-Wmaybe-uninitialized',
+  '-Wmissing-braces',
+  '-Wmissing-declarations',
+  '-Wmissing-field-initializers',
+  '-Wmissing-include-dirs',
+  '-Wmissing-parameter-type',
+  '-Wmissing-prototypes',
+  '-Wmultichar',
+  '-Wnarrowing',
+  '-Wnested-externs',
+  '-Wnonnull',
+  '-Wold-style-declaration',
+  '-Wold-style-definition',
+  '-Wopenmp-simd',
+  '-Woverflow',
+  '-Woverlength-strings',
+  '-Woverride-init',
+  '-Wpacked',
+  '-Wpacked-bitfield-compat',
+  '-Wparentheses',
+  '-Wpointer-arith',
+  '-Wpointer-sign',
+  '-Wpointer-to-int-cast',
+  '-Wpragmas',
+  '-Wreturn-local-addr',
+  '-Wreturn-type',
+  '-Wsequence-point',
+  '-Wshadow',
+  '-Wsizeof-pointer-memaccess',
+  '-Wstack-protector',
+  '-Wstrict-aliasing',
+  '-Wstrict-overflow',
+  '-Wstrict-prototypes',
+  '-Wsuggest-attribute=const',
+  '-Wsuggest-attribute=format',
+  '-Wsuggest-attribute=noreturn',
+  '-Wsuggest-attribute=pure',
+  '-Wswitch',
+  '-Wswitch-default',
+  '-Wsync-nand',
+  '-Wtrampolines',
+  '-Wtrigraphs',
+  '-Wtype-limits',
+  '-Wuninitialized',
+  '-Wunknown-pragmas',
+  '-Wunsafe-loop-optimizations',
+  '-Wunused',
+  '-Wunused-but-set-parameter',
+  '-Wunused-but-set-variable',
+  '-Wunused-function',
+  '-Wunused-label',
+  '-Wunused-local-typedefs',
+  '-Wunused-parameter',
+  '-Wunused-result',
+  '-Wunused-value',
+  '-Wunused-variable',
+  '-Wvarargs',
+  '-Wvariadic-macros',
+  '-Wvector-operation-performance',
+  '-Wvla',
+  '-Wvolatile-register-var',
+  '-Wwrite-strings',
+  '-Wnormalized=nfc',
+  '-Wno-sign-compare',
+  '-Wno-sign-conversion',
+  '-Wno-conversion',
+  '-Wno-unused-parameter',
+  '-Wjump-misses-init',
+  '-Wframe-larger-than=4096',
+  '-Wno-overlength-strings',
+  '-O2',
+  '-Wp,-D_FORTIFY_SOURCE=2',
+  '--param=ssp-buffer-size=4',
+  '-fexceptions',
+  '-fasynchronous-unwind-tables',
+  '-fdiagnostics-show-option',
+  '-funit-at-a-time',
+  '-fipa-pure-const',
+  '-Wno-suggest-attribute=pure',
+  '-Wno-suggest-attribute=const',
+]
+
+if host_machine.system() != 'windows'
+    osinfo_db_tools_check_cflags += ['-fstack-protector-all']
+endif
+
+if run_command('[', '-d', '.git', ']').returncode() == 0
+    osinfo_db_tools_check_cflags += ['-Werror']
+endif
+
+compiler = meson.get_compiler('c')
+foreach cflag: osinfo_db_tools_check_cflags
+  if compiler.has_argument(cflag)
+    osinfo_db_tools_cflags += [cflag]
+  endif
+endforeach
+
+add_project_arguments(osinfo_db_tools_cflags, language: 'c')
+
+subdir('tools')
+subdir('po')
+subdir('tests')
diff --git a/po/meson.build b/po/meson.build
new file mode 100644
index 0000000..79c6233
--- /dev/null
+++ b/po/meson.build
@@ -0,0 +1,2 @@
+i18n = import('i18n')
+i18n.gettext(meson.project_name(), preset: 'glib')
diff --git a/tests/meson.build b/tests/meson.build
new file mode 100644
index 0000000..6cf2ca8
--- /dev/null
+++ b/tests/meson.build
@@ -0,0 +1,21 @@
+python = import('python')
+
+python3 = python.find_installation('python3')
+if python3.found()
+    tests = {
+        'export/import test': 'test_osinfo_db_export_import.py',
+        'path test': 'test_osinfo_db_path.py',
+        'validate test': 'test_osinfo_db_validate.py'
+    }
+
+    env_vars = [
+        'abs_top_builddir=' + meson.build_root(),
+        'abs_top_srcdir=' + meson.source_root(),
+        'datadir=' + osinfo_db_tools_datadir,
+        'sysconfdir=' + osinfo_db_tools_sysconfdir
+    ]
+
+    foreach name, file: tests
+        test(name, find_program(file), env: env_vars)
+    endforeach
+endif
diff --git a/tools/meson.build b/tools/meson.build
new file mode 100644
index 0000000..197e809
--- /dev/null
+++ b/tools/meson.build
@@ -0,0 +1,97 @@
+# includes
+osinfo_db_tools_include = [include_directories('.')]
+
+# sources
+#  common sources
+osinfo_db_tools_common_sources = [
+    'osinfo-db-util.c',
+    'osinfo-db-util.h'
+]
+
+# osinfo-db-validate
+osinfo_db_validate_sources = [
+    osinfo_db_tools_common_sources,
+    'osinfo-db-validate.c'
+]
+osinfo_db_validate_dependencies = [
+    osinfo_db_tools_common_dependencies,
+    libxml_dep
+]
+executable(
+    'osinfo-db-validate',
+    sources: osinfo_db_validate_sources,
+    include_directories: osinfo_db_tools_include,
+    dependencies: osinfo_db_validate_dependencies,
+    install: true
+)
+
+# osinfo-db-import
+osinfo_db_import_sources = [
+    osinfo_db_tools_common_sources,
+    'osinfo-db-import.c'
+]
+osinfo_db_import_dependencies = [
+    osinfo_db_tools_common_dependencies,
+    json_glib_dep,
+    libarchive_dep
+]
+executable(
+    'osinfo-db-import',
+    sources: osinfo_db_import_sources,
+    include_directories: osinfo_db_tools_include,
+    dependencies: osinfo_db_import_dependencies,
+    install: true
+)
+
+# osinfo-db-export
+osinfo_db_export_sources = [
+    osinfo_db_tools_common_sources,
+    'osinfo-db-export.c'
+]
+osinfo_db_export_dependencies = [
+    osinfo_db_tools_common_dependencies,
+    libarchive_dep
+]
+executable(
+    'osinfo-db-export',
+    sources: osinfo_db_export_sources,
+    include_directories: osinfo_db_tools_include,
+    dependencies: osinfo_db_export_dependencies,
+    install: true)
+
+# osinfo-db-path
+osinfo_db_path_sources = [
+    osinfo_db_tools_common_sources,
+    'osinfo-db-path.c'
+]
+osinfo_db_path_dependencies = [osinfo_db_tools_common_dependencies]
+executable(
+    'osinfo-db-path',
+    sources: osinfo_db_path_sources,
+    include_directories: osinfo_db_tools_include,
+    dependencies: osinfo_db_path_dependencies,
+    install: true
+)
+
+# man pages
+pod2man = find_program('pod2man')
+if pod2man.found()
+    files = [
+        'osinfo-db-validate',
+        'osinfo-db-import',
+        'osinfo-db-export',
+        'osinfo-db-path'
+    ]
+
+    foreach file: files
+        custom_target(
+            file + '.1',
+            output: file + '.1',
+            input: file + '.c',
+            install: true,
+            install_dir: join_paths(osinfo_db_tools_datadir, 'man', 'man1'),
+            build_by_default: true,
+            command: [pod2man, '-c', 'Osinfo DB Tools', '@INPUT@', '@OUTPUT@']
+        )
+    endforeach
+endif
-- 
2.21.0

_______________________________________________
Libosinfo mailing list
Libosinfo@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libosinfo




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Fedora Users]     [Fedora Maintainers]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]

  Powered by Linux