[grilo/wip/jtojnar/meson-fixes] build: Improve meson files



commit 166612aeff09e5fc2fec1f62185c84cbdcf8f889
Author: Jan Tojnar <jtojnar gmail com>
Date:   Wed Nov 21 19:55:31 2018 +0100

    build: Improve meson files
    
    Several portability fixes to make grilo-plugins build on NixOS:
    
    - Change option names to more idiomatic style
    - Change vala option to vapi for compatibility with newer meson
    - Fix path handling in pkgconfig

 bindings/vala/meson.build | 10 +++++-----
 doc/meson.build           |  2 +-
 meson.build               | 29 ++++++++++++++++++++---------
 meson_options.txt         | 12 ++++++------
 src/meson.build           |  2 ++
 5 files changed, 34 insertions(+), 21 deletions(-)
---
diff --git a/bindings/vala/meson.build b/bindings/vala/meson.build
index 3190f00..6c15c97 100644
--- a/bindings/vala/meson.build
+++ b/bindings/vala/meson.build
@@ -5,12 +5,11 @@
 #
 # Copyright (C) 2016 Igalia S.L. All rights reserved.
 
-vapidir = join_paths([
-    prefix,
-    get_option('datadir'),
+vapidir = join_paths(
+    datadir,
     'vala',
     'vapi',
-])
+)
 
 vala_sources = [ # LIBRARY, GIR, DEPS
     ['grilo-@0@'.format(grl_majorminor), grl_gir[0], ['gmodule-2.0', 'gio-2.0']],
@@ -26,6 +25,7 @@ foreach s: vala_sources
     gnome.generate_vapi(lib,
         sources: [custom_vala, gir],
         packages: deps,
-        install: true)
+        install: true,
+        install_dir: vapidir)
 endforeach
 
diff --git a/doc/meson.build b/doc/meson.build
index 6872d8c..00ffb4a 100644
--- a/doc/meson.build
+++ b/doc/meson.build
@@ -7,6 +7,6 @@
 
 subdir('man')
 
-if get_option('enable-gtk-doc')
+if get_option('gtk_doc')
     subdir('grilo')
 endif
