[libsecret/wip/nielsdg/meson: 7/7] Add build support for Meson.



commit 5d8a2cd33050b0d9df34f61805614f3b36e96af2
Author: Niels De Graef <nielsdegraef gmail com>
Date:   Tue Mar 20 22:03:56 2018 +0100

    Add build support for Meson.

 egg/egg-secure-memory.h |   1 +
 egg/meson.build         |  24 +++++++
 libsecret/.dirstamp     |   0
 libsecret/meson.build   | 174 ++++++++++++++++++++++++++++++++++++++++++++++++
 meson.build             |  82 +++++++++++++++++++++++
 meson_options.txt       |   4 ++
 po/meson.build          |   3 +
 tool/meson.build        |  11 +++
 8 files changed, 299 insertions(+)
---
diff --git a/egg/egg-secure-memory.h b/egg/egg-secure-memory.h
index 008c82d..660bc6f 100644
--- a/egg/egg-secure-memory.h
+++ b/egg/egg-secure-memory.h
@@ -23,6 +23,7 @@
 #ifndef EGG_SECURE_MEMORY_H
 #define EGG_SECURE_MEMORY_H
 
+#include <glib.h>
 #include <stdlib.h>
 
 /* -------------------------------------------------------------------
diff --git a/egg/meson.build b/egg/meson.build
new file mode 100644
index 0000000..11eeb75
--- /dev/null
+++ b/egg/meson.build
@@ -0,0 +1,24 @@
+libegg_sources = [
+  'egg-hex.c',
+  'egg-secure-memory.c',
+  'egg-testing.c',
+]
+
+if with_gcrypt
+  libegg_sources += [
+    'egg-dh.c',
+    'egg-hkdf.c',
+    'egg-libgcrypt.c',
+  ]
+endif
+
+libegg_deps = [
+  glib_deps,
+  gcrypt_dep,
+]
+
+libegg = static_library('egg',
+  libegg_sources,
+  dependencies: libegg_deps,
+  include_directories: config_h_dir,
+)
diff --git a/libsecret/.dirstamp b/libsecret/.dirstamp
new file mode 100644
index 0000000..e69de29
diff --git a/libsecret/meson.build b/libsecret/meson.build
new file mode 100644
index 0000000..758128b
--- /dev/null
+++ b/libsecret/meson.build
@@ -0,0 +1,174 @@
+libsecret_sources = [
+  'secret-attributes.c',
+  'secret-collection.c',
+  'secret-item.c',
+  'secret-methods.c',
+  'secret-password.c',
+  'secret-prompt.c',
+  'secret-schema.c',
+  'secret-schemas.c',
+  'secret-service.c',
+  'secret-value.c',
+  'secret-paths.c',
+  'secret-session.c',
+  'secret-util.c',
+]
+
+libsecret_headers = [
+  'secret.h',
+  'secret-attributes.h',
+  'secret-collection.h',
+  'secret-item.h',
+  'secret-password.h',
+  'secret-paths.h',
+  'secret-prompt.h',
+  'secret-schema.h',
+  'secret-schemas.h',
+  'secret-service.h',
+  'secret-types.h',
+  'secret-value.h',
+]
+
+_dbus_generated = gnome.gdbus_codegen('secret-dbus-generated',
+  sources: 'org.freedesktop.Secrets.xml',
+  interface_prefix: 'org.freedesktop.Secret.',
+  namespace: '_SecretGen',
+)
+
+_enums_generated = gnome.mkenums('secret-enum-types',
+  sources: libsecret_headers,
+  c_template: 'secret-enum-types.c.template',
+  h_template: 'secret-enum-types.h.template',
+)
+
+libsecret_dependencies = [
+  glib_deps,
+]
+
+if with_gcrypt
+  libsecret_dependencies += gcrypt_dep
+endif
+
+libsecret_cflags = [
+  '-DSECRET_COMPILATION',
+]
+
+libsecret = library('secret',
+  [ libsecret_sources, _dbus_generated, _enums_generated ],
+  dependencies: libsecret_dependencies,
+  link_with: libegg,
+  c_args: libsecret_cflags,
+  include_directories: config_h_dir,
+  install: true,
+)
+
+libsecret_dep = declare_dependency(
+  link_with: [ libsecret, libegg ],
+  dependencies: libsecret_dependencies,
+)
+
+# GObject Introspection
+libsecret_gir_sources = [
+  'secret-attributes.c',
+  'secret-attributes.h',
+  'secret-collection.c',
+  'secret-collection.h',
+  'secret-item.c',
+  'secret-item.h',
+  'secret-methods.c',
+  'secret-password.c',
+  'secret-password.h',
+  'secret-paths.c',
+  'secret-paths.h',
+  'secret-prompt.c',
+  'secret-prompt.h',
+  'secret-schema.c',
+  'secret-schema.h',
+  'secret-schemas.c',
+  'secret-schemas.h',
+  'secret-service.c',
+  'secret-service.h',
+  'secret-types.h',
+  'secret-value.c',
+  'secret-value.h',
+]
+
+libsecret_gir = gnome.generate_gir(libsecret,
+  sources: libsecret_gir_sources,
+  namespace: 'Secret',
+  nsversion: '1',
+  export_packages: 'libsecret-@0@'.format(api_version_major),
+  includes: [ 'GObject-2.0', 'Gio-2.0' ],
+  extra_args: [ '-D SECRET_COMPILATION'],
+  install: true,
+)
+
+# Vapi
+libsecret_vapi = gnome.generate_vapi('Secret-@0@'.format(api_version_major),
+  sources: libsecret_gir[0],
+  metadata_dirs: join_paths(meson.source_root(), 'libsecret'),
+  packages: [ 'gobject-2.0', 'gio-2.0' ],
+  install: true,
+)
+
+# pkg-config
+pc_conf = configuration_data()
+pc_conf.set('prefix', libsecret_prefix)
+pc_conf.set('exec_prefix', '${prefix}')
+pc_conf.set('libdir', join_paths('${prefix}', get_option('libdir')))
+pc_conf.set('includedir', join_paths('${prefix}', get_option('includedir')))
+pc_conf.set('datarootdir', join_paths('${prefix}', get_option('datadir')))
+pc_conf.set('datadir', '${datarootdir}')
+pc_conf.set('sysconfdir', join_paths('${prefix}', get_option('sysconfdir')))
+pc_conf.set('SECRET_MAJOR', api_version_major)
+pc_conf.set('VERSION', meson.project_version())
+
+configure_file(
+  input: 'libsecret.pc.in',
+  output: 'libsecret-@0@.pc'.format(api_version_major),
+  configuration: pc_conf,
+)
+configure_file(
+  input: 'libsecret-unstable.pc.in',
+  output: 'libsecret-unstable.pc',
+  configuration: pc_conf,
+)
+
+# Tests
+mock_cflags = [
+  libsecret_cflags,
+  '-DSRCDIR="@0@"'.format(meson.source_root()),
+]
+
+mock_service_lib = static_library('mock-service',
+  'mock-service.c',
+  dependencies: glib_deps,
+  c_args: mock_cflags,
+  include_directories: config_h_dir,
+)
+
+test_names = [
+  'test-attributes',
+  'test-value',
+  'test-prompt',
+  'test-service',
+  'test-session',
+  'test-paths',
+  'test-methods',
+  'test-password',
+  'test-item',
+  'test-collection',
+]
+
+foreach _test : test_names
+
+  test_bin = executable(_test,
+    '@0@.c'.format(_test),
+    dependencies: libsecret_dep,
+    link_with: mock_service_lib,
+    include_directories: config_h_dir,
+    c_args: libsecret_cflags,
+  )
+
+  test(_test, test_bin)
+endforeach
diff --git a/meson.build b/meson.build
new file mode 100644
index 0000000..04ac1ee
--- /dev/null
+++ b/meson.build
@@ -0,0 +1,82 @@
+project('libsecret', 'c',
+  version: '0.18.7',
+  license: 'GPL2+',
+  meson_version: '>= 0.46',
+)
+
+gnome = import('gnome')
+i18n = import('i18n')
+
+# API version
+api_version = '1.0.0'
+api_version_major = api_version.split('.')[0]
+api_version_minor = api_version.split('.')[1]
+api_version_micro = api_version.split('.')[2]
+
+# Options
+with_manpage = get_option('manpage')
+with_gcrypt = get_option('gcrypt')
+enable_debug = get_option('debugging')
+with_vapi = get_option('vapi')
+
+# Some variables
+config_h_dir = include_directories('.')
+libsecret_prefix = get_option('prefix')
+datadir = join_paths(libsecret_prefix, get_option('datadir'))
+includedir = join_paths(libsecret_prefix, get_option('includedir'))
+bindir = join_paths(libsecret_prefix, get_option('bindir'))
+libdir = join_paths(libsecret_prefix, get_option('libdir'))
+libexecdir = join_paths(libsecret_prefix, get_option('libexecdir'))
+locale_dir = join_paths(libsecret_prefix, get_option('localedir'))
+pkgdatadir = join_paths(datadir, meson.project_name())
+pkglibdir = join_paths(libdir, meson.project_name())
+sysconfdir = join_paths(libsecret_prefix, get_option('sysconfdir'))
+po_dir = join_paths(meson.source_root(), 'po')
+
+# Dependencies
+min_glib_version = '2.44'
+glib_deps = [
+  dependency('glib-2.0', version: '>=' + min_glib_version),
+  dependency('gio-2.0', version: '>=' + min_glib_version),
+  dependency('gio-unix-2.0', version: '>=' + min_glib_version),
+]
+if with_gcrypt
+  min_libgcrypt_version = '1.2.2'
+  libgcrypt_config = find_program('libgcrypt-config')
+  libgcrypt_version = run_command(libgcrypt_config, '--version').stdout().strip()
+  if (libgcrypt_version.version_compare('>' + libgcrypt_version))
+    error('@0@ requires at least gcrypt version @1@, but version found is @2@'
+            .format(meson.project_name(), min_libgcrypt_version, libgcrypt_version))
+  endif
+  message('gcrypt version: @0@'.format(libgcrypt_version))
+  gcrypt_dep = declare_dependency(
+    link_args: run_command(libgcrypt_config, '--libs').stdout().strip().split(),
+    compile_args: run_command(libgcrypt_config, '--cflags').stdout().strip().split(),
+  )
+endif
+
+# Libraries
+math = meson.get_compiler('c').find_library('m')
+
+# Configuration
+conf = configuration_data()
+conf.set_quoted('GETTEXT_PACKAGE', meson.project_name())
+conf.set_quoted('G_LOG_DOMAIN', meson.project_name())
+conf.set_quoted('LOCALEDIR', locale_dir)
+conf.set_quoted('PACKAGE_NAME', meson.project_name())
+conf.set_quoted('PACKAGE_STRING', meson.project_name())
+conf.set_quoted('PACKAGE_VERSION', meson.project_version())
+conf.set('WITH_GCRYPT', with_gcrypt)
+if with_gcrypt
+  conf.set_quoted('LIBGCRYPT_VERSION', min_libgcrypt_version)
+endif
+conf.set('WITH_DEBUG', enable_debug)
+conf.set('_DEBUG', enable_debug)
+configure_file(output: 'config.h', configuration: conf)
+
+# Subfolders
+# subdir('docs')
+subdir('po')
+subdir('egg')
+subdir('libsecret')
+subdir('tool')
diff --git a/meson_options.txt b/meson_options.txt
new file mode 100644
index 0000000..1b9cd94
--- /dev/null
+++ b/meson_options.txt
@@ -0,0 +1,4 @@
+option('manpage', type: 'boolean', value: true, description: 'Build man pages')
+option('gcrypt', type: 'boolean', value: true, description: 'With gcrypt and transport encryption')
+option('debugging', type: 'boolean', value: false, description: 'Turn debugging on/off')
+option('vapi', type: 'boolean', value: true, description: 'Create VAPI file.')
diff --git a/po/meson.build b/po/meson.build
new file mode 100644
index 0000000..f904cde
--- /dev/null
+++ b/po/meson.build
@@ -0,0 +1,3 @@
+i18n.gettext(meson.project_name(),
+  preset: 'glib'
+)
diff --git a/tool/meson.build b/tool/meson.build
new file mode 100644
index 0000000..686cf24
--- /dev/null
+++ b/tool/meson.build
@@ -0,0 +1,11 @@
+secret_tool_sources = [
+  'secret-tool.c',
+]
+
+secret_tool = executable('secret-tool',
+  secret_tool_sources,
+  dependencies: libsecret_dep,
+  include_directories: config_h_dir,
+  c_args: libsecret_cflags,
+  install: true,
+)


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