[wing/wip/meson] Add meson support



commit a920e6afe29df0b0175ec43512746695fece0952
Author: Ignacio Casal Quinteiro <qignacio amazon com>
Date:   Wed Mar 1 19:04:01 2017 +0100

    Add meson support

 meson.build       |  181 +++++++++++++++++++++++++++++++++++++++++++++++++++++
 meson_options.txt |    1 +
 tests/meson.build |   10 +++
 wing-1.0.pc.in    |   11 +++
 wing/meson.build  |   49 ++++++++++++++
 5 files changed, 252 insertions(+), 0 deletions(-)
---
diff --git a/meson.build b/meson.build
new file mode 100644
index 0000000..a99b32e
--- /dev/null
+++ b/meson.build
@@ -0,0 +1,181 @@
+project('wing', 'c',
+        version: '0.0.1',
+        default_options: [
+          'buildtype=debugoptimized'
+        ],
+        license: 'LGPL2+',
+        meson_version: '>= 0.36.0')
+
+wing_version = meson.project_version()
+version_array = wing_version.split('.')
+wing_major_version = version_array[0].to_int()
+wing_minor_version = version_array[1].to_int()
+wing_micro_version = version_array[2].to_int()
+
+wing_api_version = '1.0'
+
+# The interface age is reset every time we add new API; this
+# should only happen during development cycles, otherwise the
+# interface age is the same as the micro version
+if wing_minor_version.is_odd()
+  wing_interface_age = 0
+else
+  wing_interface_age = wing_micro_version
+endif
+
+soversion = 0
+# maintaining compatibility with the previous libtool versioning
+# current = minor * 100 + micro - interface
+# revision = interface
+current = wing_minor_version * 100 + wing_micro_version - wing_interface_age
+revision = wing_interface_age
+libversion = '@0@.@1@.@2@'.format(soversion, current, revision)
+
+wing_prefix = get_option('prefix')
+wing_libdir = join_paths(wing_prefix, get_option('libdir'))
+wing_includedir = join_paths(wing_prefix, get_option('includedir'))
+wing_includedir_real = join_paths(wing_includedir,
+                                          'wing-@0@'.format(wing_api_version),
+                                          'wing')
+wing_datadir = join_paths(wing_prefix, get_option('datadir'))
+
+cc = meson.get_compiler('c')
+host_system = host_machine.system()
+
+conf = configuration_data()
+
+# Compat variables for pkgconfig
+conf.set('prefix', wing_prefix)
+conf.set('exec_prefix', wing_prefix)
+conf.set('libdir', wing_libdir)
+conf.set('includedir', wing_includedir)
+
+# Version macros
+conf.set('VERSION', wing_version)
+
+# Compiler flags
+if cc.get_id() == 'msvc'
+  # Make MSVC more pedantic, this is a recommended pragma list
+  # from _Win32_Programming_ by Rector and Newcomer.  Taken from
+  # glib's msvc_recommended_pragmas.h--please see that file for
+  # the meaning of the warning codes used here
+  test_cflags = [
+    '-W3',
+    '-we4002',
+    '-we4003',
+    '-w14010',
+    '-we4013',
+    '-w14016',
+    '-we4020',
+    '-we4021',
+    '-we4027',
+    '-we4029',
+    '-we4033',
+    '-we4035',
+    '-we4045',
+    '-we4047',
+    '-we4049',
+    '-we4053',
+    '-we4071',
+    '-we4150',
+    '-we4819'
+  ]
+else
+  test_cflags = [
+    '-ffast-math',
+    '-fstrict-aliasing',
+    '-Wpointer-arith',
+    '-Wmissing-declarations',
+    '-Wformat=2',
+    '-Wstrict-prototypes',
+    '-Wmissing-prototypes',
+    '-Wnested-externs',
+    '-Wold-style-definition',
+    '-Wdeclaration-after-statement',
+    '-Wunused',
+    '-Wuninitialized',
+    '-Wshadow',
+    '-Wmissing-noreturn',
+    '-Wmissing-format-attribute',
+    '-Wredundant-decls',
+    '-Wlogical-op',
+    '-Wcast-align',
+    '-Wno-unused-local-typedefs',
+    '-Werror=implicit',
+    '-Werror=init-self',
+    '-Werror=main',
+    '-Werror=missing-braces',
+    '-Werror=return-type',
+    '-Werror=array-bounds',
+    '-Werror=write-strings'
+  ]
+endif
+common_flags = []
+foreach cflag: test_cflags
+  if cc.has_argument(cflag)
+    common_flags += [ cflag ]
+  endif
+endforeach
+
+# Debugging
+enable_debug = get_option('enable-debug')
+if enable_debug == 'auto'
+  if wing_minor_version.is_odd()
+    enable_debug = 'yes'
+  else
+    enable_debug = 'minimum'
+  endif
+endif
+
+debug_flags = []
+if enable_debug == 'yes'
+  debug_flags += [
+    '-DWING_ENABLE_DEBUG'
+  ]
+endif
+
+if enable_debug == 'minimum'
+  debug_flags += [
+    '-DWING_ENABLE_DEBUG',
+    '-DG_DISABLE_CAST_CHECKS'
+  ]
+endif
+
+if enable_debug == 'no'
+  debug_flags += [
+    '-DG_DISABLE_CAST_CHECKS',
+    '-DG_DISABLE_CHECKS',
+    '-DG_DISABLE_ASSERT'
+  ]
+endif
+
+extra_args= []
+# Detect and set symbol visibility
+if cc.get_id() == 'msvc'
+  extra_args += ['-D_WING_EXTERN=__declspec (dllexport) extern']
+else
+  extra_args += ['-D_WING_EXTERN=__attribute__((visibility("default"))) __declspec(dllexport) extern', 
'-fvisibility=hidden']
+endif
+
+core_inc = include_directories('.')
+
+# Required dependencies
+glib_req = '2.44.0'
+conf.set('GLIB_REQUIRED', glib_req)
+glib = dependency('glib-2.0', version: '>=' + glib_req)
+gobject = dependency('gobject-2.0', version: '>=' + glib_req)
+gio = dependency('gio-2.0', version: '>=' + glib_req)
+gio_windows = dependency('gio-windows-2.0', version: '>=' + glib_req)
+build_gobject = gobject.found()
+
+gnome = import('gnome')
+
+# Generate the pkg-config files
+configure_file(input: 'wing-@0  pc in'.format(wing_api_version),
+               output: 'wing-@0@.pc'.format(wing_api_version),
+               configuration: conf,
+               install: true,
+               install_dir: join_paths(wing_libdir, 'pkgconfig'))
+
+subdir('wing')
+subdir('tests')
diff --git a/meson_options.txt b/meson_options.txt
new file mode 100644
index 0000000..0108b66
--- /dev/null
+++ b/meson_options.txt
@@ -0,0 +1 @@
+option('enable-debug', type: 'combo', choices: [ 'auto', 'yes', 'minimum', 'no' ], value: 'yes', 
description: 'Enable debugging level')
diff --git a/tests/meson.build b/tests/meson.build
new file mode 100644
index 0000000..b26d794
--- /dev/null
+++ b/tests/meson.build
@@ -0,0 +1,10 @@
+unit_tests = [
+  'named-pipe'
+]
+
+foreach unit: unit_tests
+  exe = executable(unit, unit + '.c',
+                   dependencies: wing_dep,
+                   include_directories: wing_inc)
+  test(unit, exe, args: [ '--tap', '-k' ])
+endforeach
diff --git a/wing-1.0.pc.in b/wing-1.0.pc.in
new file mode 100644
index 0000000..4086030
--- /dev/null
+++ b/wing-1.0.pc.in
@@ -0,0 +1,11 @@
+prefix=@prefix@
+exec_prefix=@exec_prefix@
+libdir=@libdir@
+includedir=@includedir@
+
+Name: wing
+Description: Wing is a library which provides GLib-like API to some Windows API.
+Requires: glib-2.0 >= @GLIB_REQUIRED@, gobject-2.0 >= @GLIB_REQUIRED@, gio-2.0 >= @GLIB_REQUIRED@
+Version: @VERSION@
+Cflags: -I${includedir}/wing-1.0 @LIBGIT2_GLIB_PCCFLAGS@
+Libs: -L${libdir} -lwing-1.0
diff --git a/wing/meson.build b/wing/meson.build
new file mode 100644
index 0000000..232aa6b
--- /dev/null
+++ b/wing/meson.build
@@ -0,0 +1,49 @@
+headers = [
+  'wing.h',
+  'wingversionmacros.h',
+  'wingnamedpipeclient.h',
+  'wingnamedpipeconnection.h',
+  'wingnamedpipelistener.h',
+  'wingservice.h',
+  'wingservicemanager.h',
+  'wingsource.h',
+  'wingutils.h',
+]
+
+sources = [
+  'wingnamedpipeclient.c',
+  'wingnamedpipeconnection.c',
+  'wingnamedpipelistener.c',
+  'wingservice.c',
+  'wingservice-private.h',
+  'wingservicemanager.c',
+  'wingsource.c',
+  'wingutils.c',
+]
+
+install_headers(headers, subdir: wing_includedir_real)
+
+platform_deps = [ glib, gobject, gio, gio_windows ]
+
+if cc.get_id() == 'msvc'
+  wing_link_args = []
+else
+  wing_link_args = [ '-Wl,-Bsymbolic-functions' ]
+endif
+
+wing = shared_library('wing-@0@'.format(wing_api_version),
+  include_directories: core_inc,
+  sources: sources,
+  version: libversion,
+  soversion: soversion,
+  install: true,
+  dependencies: platform_deps,
+  c_args: extra_args + common_flags + debug_flags + [
+            '-DG_LOG_DOMAIN="Wing"' ],
+  link_args: wing_link_args)
+
+# Internal dependency, for tests and benchmarks
+wing_inc = include_directories([ meson.current_source_dir(), meson.current_build_dir(), meson.build_root(), 
meson.source_root() ])
+wing_dep = declare_dependency(link_with: wing,
+                              include_directories: [ wing_inc ],
+                              dependencies: platform_deps)


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