diff --git a/meson.build b/meson.build
index 7f237c6..d628881 100644
--- a/meson.build
+++ b/meson.build
@@ -46,36 +46,47 @@ gmodule_dep = dependency('gmodule-2.0', version: glib2_required_info, required:
 gobject_dep = dependency('gobject-2.0', version: glib2_required_info, required: true)
 libxml_dep = dependency('libxml-2.0', required: true)
 
-enable_grlnet = get_option('enable-grl-net')
+enable_grlnet = get_option('grl_net')
 if enable_grlnet
     libsoup_dep = dependency('libsoup-2.4', version: '>= 2.41.3', required: true)
 endif
 
-enable_grlpls = get_option('enable-grl-pls')
+enable_grlpls = get_option('grl_pls')
 if enable_grlpls
     totem_plparser_dep = dependency('totem-plparser', version: '>= 3.4.1', required: true)
 endif
 
-enable_gir = get_option('enable-introspection') or get_option('enable-vala')
+enable_gir = get_option('introspection') or get_option('vapi')
 if enable_gir
    find_program('g-ir-scanner', required: true)
 endif
 
-enable_vala = get_option('enable-vala')
+enable_vala = get_option('vapi')
 if enable_vala
     vapigen = find_program('vapigen', required: true)
 endif
 
-enable_testui = get_option('enable-test-ui')
+enable_testui = get_option('test_ui')
 if enable_testui
     gtk_dep = dependency('gtk+-3.0', version: '>= 3.14', required: true)
     oauth_dep = dependency('oauth', required: false)
 endif
 
 prefix = get_option('prefix')
+includedir = join_paths(prefix, get_option('includedir'))
 libdir = join_paths(prefix, get_option('libdir'))
 plugins_dir = join_paths(libdir, grl_name)
 localedir = join_paths(prefix, get_option('localedir'))
+datadir = join_paths(prefix, get_option('datadir'))
+
+gobject_introspection = dependency('gobject-introspection-1.0', required: false)
+if gobject_introspection.found()
+    girdir = gobject_introspection.get_pkgconfig_variable('girdir', define_variable: ['datadir', datadir])
+    typelibdir = gobject_introspection.get_pkgconfig_variable('typelibdir', define_variable: ['libdir', 
libdir])
+else
+    girdir = join_paths(datadir, 'gir-1.0')
+    typelibdir = join_paths(libdir, 'girepository-1.0')
+endif
 
 cdata = configuration_data()
 cdata.set_quoted('VERSION', grilo_version)
@@ -99,11 +110,11 @@ pkgconf = configuration_data()
 pkgconf.set('prefix', prefix)
 pkgconf.set('exec_prefix', '${prefix}')
 pkgconf.set('libdir', libdir)
-pkgconf.set('includedir', '${prefix}/@0@'.format(get_option('includedir')))
+pkgconf.set('includedir', join_paths('${prefix}', includedir))
 pkgconf.set('GRL_NAME', grl_name)
 pkgconf.set('GRL_PLUGINS_DIR', plugins_dir)
-pkgconf.set('INTROSPECTION_GIRDIR', '${datarootdir}/gir-1.0')
-pkgconf.set('INTROSPECTION_TYPELIBDIR', '${libdir}/girepository-1.0'.format(get_option('libdir')))
+pkgconf.set('INTROSPECTION_GIRDIR', join_paths('${prefix}', girdir))
+pkgconf.set('INTROSPECTION_TYPELIBDIR', join_paths('${prefix}', typelibdir))
 pkgconf.set('VERSION', grilo_version)
 pkgconf.set('GRLNET_VERSION', grlnet_version)
 pkgconf.set('GRLPLS_VERSION', grlpls_version)
@@ -114,7 +125,7 @@ foreach p: pkgconfig_files
     configure_file(input: infile,
         output: outfile,
         configuration: pkgconf,
-        install_dir: '@0@/pkgconfig'.format(get_option('libdir')))
+        install_dir: join_paths(libdir, 'pkgconfig'))
 endforeach
 
 gnome = import('gnome')
diff --git a/meson_options.txt b/meson_options.txt
index 5f396a1..d4800f1 100644
--- a/meson_options.txt
+++ b/meson_options.txt
@@ -1,6 +1,6 @@
-option('enable-grl-net', type: 'boolean', value: true, description: 'Enable Grilo Net library')
-option('enable-grl-pls', type: 'boolean', value: true, description: 'Enable Grilo Pls library')
-option('enable-gtk-doc', type: 'boolean', value: false, description: 'Enable generating the API reference')
-option('enable-introspection', type: 'boolean', value: true, description: 'Enable GObject Introspection')
-option('enable-test-ui', type: 'boolean', value: true, description: 'Build Test UI')
-option('enable-vala', type: 'boolean', value: true, description: 'Enable Vala (enables GObject 
Introspection)')
+option('grl_net', type: 'boolean', value: true, description: 'Enable Grilo Net library')
+option('grl_pls', type: 'boolean', value: true, description: 'Enable Grilo Pls library')
+option('gtk_doc', type: 'boolean', value: false, description: 'Enable generating the API reference')
+option('introspection', type: 'boolean', value: true, description: 'Enable GObject Introspection')
+option('test_ui', type: 'boolean', value: true, description: 'Build Test UI')
+option('vapi', type: 'boolean', value: true, description: 'Enable Vala (enables GObject Introspection)')
diff --git a/src/meson.build b/src/meson.build
index 36c34b3..2eb46f6 100644
--- a/src/meson.build
+++ b/src/meson.build
@@ -120,5 +120,7 @@ if enable_gir
         dependencies: [ gobject_dep, gmodule_dep, gio_dep ],
         includes: [ 'GObject-2.0', 'GModule-2.0', 'Gio-2.0' ],
         install: true,
+        install_dir_gir: girdir,
+        install_dir_typelib: typelibdir,
         extra_args: gir_extra_args)
 endif


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