[virt-tools-list] [PATCH virt-viewer v2] Add support for building with meson/ninja
Eduardo Lima (Etrunko)
etrunko at redhat.com
Fri Sep 28 17:13:04 UTC 2018
Signed-off-by: Eduardo Lima (Etrunko) <etrunko at redhat.com>
---
In v2:
- Add meson.build files to EXTRA_DIST
- Fix typo meson meson_vesrion -> meson_version
- Minimal cleanups
---
Makefile.am | 3 +
data/Makefile.am | 1 +
data/meson.build | 16 ++++
icons/Makefile.am | 2 +
icons/meson.build | 14 ++++
man/Makefile.am | 1 +
man/meson.build | 16 ++++
meson.build | 203 ++++++++++++++++++++++++++++++++++++++++++++++
meson_options.txt | 25 ++++++
po/meson.build | 2 +
src/Makefile.am | 1 +
src/meson.build | 116 ++++++++++++++++++++++++++
tests/Makefile.am | 2 +
tests/meson.build | 16 ++++
14 files changed, 418 insertions(+)
create mode 100644 data/meson.build
create mode 100644 icons/meson.build
create mode 100644 man/meson.build
create mode 100644 meson.build
create mode 100644 meson_options.txt
create mode 100644 po/meson.build
create mode 100644 src/meson.build
create mode 100644 tests/meson.build
diff --git a/Makefile.am b/Makefile.am
index d33367a..dcbe49b 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -19,6 +19,9 @@ EXTRA_DIST = \
build-aux/vc-list-files \
AUTHORS.in \
README.md \
+ meson.build \
+ meson_options.txt \
+ po/meson.build \
$(NULL)
DISTCLEAN_FILES = \
diff --git a/data/Makefile.am b/data/Makefile.am
index 54be2b1..afc3be8 100644
--- a/data/Makefile.am
+++ b/data/Makefile.am
@@ -4,6 +4,7 @@ MANUFACTURER = Virt Manager Project
EXTRA_DIST = \
virt-viewer.wxs.in \
+ meson.build \
$(NULL)
# this make sure those files are regenerated when they change
diff --git a/data/meson.build b/data/meson.build
new file mode 100644
index 0000000..f57e751
--- /dev/null
+++ b/data/meson.build
@@ -0,0 +1,16 @@
+intltool = find_program('intltool-merge')
+podir = join_paths(meson.source_root(), 'po')
+
+targets = {'remote-viewer.desktop' : 'applications',
+ 'remote-viewer.appdata.xml' : 'appdata',
+ 'virt-viewer-mime.xml' : 'mime/packages'}
+
+foreach target, dir : targets
+ style = target.split('.')[-1]
+ custom_target(target,
+ input : '@0 at .in'.format(target),
+ output : target,
+ command : [intltool, '-- at 0@-style'.format(style), podir, '@INPUT@', '@OUTPUT@'],
+ install : true,
+ install_dir : join_paths(virt_viewer_datadir, dir))
+endforeach
diff --git a/icons/Makefile.am b/icons/Makefile.am
index 0b4c247..978a0c0 100644
--- a/icons/Makefile.am
+++ b/icons/Makefile.am
@@ -10,4 +10,6 @@ ico_sizes = 16 32 48 256
%.ico: $(foreach s,$(ico_sizes),$(s)x$(s)/%.png)
$(AM_V_GEN)$(ICOTOOL) -c -o $@ $^
+EXTRA_DIST = meson.build
+
-include $(top_srcdir)/git.mk
diff --git a/icons/meson.build b/icons/meson.build
new file mode 100644
index 0000000..8a7741f
--- /dev/null
+++ b/icons/meson.build
@@ -0,0 +1,14 @@
+dirs = [
+ '16x16',
+ '22x22',
+ '24x24',
+ '32x32',
+ '48x48',
+ '256x256'
+]
+
+foreach d : dirs
+ file = files('@0@/virt-viewer.png'.format(d))
+ dir = join_paths(virt_viewer_datadir, 'icons', 'hicolor', d, 'apps')
+ install_data(file, install_dir : dir)
+endforeach
diff --git a/man/Makefile.am b/man/Makefile.am
index 39b6019..7db1b20 100644
--- a/man/Makefile.am
+++ b/man/Makefile.am
@@ -8,6 +8,7 @@ dist_man_MANS = \
EXTRA_DIST = \
remote-viewer.pod \
virt-viewer.pod \
+ meson.build \
$(NULL)
MAINTAINERCLEANFILES = $(dist_man_MANS)
diff --git a/man/meson.build b/man/meson.build
new file mode 100644
index 0000000..9d79bd0
--- /dev/null
+++ b/man/meson.build
@@ -0,0 +1,16 @@
+pod2man = find_program('pod2man')
+manuals = ['remote-viewer', 'virt-viewer']
+
+if pod2man.found()
+ foreach m : manuals
+ man = '@0 at .1'.format(m)
+ pod = '@0 at .pod'.format(m)
+ custom_target(man,
+ output : man,
+ input : pod,
+ install : true,
+ install_dir : join_paths(virt_viewer_datadir, 'man', 'man1'),
+ build_by_default : true,
+ command : [pod2man, '-c', 'Virtualization Support', '@INPUT@', '@OUTPUT@'])
+ endforeach
+endif
diff --git a/meson.build b/meson.build
new file mode 100644
index 0000000..578a3d3
--- /dev/null
+++ b/meson.build
@@ -0,0 +1,203 @@
+project('virt-viewer', 'c',
+ version : '8.0',
+ license : 'GPLv2',
+ meson_version : '>= 0.47.0')
+
+#
+# globals
+#
+virt_viewer_deps = []
+virt_viewer_include = [include_directories('.')]
+virt_viewer_config_data = configuration_data()
+virt_viewer_package_name = meson.project_name()
+virt_viewer_version = meson.project_version()
+virt_viewer_datadir = join_paths(get_option('prefix'), get_option('datadir'))
+virt_viewer_localedir = join_paths(virt_viewer_datadir, 'locale')
+
+virt_viewer_cflags = ['-DG_LOG_DOMAIN="@0@"'.format(virt_viewer_package_name),
+ '-Wall',
+ '-Wmissing-prototypes',
+ '-std=c99',
+ '-Wnested-externs',
+ '-Wpointer-arith',
+ '-Wextra',
+ '-Wshadow',
+ '-Wcast-align',
+ '-Wwrite-strings',
+ '-Waggregate-return',
+ '-Winline',
+ '-Wredundant-decls',
+ '-Wdeprecated-declarations',
+ '-Wno-sign-compare',
+ '-Wno-cast-function-type',
+ '-Werror']
+
+compiler = meson.get_compiler('c')
+
+# dependency versions
+glib2_version = '2.38'
+glib2_required = '>= @0@'.format(glib2_version)
+gtk_version = '3.12'
+gtk_required = '>= @0@'.format(gtk_version)
+libxml2_required = '>= 2.6.0'
+libvirt_required = '>= 0.10.0'
+libvirt_glib_required = '>= 0.1.8'
+gtk_vnc_required = '>= 0.4.0'
+spice_gtk_required = '>= 0.35'
+spice_protocol_required = '>= 0.12.7'
+govirt_required = '>= 0.3.3'
+rest_required = '>= 0.8'
+
+#
+# check system headers
+#
+headers = ['sys/socket.h', 'sys/un.h', 'windows.h']
+foreach header : headers
+ if compiler.has_header(header)
+ virt_viewer_config_data.set('HAVE_ at 0@'.format(header.underscorify().to_upper()), '1')
+ endif
+endforeach
+
+#
+# check system functions
+#
+functions = ['fork', 'socketpair']
+foreach function : functions
+ if compiler.has_function(function)
+ virt_viewer_config_data.set('HAVE_ at 0@'.format(function.underscorify().to_upper()), '1')
+ endif
+endforeach
+
+#
+# Check for dependencies
+#
+virt_viewer_deps = [compiler.find_library('m')]
+
+# mandatory deps
+deps = {'glib-2.0' : glib2_required,
+ 'gio-2.0' : glib2_required,
+ 'gthread-2.0' : glib2_required,
+ 'gmodule-export-2.0': glib2_required,
+ 'gtk+-3.0' : gtk_required,
+ 'libxml-2.0' : libxml2_required}
+
+foreach dep, version : deps
+ virt_viewer_deps += dependency(dep, version : version)
+endforeach
+
+glib2_encoded_version = 'GLIB_VERSION_ at 0@'.format(glib2_version.underscorify())
+gtk_encoded_version = 'GDK_VERSION_ at 0@'.format(gtk_version.underscorify())
+
+virt_viewer_cflags += ['-DGLIB_VERSION_MIN_REQUIRED=@0@'.format(glib2_encoded_version),
+ '-DGLIB_VERSION_MAX_ALLOWED=@0@'.format(glib2_encoded_version),
+ '-DGDK_VERSION_MIN_REQUIRED=@0@'.format(gtk_encoded_version),
+ '-DGDK_VERSION_MAX_ALLOWED=@0@'.format(gtk_encoded_version)]
+
+# optional deps
+
+# libvirt
+virt_viewer_has_libvirt = false
+
+libvirt_dep = dependency('libvirt', version : libvirt_required, required : get_option('libvirt'))
+libvirt_glib_dep = dependency('libvirt-glib-1.0', version : libvirt_glib_required, required : get_option('libvirt'))
+
+if libvirt_dep.found() and libvirt_glib_dep.found()
+ virt_viewer_deps += [libvirt_dep, libvirt_glib_dep]
+
+ if compiler.has_function('virDomainOpenGraphicsFD', dependencies : libvirt_dep)
+ virt_viewer_config_data.set('HAVE_VIR_DOMAIN_OPEN_GRAPHICS_FD', '1')
+ endif
+
+ virt_viewer_config_data.set('HAVE_LIBVIRT', '1')
+ virt_viewer_has_libvirt = true
+endif
+
+# gtk-vnc
+virt_viewer_has_gtk_vnc = false
+gtk_vnc_dep = dependency('gtk-vnc-2.0', version : gtk_vnc_required, required : get_option('gtk-vnc'))
+
+if gtk_vnc_dep.found()
+ virt_viewer_deps += gtk_vnc_dep
+ virt_viewer_config_data.set('HAVE_GTK_VNC', '1')
+ virt_viewer_has_gtk_vnc = true
+endif
+
+# spice-gtk
+virt_viewer_has_spice_gtk = false
+spice_protocol_dep = dependency('spice-protocol', version : spice_protocol_required, required : get_option('spice-gtk'))
+spice_glib_dep = dependency('spice-client-glib-2.0', version : spice_gtk_required, required : get_option('spice-gtk'))
+spice_gtk_dep = dependency('spice-client-gtk-3.0', version : spice_gtk_required, required : get_option('spice-gtk'))
+
+if spice_protocol_dep.found() and spice_glib_dep.found() and spice_gtk_dep.found()
+ virt_viewer_deps += [spice_protocol_dep, spice_glib_dep, spice_gtk_dep]
+ virt_viewer_config_data.set('HAVE_SPICE_GTK', '1')
+ virt_viewer_has_spice_gtk = true
+endif
+
+# ovirt
+virt_viewer_has_ovirt = false
+rest_dep = dependency('rest-0.7', version : rest_required, required : get_option('ovirt'))
+ovirt_dep = dependency('govirt-1.0', version : govirt_required, required: get_option('ovirt'))
+
+if rest_dep.found() and ovirt_dep.found()
+ virt_viewer_deps += [rest_dep, ovirt_dep]
+
+ if (compiler.has_function('ovirt_api_search_vms', dependencies : ovirt_dep) and
+ compiler.has_function('ovirt_vm_get_host', dependencies : ovirt_dep) and
+ compiler.has_function('ovirt_host_get_cluster', dependencies : ovirt_dep) and
+ compiler.has_function('ovirt_cluster_get_data_center', dependencies : ovirt_dep))
+ virt_viewer_config_data.set('HAVE_OVIRT_DATA_CENTER', '1')
+ endif
+
+ virt_viewer_config_data.set('HAVE_OVIRT', '1')
+ virt_viewer_has_ovirt = true
+endif
+
+osid = get_option('osid')
+if osid.strip() != ''
+ virt_viewer_config_data.set_quoted('REMOTE_VIEWER_OS_ID', osid)
+endif
+
+buildid = get_option('buildid')
+if buildid.strip() == '0'
+ buildid = ''
+else
+ buildid = '- at 0@'.format(buildid)
+endif
+
+virt_viewer_config_data.set_quoted('BUILDID', '@0@'.format(buildid))
+
+#
+# global C defines
+#
+add_project_arguments(compiler.get_supported_arguments(virt_viewer_cflags),
+ language : 'c')
+
+#
+# Subdirectories
+#
+subdir('src')
+subdir('tests')
+subdir('icons')
+subdir('po')
+subdir('data')
+subdir('man')
+
+#
+# Write config.h
+#
+config_data = {'PACKAGE' : virt_viewer_package_name,
+ 'GETTEXT_PACKAGE' : virt_viewer_package_name,
+ 'VERSION' : virt_viewer_version,
+ 'PACKAGE_VERSION' : virt_viewer_version,
+ 'LOCALE_DIR' : virt_viewer_localedir}
+
+foreach key, value : config_data
+ virt_viewer_config_data.set_quoted(key, value)
+endforeach
+
+virt_viewer_config_data.set('_GNU_SOURCE', '')
+
+configure_file(output : 'config.h',
+ install : false,
+ configuration : virt_viewer_config_data)
diff --git a/meson_options.txt b/meson_options.txt
new file mode 100644
index 0000000..cb39516
--- /dev/null
+++ b/meson_options.txt
@@ -0,0 +1,25 @@
+option('libvirt',
+ type : 'feature',
+ description: 'Enable libvirt')
+
+option('gtk-vnc',
+ type : 'feature',
+ description: 'Enable gtk-vnc')
+
+option('spice-gtk',
+ type : 'feature',
+ description: 'Enable spice-gtk')
+
+option('ovirt',
+ type : 'feature',
+ description: 'Enable ovirt')
+
+option('osid',
+ type : 'string',
+ description: 'OS ID for this build')
+
+option('buildid',
+ type : 'string',
+ value : '0',
+ description: 'Set additional build version details')
+
diff --git a/po/meson.build b/po/meson.build
new file mode 100644
index 0000000..a2a36b8
--- /dev/null
+++ b/po/meson.build
@@ -0,0 +1,2 @@
+i18n = import('i18n')
+i18n.gettext('virt-viewer')
diff --git a/src/Makefile.am b/src/Makefile.am
index 0472908..4b61797 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -22,6 +22,7 @@ EXTRA_DIST = \
virt-viewer-enums.c.etemplate \
virt-viewer-enums.h.etemplate \
resources/virt-viewer.gresource.xml \
+ meson.build \
$(NULL)
ENUMS_FILES = \
diff --git a/src/meson.build b/src/meson.build
new file mode 100644
index 0000000..29026f5
--- /dev/null
+++ b/src/meson.build
@@ -0,0 +1,116 @@
+virt_viewer_include += [include_directories('.')]
+gnome = import('gnome')
+
+virt_viewer_gresource = files('resources/virt-viewer.gresource.xml')
+virt_viewer_resources = gnome.compile_resources('virt-viewer-resources',
+ virt_viewer_gresource,
+ source_dir : 'resources',
+ c_name : 'virt_viewer')
+virt_viewer_enums = gnome.mkenums_simple('virt-viewer-enums', sources : ['virt-viewer-display.h'])
+
+# libvirt-viewer-util
+libvirt_viewer_util_sources = [
+ 'virt-viewer-util.h',
+ 'virt-viewer-util.c',
+]
+
+libvirt_viewer_util_lib = static_library('virt-viewer-util', libvirt_viewer_util_sources,
+ include_directories : virt_viewer_include,
+ dependencies : virt_viewer_deps,
+ install : false)
+
+# libvirt-viewer
+libvirt_viewer_sources = [
+ virt_viewer_resources,
+ virt_viewer_enums,
+ 'glib-compat.h',
+ 'glib-compat.c',
+ 'virt-viewer-auth.h',
+ 'virt-viewer-auth.c',
+ 'virt-viewer-app.h',
+ 'virt-viewer-app.c',
+ 'virt-viewer-file.h',
+ 'virt-viewer-file.c',
+ 'virt-viewer-session.h',
+ 'virt-viewer-session.c',
+ 'virt-viewer-display.h',
+ 'virt-viewer-display.c',
+ 'virt-viewer-notebook.h',
+ 'virt-viewer-notebook.c',
+ 'virt-viewer-window.h',
+ 'virt-viewer-window.c',
+ 'virt-viewer-vm-connection.h',
+ 'virt-viewer-vm-connection.c',
+ 'virt-viewer-timed-revealer.c',
+ 'virt-viewer-timed-revealer.h',
+]
+
+if virt_viewer_has_gtk_vnc
+ libvirt_viewer_sources += ['virt-viewer-session-vnc.h',
+ 'virt-viewer-session-vnc.c',
+ 'virt-viewer-display-vnc.h',
+ 'virt-viewer-display-vnc.c']
+endif
+
+if virt_viewer_has_spice_gtk
+ libvirt_viewer_sources += ['virt-viewer-session-spice.h',
+ 'virt-viewer-session-spice.c',
+ 'virt-viewer-display-spice.h',
+ 'virt-viewer-display-spice.c',
+ 'virt-viewer-file-transfer-dialog.h',
+ 'virt-viewer-file-transfer-dialog.c']
+endif
+
+if virt_viewer_has_ovirt
+ libvirt_viewer_sources += ['ovirt-foreign-menu.h',
+ 'ovirt-foreign-menu.c',
+ 'remote-viewer-iso-list-dialog.c',
+ 'remote-viewer-iso-list-dialog.h']
+endif
+
+libvirt_viewer_lib = static_library('virt-viewer', libvirt_viewer_sources,
+ include_directories : virt_viewer_include,
+ dependencies : virt_viewer_deps,
+ install: false)
+
+# remote-viewer
+remote_viewer_sources = [
+ virt_viewer_enums[1],
+ 'remote-viewer.h',
+ 'remote-viewer.c',
+ 'remote-viewer-connect.c',
+ 'remote-viewer-connect.h',
+ 'remote-viewer-main.c',
+]
+
+executable('remote-viewer',
+ remote_viewer_sources,
+ include_directories : virt_viewer_include,
+ dependencies : virt_viewer_deps,
+ link_with : [libvirt_viewer_util_lib, libvirt_viewer_lib],
+ install : false)
+
+# virt-viewer
+virt_viewer_sources = [
+ virt_viewer_enums[1],
+ 'virt-viewer.h',
+ 'virt-viewer.c',
+ 'virt-viewer-main.c',
+]
+
+if virt_viewer_has_libvirt
+ executable('virt-viewer',
+ virt_viewer_sources,
+ include_directories : virt_viewer_include,
+ dependencies : virt_viewer_deps,
+ link_with : [libvirt_viewer_util_lib, libvirt_viewer_lib],
+ install : true)
+endif
+
+# virt-viewer.rc
+virt_viewer_rc = configuration_data()
+virt_viewer_rc.set('VERSION', virt_viewer_version)
+virt_viewer_rc.set('PACKAGE_STRING', '@0@ @1@'.format(virt_viewer_package_name, virt_viewer_version))
+configure_file(input : 'virt-viewer.rc.in',
+ output : 'virt-viewer.rc',
+ configuration : virt_viewer_rc)
diff --git a/tests/Makefile.am b/tests/Makefile.am
index dfa161b..e58bdf8 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -48,4 +48,6 @@ redirect_test_LDFLAGS = -Wl,--subsystem,windows
redirect_test_CPPFLAGS = $(GLIB2_CFLAGS)
endif
+EXTRA_DIST = meson.build
+
-include $(top_srcdir)/git.mk
diff --git a/tests/meson.build b/tests/meson.build
new file mode 100644
index 0000000..3e41a7f
--- /dev/null
+++ b/tests/meson.build
@@ -0,0 +1,16 @@
+tests = {
+ 'test-version-compare' : [],
+ 'test-monitor-mapping' : [],
+ 'test-hotkeys' : [libvirt_viewer_lib],
+ 'test-monitor-alignment' : [],
+}
+
+foreach t, libs : tests
+ test(t,
+ executable(t,
+ ['@0 at .c'.format(t), virt_viewer_enums[1]],
+ include_directories : virt_viewer_include,
+ dependencies : virt_viewer_deps,
+ link_with : [libvirt_viewer_util_lib, libs],
+ install : false))
+endforeach
--
2.17.1
More information about the virt-tools-list
mailing list