[libgovirt] Add initial support for building with meson



commit 09ab6088feb4f7fb2f2c54af061cdddea9b693ae
Author: Eduardo Lima (Etrunko) <etrunko redhat com>
Date:   Sun Aug 14 10:56:43 2016 +0200

    Add initial support for building with meson
    
    Based on initial work by Christophe Fergeau <cfergeau redhat com>
    
    Signed-off-by: Eduardo Lima (Etrunko) <etrunko redhat com>

 Makefile.am          |   2 +
 examples/Makefile.am |   2 +-
 examples/meson.build |   8 ++++
 govirt/Makefile.am   |   1 +
 govirt/meson.build   | 130 +++++++++++++++++++++++++++++++++++++++++++++++++++
 meson.build          | 104 +++++++++++++++++++++++++++++++++++++++++
 po/meson.build       |   2 +
 tests/Makefile.am    |   1 +
 tests/meson.build    |  12 +++++
 9 files changed, 261 insertions(+), 1 deletion(-)
---
diff --git a/Makefile.am b/Makefile.am
index 3d867ca..c7a7a78 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -15,6 +15,8 @@ EXTRA_DIST =                                          \
        NEWS                                            \
        autogen.sh                                      \
        libgovirt.doap                                  \
+       meson.build                                     \
+       po/meson.build                                  \
        $(NULL)
 
 MAINTAINERCLEANFILES =                                 \
diff --git a/examples/Makefile.am b/examples/Makefile.am
index 0421915..d57d652 100644
--- a/examples/Makefile.am
+++ b/examples/Makefile.am
@@ -1,6 +1,6 @@
 noinst_PROGRAMS = async-test sync-test list-vms list-vms-async
 
-EXTRA_DIST =
+EXTRA_DIST = meson.build
 
 sync_test_CFLAGS = \
                $(WARNINGFLAGS_C) \
diff --git a/examples/meson.build b/examples/meson.build
new file mode 100644
index 0000000..b400abf
--- /dev/null
+++ b/examples/meson.build
@@ -0,0 +1,8 @@
+examples = ['sync-test',
+            'async-test',
+            'list-vms',
+            'list-vms-async']
+
+foreach e : examples
+  executable(e, '@0@.c'.format(e), dependencies: govirt_lib_dep)
+endforeach
diff --git a/govirt/Makefile.am b/govirt/Makefile.am
index 5d8a7cb..0ce276d 100644
--- a/govirt/Makefile.am
+++ b/govirt/Makefile.am
@@ -126,6 +126,7 @@ BUILT_SOURCES =                                                     \
        $(NULL)
 
 EXTRA_DIST =                                                   \
+       meson.build                                             \
        govirt-1.0.pc.in                                        \
        govirt.sym                                              \
        ovirt-enum-types.h.template                             \
