[libgudev/tchaik/meson: 1/5] Port to meson build system




commit 334f31b3cf0837ffb2298f498686905e8ba14f7b
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 | 133 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
 meson.build       | 106 +++++++++++++++++++++++++++++++++++++++++++
 meson_options.txt |  15 ++++++
 tests/meson.build |  35 ++++++++++++++
 5 files changed, 343 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..fd06a11
--- /dev/null
+++ b/gudev/meson.build
@@ -0,0 +1,133 @@
+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',
+  '-Wl,--version-script,@0@/libgudev-1.0.sym'.format(top_srcdir),
+]
+
+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 = 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,
+  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,
+  install_dir: pkgconfigdir,
+  variables: [
+    'exec_prefix=${prefix}',
+  ]
+)
+
+if introspection_dep.found()
+  libgudev_gir = gnome.generate_gir(
+    libgudev,
+    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,
+    install: true,
+    install_dir_gir: girdir,
+    install_dir_typelib: typelibdir,
+    extra_args: [
+      '-D_GUDEV_COMPILATION',
+      '-D_GUDEV_WORK_AROUND_DEV_T_BUG',
+    ]
+  )
+
+  if vapigen_dep.found()
+    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..c7b6d92
--- /dev/null
+++ b/meson.build
@@ -0,0 +1,106 @@
+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('tests'))
+umockdev_dep = dependency(
+  'umockdev-1.0',
+  required: get_option('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
+)
+
+top_srcdir = meson.current_source_dir()
+
+subdir('gudev')
+
+if umockdev_dep.found()
+  subdir('tests')
+endif
+
+if get_option('gtk_doc')
+  subdir('docs')
+endif
+
+summary('Documentation', get_option('gtk_doc'), section: 'Build')
+summary('Introspection', introspection_dep.found(), section: 'Build')
+summary('Vala API', vapigen_dep.found(), section: 'Build')
+summary('Tests', umockdev_dep.found(), 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..06e5b48
--- /dev/null
+++ b/meson_options.txt
@@ -0,0 +1,15 @@
+option('tests',
+       type: 'feature', value: 'auto',
+       description: 'Build tests (requires umockdev)')
+
+option('introspection',
+       type: 'feature', value: 'auto',
+       description: 'Generate introspection data (requires gobject-introspection)')
+option('vapi',
+       type: 'feature', value: 'auto',
+       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..6995801
--- /dev/null
+++ b/tests/meson.build
@@ -0,0 +1,35 @@
+libgudev_tests = {
+  'test-enumerator-filter': {
+    'dependencies': [gio_dep, umockdev_dep],
+    'environment': ['LD_PRELOAD=libumockdev-preload.so.0'],
+  },
+  'test-sysfsattr': {
+    'dependencies': [gio_dep, umockdev_dep],
+    'environment': ['LD_PRELOAD=libumockdev-preload.so.0'],
+  },
+}
+
+libgudev_tests_deps = [
+  libgudev_dep,
+]
+
+foreach test_name, test_extras: libgudev_tests
+  test_sources = ['@0@.c'.format(test_name)]
+  test_deps = libgudev_tests_deps
+  test_env = []
+
+  test_deps += test_extras.get('dependencies', [])
+  test_env += test_extras.get('environment', [])
+
+  test_exe = executable(
+    test_name,
+    test_sources,
+    dependencies: test_deps,
+  )
+
+  test(
+    test_name,
+    test_exe,
+    env: test_env,
+  )
+endforeach


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