[libgudev/tchaik/meson: 1/2] Port to meson build system
- From: Martin Blanchard <mablanch src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libgudev/tchaik/meson: 1/2] Port to meson build system
- Date: Thu, 8 Oct 2020 20:03:20 +0000 (UTC)
commit 59bb7ba0d84484443272ab43dff827f4274571cb
Author: Martin Blanchard <martin blanchard codethink co uk>
Date: Tue Mar 13 13:47:25 2018 +0000
Port to meson build system
The meson build system focuses on speed an ease of use,
which helps speeding up the software development.
docs/meson.build | 54 ++++++++++++++++++++++
gudev/meson.build | 132 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
meson.build | 102 +++++++++++++++++++++++++++++++++++++++++
meson_options.txt | 15 +++++++
tests/meson.build | 61 +++++++++++++++++++++++++
5 files changed, 364 insertions(+)
---
diff --git a/docs/meson.build b/docs/meson.build
new file mode 100644
index 0000000..b61b607
--- /dev/null
+++ b/docs/meson.build
@@ -0,0 +1,54 @@
+glib_prefix = glib_dep.get_pkgconfig_variable('prefix')
+glib_docpath = join_paths(glib_prefix, 'share', 'gtk-doc', 'html', 'glib')
+
+gobject_prefix = gobject_dep.get_pkgconfig_variable('prefix')
+gobject_docpath = join_paths(gobject_prefix, 'share', 'gtk-doc', 'html', 'gobject')
+
+libgudev_reference_ignored_h = [
+ 'gudevenumtypes.h',
+]
+
+libgudev_reference_source_folders = [
+ join_paths(srcdir, 'gudev'),
+]
+
+version_xml = configuration_data()
+version_xml.set('VERSION', version)
+
+configure_file(
+ input: 'version.xml.in',
+ output: 'version.xml',
+ configuration: version_xml,
+ install: false,
+)
+
+libgudev_reference_scan_args = [
+ '--ignore-headers=' + ' '.join(libgudev_reference_ignored_h),
+]
+
+libgudev_reference_mkdb_args = [
+ '--name-space=g_udev',
+]
+
+libgudev_reference_fixxref_args = [
+ '--html-dir=@0@'.format(join_paths(gtkdocdir, 'html', package_string)),
+ '--extra-dir=@0@'.format(glib_docpath),
+ '--extra-dir=@0@'.format(gobject_docpath),
+]
+
+gnome.gtkdoc(
+ package_string,
+ main_xml: 'gudev-docs.xml',
+ gobject_typesfile: files('gudev.types'),
+ src_dir: libgudev_reference_source_folders,
+ dependencies: libgudev_dep,
+ scan_args: libgudev_reference_scan_args,
+ mkdb_args: libgudev_reference_mkdb_args,
+ fixxref_args: libgudev_reference_fixxref_args,
+ install: true,
+ install_dir: join_paths(
+ gtkdocdir,
+ 'html',
+ package_string,
+ )
+)
\ No newline at end of file
diff --git a/gudev/meson.build b/gudev/meson.build
new file mode 100644
index 0000000..b99c35d
--- /dev/null
+++ b/gudev/meson.build
@@ -0,0 +1,132 @@
+libgudev_public_h = [
+ 'gudev.h',
+ 'gudevclient.h',
+ 'gudevdevice.h',
+ 'gudevenumerator.h',
+ 'gudevenums.h',
+ 'gudevtypes.h',
+]
+
+libgudev_private_h = [
+ 'gudevprivate.h',
+]
+
+libgudev_sources = [
+ 'gudevclient.c',
+ 'gudevdevice.c',
+ 'gudevenumerator.c',
+]
+
+libgudev_deps = [
+ glib_dep,
+ gobject_dep,
+ libudev_dep,
+]
+
+libgudev_c_args = [
+ '-DHAVE_CONFIG_H',
+ '-D_POSIX_PTHREAD_SEMANTICS',
+ '-D_REENTRANT',
+ '-D_GUDEV_COMPILATION',
+ '-D_GUDEV_WORK_AROUND_DEV_T_BUG',
+ '-DG_LOG_DOMAIN="GUdev"',
+]
+
+libgudev_link_args = [
+ '-export-dynamic',
+]
+
+libgudev_enums = gnome.mkenums(
+ 'gudevenumtypes',
+ sources: libgudev_public_h,
+ h_template: 'gudevenumtypes.h.template',
+ c_template: 'gudevenumtypes.c.template',
+ install_header: true,
+ install_dir: join_paths(
+ pkgincludedir,
+ 'gudev',
+ )
+)
+
+libgudev_enums_h = libgudev_enums.get(1)
+
+libgudev_sources += [
+ libgudev_enums,
+]
+
+install_headers(
+ libgudev_public_h,
+ install_dir: join_paths(
+ pkgincludedir,
+ 'gudev',
+ )
+)
+
+libgudev_sha = shared_library(
+ package_string,
+ libgudev_sources,
+ version: lib_version,
+ include_directories: rootdir,
+ dependencies: libgudev_deps,
+ c_args: libgudev_c_args,
+ link_args: libgudev_link_args,
+ install: true,
+ install_dir: libdir,
+)
+
+libgudev_dep = declare_dependency(
+ link_with: libgudev_sha,
+ include_directories: rootdir,
+ dependencies: libgudev_deps,
+ sources: [
+ libgudev_enums_h,
+ ]
+)
+
+pkg.generate(
+ name: package_string,
+ description: 'GObject bindings for libudev',
+ requires: ['glib-2.0', 'gobject-2.0'],
+ version: version,
+ subdirs: package_string,
+ libraries: libgudev_sha,
+ install_dir: pkgconfigdir,
+ variables: [
+ 'exec_prefix=${prefix}',
+ ]
+)
+
+if get_option('introspection')
+ libgudev_gir = gnome.generate_gir(
+ libgudev_sha,
+ sources: libgudev_sources + libgudev_public_h,
+ nsversion: api_version,
+ namespace: 'GUdev',
+ symbol_prefix: 'g_udev',
+ identifier_prefix: 'GUdev',
+ header: 'gudev/gudev.h',
+ export_packages: [package_string],
+ includes: ['GObject-2.0'],
+ link_with: libgudev_sha,
+ install: true,
+ install_dir_gir: girdir,
+ install_dir_typelib: typelibdir,
+ extra_args: [
+ '-D_GUDEV_COMPILATION',
+ '-D_GUDEV_WORK_AROUND_DEV_T_BUG',
+ ]
+ )
+
+ if get_option('vapi')
+ libgudev_vapi = gnome.generate_vapi(
+ package_string,
+ sources: libgudev_gir.get(0),
+ install: true,
+ install_dir: vapidir,
+ packages: [
+ 'gobject-2.0',
+ ]
+ )
+ endif
+endif
+
diff --git a/meson.build b/meson.build
new file mode 100644
index 0000000..6893cc6
--- /dev/null
+++ b/meson.build
@@ -0,0 +1,102 @@
+project('gudev', 'c',
+ version: '234',
+ license: 'LGPLv2.1+',
+ meson_version: '>= 0.53.0',
+ default_options: [
+ 'buildtype=debugoptimized',
+ ]
+)
+
+gnome = import('gnome')
+pkg = import('pkgconfig')
+
+# Versioning
+api_version = '1.0'
+lib_version = '0.3.0'
+version = meson.project_version()
+
+package_name = meson.project_name()
+package_string = '@0@-@1@'.format(package_name, api_version)
+
+# Paths
+rootdir = include_directories('.')
+
+srcdir = meson.source_root()
+builddir = meson.build_root()
+
+prefix = get_option('prefix')
+
+includedir = join_paths(prefix, get_option('includedir'))
+libdir = join_paths(prefix, get_option('libdir'))
+datadir = join_paths(prefix, get_option('datadir'))
+
+pkgincludedir = join_paths(includedir, package_string)
+typelibdir = join_paths(libdir, 'girepository-1.0')
+pkgconfigdir = join_paths(libdir, 'pkgconfig')
+girdir = join_paths(datadir, 'gir-1.0')
+gtkdocdir = join_paths(datadir, 'gtk-doc')
+vapidir = join_paths(datadir, 'vala', 'vapi')
+
+# Dependencies
+cc = meson.get_compiler('c')
+
+glib_req = '>= 2.38.0'
+libudev_req = '>= 199'
+introspection_req = '>= 1.31.1'
+vapigen_req = '>= 0.38.0'
+gtk_doc_req = '>= 1.18'
+
+glib_dep = dependency('glib-2.0', version: glib_req)
+gobject_dep = dependency('gobject-2.0', version: glib_req)
+libudev_dep = dependency('libudev', version: libudev_req)
+gio_dep = dependency(
+ 'gio-2.0', version: glib_req,
+ required: get_option('build-tests'))
+umockdev_dep = dependency(
+ 'umockdev-1.0',
+ required: get_option('build-tests')
+)
+
+introspection_dep = dependency(
+ 'gobject-introspection-1.0', version: introspection_req,
+ required: get_option('introspection')
+)
+
+vapigen_dep = dependency(
+ 'vapigen', version: vapigen_req,
+ required: get_option('vapi')
+)
+
+gtk_doc_dep = dependency(
+ 'gtk-doc', version: gtk_doc_req,
+ required: get_option('gtk_doc')
+)
+
+# Configurations
+config_h = configuration_data()
+config_h.set_quoted('VERSION', version)
+
+configure_file(
+ output: 'config.h',
+ configuration: config_h
+)
+
+subdir('gudev')
+
+if get_option('build-tests')
+ subdir('tests')
+endif
+
+if get_option('gtk_doc')
+ subdir('docs')
+endif
+
+summary('Documentation', get_option('gtk_doc'), section: 'Build')
+summary('Introspection', get_option('introspection'), section: 'Build')
+summary('Tests', get_option('build-tests'), section: 'Build')
+
+summary('prefix', prefix, section: 'Directories')
+summary('includedir', includedir, section: 'Directories')
+summary('libdir', libdir, section: 'Directories')
+summary('datadir', datadir, section: 'Directories')
+
diff --git a/meson_options.txt b/meson_options.txt
new file mode 100644
index 0000000..fcfba7f
--- /dev/null
+++ b/meson_options.txt
@@ -0,0 +1,15 @@
+option('build-tests',
+ type: 'boolean', value: true,
+ description : 'Build tests (requires umockdev)')
+
+option('introspection',
+ type: 'boolean', value: true,
+ description: 'Generate introspection data (requires gobject-introspection)')
+option('vapi',
+ type: 'boolean', value: true,
+ description: 'Generate vapi file (requires vapigen)')
+
+option('gtk_doc',
+ type: 'boolean', value: false,
+ description: 'Build reference manual (requires gtk-doc)')
+
diff --git a/tests/meson.build b/tests/meson.build
new file mode 100644
index 0000000..f44d9c8
--- /dev/null
+++ b/tests/meson.build
@@ -0,0 +1,61 @@
+gtester_prg = find_program('gtester')
+
+libgudev_tests_sources = [
+ ['test-enumerator-filter', [gio_dep, umockdev_dep]],
+ ['test-sysfsattr', [gio_dep, umockdev_dep]],
+]
+
+libgudev_tests_deps = [
+ glib_dep,
+ gobject_dep,
+ libgudev_dep,
+]
+
+foreach test: libgudev_tests_sources
+ test_name = test.get(0)
+ test_sources = ['@0@.c'.format(test_name)]
+ test_deps = libgudev_tests_deps
+ test_env = []
+
+ if test.length() > 1
+ test_deps += test.get(1)
+ endif
+
+ test_deps_found = true
+
+ foreach dep: test_deps
+ if not dep.found()
+ test_deps_found = false
+ elif dep == umockdev_dep
+ test_env += [
+ 'LD_PRELOAD=libumockdev-preload.so.0',
+ ]
+ endif
+ endforeach
+
+ if test_deps_found == true
+ test_exe = executable(
+ test_name,
+ test_sources,
+ dependencies: test_deps,
+ )
+
+ if gtester_prg.found()
+ test(
+ test_name,
+ gtester_prg,
+ env: test_env,
+ args: [
+ '--verbose',
+ test_exe,
+ ]
+ )
+ else
+ test(
+ test_name,
+ test_exe,
+ env: test_env,
+ )
+ endif
+ endif
+endforeach
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]