build: Make use of assert function

meson has support for `assert` function, which halts meson's
execution showing a given message when a given condition is false.

This patch takes advantage of this function to slightly improve
meson's build file readibility.

It also removes a duplicated check for `pkglibdir` being set when
introspection is also set, because this check is already done when
a shared library is being created, that is a precondition for
introspection generation.

https://bugzilla.gnome.org/show_bug.cgi?id=792948
This commit is contained in:
Iñigo Martínez 2018-01-27 09:45:58 +01:00
parent f764bb68e0
commit 69eac7d7cc

View File

@ -3,9 +3,7 @@ project('gvc', 'c',
default_options: ['static=true'] default_options: ['static=true']
) )
if not meson.is_subproject() assert(meson.is_subproject(), 'This project is only intended to be used as a subproject!')
error('This project is only intended to be used as a subproject!')
endif
gnome = import('gnome') gnome = import('gnome')
@ -68,9 +66,8 @@ cdata.set('HAVE_ALSA', enable_alsa)
enable_static = get_option('static') enable_static = get_option('static')
enable_introspection = get_option('introspection') enable_introspection = get_option('introspection')
if enable_static and enable_introspection assert(not enable_static or not enable_introspection, 'Currently meson requires a shared library for building girs.')
error('Currently meson requires a shared library for building girs.') assert(enable_static or pkglibdir != '', 'Installing shared library, but pkglibdir is unset!')
endif
c_args = ['-DG_LOG_DOMAIN="Gvc"'] c_args = ['-DG_LOG_DOMAIN="Gvc"']
@ -106,11 +103,7 @@ else
endif endif
if enable_introspection if enable_introspection
if pkgdatadir == '' assert(pkgdatadir != '', 'Installing introspection, but pkgdatadir is unset!')
error('Installing introspection, but pkgdatadir is unset!')
elif (pkglibdir == '')
error('Installing introspection, but pkglibdir is unset!')
endif
libgvc_gir = gnome.generate_gir(libgvc, libgvc_gir = gnome.generate_gir(libgvc,
sources: libgvc_gir_sources + libgvc_gir_headers, sources: libgvc_gir_sources + libgvc_gir_headers,