diff --git a/govirt/meson.build b/govirt/meson.build
new file mode 100644
index 0000000..bec7781
--- /dev/null
+++ b/govirt/meson.build
@@ -0,0 +1,130 @@
+gnome = import('gnome')
+
+govirt_headers = [
+  'govirt.h',
+  'ovirt-api.h',
+  'ovirt-cdrom.h',
+  'ovirt-cluster.h',
+  'ovirt-collection.h',
+  'ovirt-data-center.h',
+  'ovirt-error.h',
+  'ovirt-host.h',
+  'ovirt-options.h',
+  'ovirt-proxy.h',
+  'ovirt-resource.h',
+  'ovirt-rest-call-error.h',
+  'ovirt-storage-domain.h',
+  'ovirt-types.h',
+  'ovirt-vm-display.h',
+  'ovirt-vm.h',
+  'ovirt-vm-pool.h',
+]
+
+install_headers(govirt_headers, subdir : govirt_include_subdir)
+
+govirt_enum_types = gnome.mkenums_simple('ovirt-enum-types',
+                                         sources : govirt_headers,
+                                         install_header : true,
+                                         install_dir : govirt_includedir / govirt_include_subdir)
+
+govirt_private_headers = [
+  'govirt-private.h',
+  'ovirt-action-rest-call.h',
+  'ovirt-api-private.h',
+  'ovirt-cluster-private.h',
+  'ovirt-collection-private.h',
+  'ovirt-data-center-private.h',
+  'ovirt-host-private.h',
+  'ovirt-proxy-private.h',
+  'ovirt-resource-private.h',
+  'ovirt-rest-call.h',
+  'ovirt-resource-rest-call.h',
+  'ovirt-storage-domain-private.h',
+  'ovirt-utils.h',
+  'ovirt-vm-private.h',
+]
+
+govirt_enum_types_private = gnome.mkenums_simple('ovirt-enum-types-private',
+                                                 sources : govirt_private_headers,
+                                                 install : false)
+
+#
+# libgovirt.so
+#
+govirt_sources = [
+  'ovirt-action-rest-call.c',
+  'ovirt-api.c',
+  'ovirt-cdrom.c',
+  'ovirt-cluster.c',
+  'ovirt-collection.c',
+  'ovirt-data-center.c',
+  'ovirt-error.c',
+  'ovirt-host.c',
+  'ovirt-options.c',
+  'ovirt-proxy.c',
+  'ovirt-proxy-deprecated.c',
+  'ovirt-resource.c',
+  'ovirt-resource-rest-call.c',
+  'ovirt-rest-call.c',
+  'ovirt-storage-domain.c',
+  'ovirt-utils.c',
+  'ovirt-vm.c',
+  'ovirt-vm-display.c',
+  'ovirt-vm-pool.c',
+]
+
+govirt_lib_sources = [
+  govirt_enum_types,
+  govirt_enum_types_private,
+  govirt_headers,
+  govirt_private_headers,
+  govirt_sources,
+]
+
+govirt_syms = files('govirt.sym')
+govirt_syms_path = meson.current_source_dir() / 'govirt.sym'
+govirt_version_script = '-Wl,--version-script=@0@'.format(govirt_syms_path)
+
+govirt_lib = library('govirt', govirt_lib_sources,
+                     version : govirt_so_version,
+                     dependencies : govirt_deps,
+                     include_directories : govirt_include,
+                     link_args : compiler.get_supported_link_arguments(govirt_version_script),
+                     link_depends : govirt_syms,
+                     install : true)
+
+govirt_lib_dep = declare_dependency(link_with : govirt_lib,
+                                   include_directories : govirt_include,
+                                   dependencies : govirt_deps,
+                                   sources : [govirt_enum_types[1], govirt_enum_types_private[1]])
+
+#
+# GoVirt-1.0.gir
+#
+govirt_introspection_sources = [
+    govirt_headers,
+    govirt_sources,
+]
+
+gnome.generate_gir(govirt_lib,
+                   build_by_default : true,
+                   sources : govirt_introspection_sources,
+                   namespace : 'GoVirt',
+                   nsversion : '1.0',
+                   identifier_prefix : 'Ovirt',
+                   symbol_prefix : 'ovirt',
+                   export_packages : 'govirt-1.0',
+                   includes : ['Gio-2.0', 'GObject-2.0', 'Rest-0.7' ],
+                   install : true,
+                   extra_args : ['--c-include=govirt/govirt.h'])
+
+#
+# write govirt-1.0.pc
+#
+pkgconfig = import('pkgconfig')
+pkgconfig.generate(govirt_lib,
+                   filebase : 'govirt-1.0',
+                   description : 'goVirt is a GLib binding for oVirt REST API',
+                   subdirs : 'govirt-1.0',
+                   variables : 'exec_prefix=${prefix}')
+
diff --git a/meson.build b/meson.build
new file mode 100644
index 0000000..c207ca4
--- /dev/null
+++ b/meson.build
@@ -0,0 +1,104 @@
+#
+# project definition
+#
+project('libgovirt', 'c',
+        version : '0.3.4',
+        license : 'LGPLv2.1',
+        meson_version: '>= 0.49.0')
+
+#
+# global vars
+#
+compiler = meson.get_compiler('c')
+govirt_version = meson.project_version()
+govirt_include = [include_directories('.')]
+govirt_includedir = get_option('prefix') / get_option('includedir')
+govirt_include_subdir = 'govirt-1.0' / 'govirt'
+govirt_deps = []
+
+# libtool versioning - this applies to libgovirt
+#
+# See http://sources.redhat.com/autobook/autobook/autobook_91.html#SEC91
+# for details
+#
+# increment;
+# CURRENT      If the API or ABI interface has changed (reset REVISION to 0)
+# REVISION     If the API and ABI remains the same, but bugs are fixed.
+# AGE          Don't use.
+govirt_current = 4
+govirt_revision = 1
+govirt_age = 2
+govirt_so_version = '@0@.@1@.@2@'.format(govirt_current - govirt_age,
+                                         govirt_age,
+                                         govirt_revision)
+
+#
+# check for dependencies
+#
+glib_version_info = '>= 2.38'
+glib_encoded_version = 'GLIB_VERSION_2_38'
+
+deps = {'gobject-2.0' : glib_version_info,
+        'gio-2.0' : glib_version_info,
+        'gthread-2.0' : glib_version_info,
+        'gobject-introspection-1.0' : '>= 1.30.0',
+        'rest-0.7' : '>= 0.7.92',}
+
+foreach dep, version : deps
+  govirt_deps += dependency(dep, version : version)
+endforeach
+
+#
+# global C defines
+#
+govirt_global_cflags = ['-std=c99',
+                        '-DG_LOG_DOMAIN="libgovirt"',
+                        '-DGLIB_VERSION_MIN_REQUIRED=@0@'.format(glib_encoded_version),
+                        '-DGLIB_VERSION_MAX_ALLOWED=@0@'.format(glib_encoded_version),
+                        '-Wall',
+                        '-Wextra',
+                        '-Werror',
+                        '-Wcast-align',
+                        '-Wmissing-declarations',
+                        '-Wpointer-arith',
+                        '-Wcast-align',
+                        '-Wwrite-strings',
+                        '-Winit-self',
+                        '-Wreturn-type',
+                        '-Wformat-nonliteral',
+                        '-Wformat-security',
+                        '-Wmissing-include-dirs',
+                        '-Wmissing-format-attribute',
+                        '-Wclobbered',
+                        '-Wempty-body',
+                        '-Wignored-qualifiers',
+                        '-Wsign-compare',
+                        '-Wtype-limits',
+                        '-Wuninitialized',
+                        '-Waggregate-return',
+                        '-Wdeclaration-after-statement',
+                        '-Wshadow',
+                        '-Wno-strict-aliasing',
+                        '-Winline',
+                        '-Wmissing-parameter-type',
+                        '-Woverride-init',
+                        '-Wno-unused-parameter']
+
+foreach arg : govirt_global_cflags
+  add_project_arguments(arg, language : 'c')
+endforeach
+
+subdir('govirt')
+subdir('po')
+subdir('examples')
+subdir('tests')
+
+
+#
+# write config.h
+#
+config_data = configuration_data()
+config_data.set_quoted('GETTEXT_PACKAGE', 'libgovirt')
+config_data.set_quoted('PACKAGE_STRING', 'libgovirt @0@'.format(govirt_version))
+
+configure_file(output : 'config.h', configuration : config_data)
diff --git a/po/meson.build b/po/meson.build
new file mode 100644
index 0000000..86f82f9
--- /dev/null
+++ b/po/meson.build
@@ -0,0 +1,2 @@
+i18n = import('i18n')
+i18n.gettext('govirt-1.0', preset : 'glib')
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 068de23..1b1d9fa 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -8,6 +8,7 @@ EXTRA_DIST =                            \
        https-cert/server-key.csr       \
        https-cert/server-key.pem       \
        mock-xml-data                   \
+       meson.build                     \
        $(NULL)
 
 AM_LDFLAGS =                                   \
diff --git a/tests/meson.build b/tests/meson.build
new file mode 100644
index 0000000..bddc1a3
--- /dev/null
+++ b/tests/meson.build
@@ -0,0 +1,12 @@
+test_govirt_sources = ['test-govirt.c',
+                       'mock-httpd.c',
+                       'mock-httpd.h']
+
+test_c_args = ['-Dabs_srcdir="@0@"'.format(meson.current_source_dir()),
+               '-Dsrcdir="@0@"'.format(meson.current_source_dir())]
+
+test_govirt = executable('test-govirt', test_govirt_sources,
+                         dependencies: govirt_lib_dep,
+                         c_args : test_c_args)
+
+test('test-govirt', test_govirt)


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