[gnome-boxes/wip/inigomartinez/meson: 4/5] meson: Add support for building libcommon



commit 78f095086dce08b8c9c7ab1683e7058b0f4935fd
Author: Iñigo Martínez <inigomartinez gmail com>
Date:   Sat Dec 9 20:13:51 2017 +0100

    meson: Add support for building libcommon
    
    Autotools builds a static library called libcommon which is used to
    build gnome-boxes but also gnome-boxes-search-provider executable.
    
    This patch adds support for building this library.

 meson.build     |   12 ++++++++-
 src/meson.build |   73 ++++++++++++++++++++++++++++++++----------------------
 2 files changed, 54 insertions(+), 31 deletions(-)
---
diff --git a/meson.build b/meson.build
index 260d564..fae65c6 100644
--- a/meson.build
+++ b/meson.build
@@ -8,6 +8,9 @@ project ('gnome-boxes',
 gnome = import ('gnome')
 i18n = import ('i18n')
 
+cc = meson.get_compiler ('c')
+valac = meson.get_compiler ('vala')
+
 glib = dependency ('glib-2.0', version: '>= 2.38.0')
 gio = dependency ('gio-2.0', version: '>= 2.38.0')
 gobject = dependency ('gobject-2.0', version: '>= 2.44')
@@ -27,7 +30,14 @@ spice_client_gtk = dependency ('spice-client-gtk-3.0', version: '>= 0.32')
 tracker = dependency ('tracker-sparql-2.0')
 webkitgtk = dependency ('webkit2gtk-4.0')
 
-cc = meson.get_compiler ('c')
+src_dir = join_paths (meson.source_root (), 'src')
+vapi_dir = join_paths (meson.source_root (), 'vapi')
+
+config = valac.find_library('config', dirs: src_dir)
+gio_workaround = valac.find_library('gio-2.0-workaround', dirs: vapi_dir)
+linux = valac.find_library('linux')
+posix = valac.find_library('posix')
+rest = valac.find_library('rest-0.7')
 
 pkglibdir = join_paths (get_option ('libdir'), meson.project_name ())
 libgd = subproject (
diff --git a/src/meson.build b/src/meson.build
index d503741..84c0cb1 100644
--- a/src/meson.build
+++ b/src/meson.build
@@ -5,6 +5,43 @@ common_sources = [
   'util.vala',
 ]
 
+vala_args = [
+  '--enable-experimental',
+  '--target-glib', '2.44',
+  '--vapidir', vapi_dir,
+  '--vapidir', join_paths (vapi_dir, 'upstream'),
+  '--vapidir', join_paths (meson.build_root (), 'subprojects', 'libgd', 'libgd'),
+  '--gresources', resource_files,
+]
+
+common_dependencies = [
+  config,
+  glib,
+  gio,
+  libarchive,
+]
+
+c_args = [
+  '-DDATADIR="' + data_dir + '"',
+  '-DGNOMELOCALEDIR="' + locale_dir + '"',
+  '-DGETTEXT_PACKAGE="gnome-boxes"',
+  '-DCACHEDIR="/var/cache/"',
+  '-DG_LOG_DOMAIN="Boxes"',
+]
+
+if get_option('buildtype').contains('debug')
+  c_args += ['-O0', '-ggdb3']
+endif
+
+libcommon = static_library(
+  'common',
+  sources: common_sources,
+  include_directories: config_h_dir,
+  dependencies: common_dependencies,
+  vala_args: vala_args,
+  c_args: c_args
+)
+
 vala_sources = [
   'app.vala',
   'app-window.vala',
@@ -86,29 +123,13 @@ if govirt.found ()
 endif
 
 boxes_sources = [
-  common_sources,
   vala_sources,
   resources
 ]
 
-vala_args = [
-  '--enable-experimental',
-  '--target-glib', '2.44',
-  '--vapidir', meson.current_source_dir (),
-  '--vapidir', join_paths (meson.source_root (), 'vapi'),
-  '--vapidir', join_paths (meson.source_root (), 'vapi', 'upstream'),
-  '--vapidir', join_paths (meson.build_root (), 'subprojects', 'libgd', 'libgd'),
-  '--pkg', 'config',
-  '--pkg', 'gio-2.0-workaround',
-  '--pkg', 'posix',
-  '--pkg', 'linux',
-  '--pkg', 'rest-0.7',
-  '--gresources', resource_files,
-]
-
 dependencies = [
-  glib,
-  gio,
+  config,
+  gio_workaround,
   gobject,
   gtk,
   gtk_vnc,
@@ -119,12 +140,15 @@ dependencies = [
   libvirt_gconfig,
   libxml,
   libusb,
+  linux,
   spice_client_gtk,
   gudev,
   libosinfo,
   libsoup,
   libarchive,
+  rest,
   tracker,
+  posix,
   webkitgtk,
 ]
 
@@ -134,22 +158,11 @@ if govirt.found()
   endif
 endif
 
-c_args = [
-  '-DDATADIR="' + data_dir + '"',
-  '-DGNOMELOCALEDIR="' + locale_dir + '"',
-  '-DGETTEXT_PACKAGE="gnome-boxes"',
-  '-DCACHEDIR="/var/cache/"',
-  '-DG_LOG_DOMAIN="Boxes"',
-]
-
-if get_option('buildtype').contains('debug')
-  c_args += ['-O0', '-ggdb3']
-endif
-
 executable ('gnome-boxes', boxes_sources,
             include_directories: config_h_dir,
             vala_args: vala_args,
             c_args : c_args,
             dependencies: dependencies,
+            link_with: libcommon,
             install: true
 )


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