[pacman-dev] [PATCH 0/3] meson updates
Let's take advantage of the latest version of meson to make our meson.build smaller! New in 0.51 is also the dep.get_variable() function which is "a generic replacement for type specific variable getters" but I decided not to bother using it since it doesn't actually make get_pkgconfig_variable() shorter and the only benefit would be allowing us to also detect bash-completion using cmake (!!!) and there really is no need to pander to that. Eli Schwartz (3): meson: bump the minimum supported version of meson to 0.51 meson: use not_found_message when dependencies are not found meson: use dependency('gpgme') exclusively meson.build | 47 ++++++++++------------------------------------- meson_options.txt | 2 -- 2 files changed, 10 insertions(+), 39 deletions(-) -- 2.22.0
We haven't reached our first public release of the meson build backend yet, so we have lots of flexibility for this... and build dependencies are easier to upgrade than runtime dependencies anyway. Updating meson allows us to make use of a bunch of new features that rewquire the latest version of meson. Signed-off-by: Eli Schwartz <eschwartz@archlinux.org> --- This is probably my most controversial patch ever. meson.build | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/meson.build b/meson.build index 91f05031..de309e30 100644 --- a/meson.build +++ b/meson.build @@ -8,7 +8,7 @@ project('pacman', 'sysconfdir=/etc', 'localstatedir=/var', ], - meson_version : '>= 0.47') + meson_version : '>= 0.51') libalpm_version = '11.0.1' -- 2.22.0
The default state of `dependency()` is `required: true`, which means if a dependency is not found, meson immediately aborts and does not log our `error()` messages. meson 0.50 has builtin support for dependencies with custom error messages. The alternative would be to specify `required: false` everywhere, and only then to key off of `dep.found()`. Signed-off-by: Eli Schwartz <eschwartz@archlinux.org> --- meson.build | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/meson.build b/meson.build index de309e30..f5fdd733 100644 --- a/meson.build +++ b/meson.build @@ -130,17 +130,13 @@ endif want_crypto = get_option('crypto') if want_crypto == 'openssl' - libcrypto = dependency('libcrypto', static : get_option('buildstatic')) - if not libcrypto.found() - error('openssl support requested but not found') - endif + libcrypto = dependency('libcrypto', static : get_option('buildstatic'), + not_found_message : 'openssl support requested but not found') crypto_provider = libcrypto conf.set10('HAVE_LIBSSL', true) elif want_crypto == 'nettle' - libnettle = dependency('nettle', static : get_option('buildstatic')) - if not libnettle.found() - error('nettle support requested but not found') - endif + libnettle = dependency('nettle', static : get_option('buildstatic'), + not_found_message : 'nettle support requested but not found') crypto_provider = libnettle conf.set10('HAVE_LIBNETTLE', true) else -- 2.22.0
This works everywhere that gpgme >= 1.13.0 because it is a pkg-config dependency, and meson 0.51 adds a fallback config-tool dependency provider that detects older versions of gpgme seamlessly via gpgme-config. Signed-off-by: Eli Schwartz <eschwartz@archlinux.org> --- 25 lines gone, if only we could do the same to configure.ac :p meson.build | 33 +++++---------------------------- meson_options.txt | 2 -- 2 files changed, 5 insertions(+), 30 deletions(-) diff --git a/meson.build b/meson.build index f5fdd733..db9e9349 100644 --- a/meson.build +++ b/meson.build @@ -97,36 +97,13 @@ libcurl = dependency('libcurl', static : get_option('buildstatic')) conf.set('HAVE_LIBCURL', libcurl.found()) -want_gpgme = get_option('gpgme') +needed_gpgme_version = '>=1.3.0' gpgme = dependency('gpgme', - required : false, - static : get_option('buildstatic')) -# gpgme recently began providing a pkg-config file. Create a fake dependency -# object if it cannot be found, by manually searching for libs. -if not want_gpgme.disabled() and not gpgme.found() - gpgme_config = find_program('gpgme-config', required : want_gpgme) - if gpgme_config.found() - gpgme_version = run_command(gpgme_config, '--version').stdout().strip() - - needed_gpgme_version = '>=1.3.0' - if gpgme_version.version_compare(needed_gpgme_version) - gpgme_libs = [ - cc.find_library('gpgme', - dirs : [get_option('gpgme-libdir')]), - cc.find_library('gpg-error', - dirs : [get_option('gpgme-libdir')]), - cc.find_library('assuan', - dirs : [get_option('gpgme-libdir')]), - ] - gpgme = declare_dependency(dependencies : gpgme_libs) - endif - endif -endif - + version : needed_gpgme_version, + required : get_option('gpgme'), + static : get_option('buildstatic'), + not_found_message : 'gpgme @0@ is needed for GPG signature support'.format(needed_gpgme_version)) conf.set('HAVE_LIBGPGME', gpgme.found()) -if want_gpgme.enabled() and not conf.get('HAVE_LIBGPGME') - error('gpgme @0@ is needed for GPG signature support'.format(needed_gpgme_version)) -endif want_crypto = get_option('crypto') if want_crypto == 'openssl' diff --git a/meson_options.txt b/meson_options.txt index ffa4ddff..2d640e87 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -47,8 +47,6 @@ option('crypto', type : 'combo', choices : ['openssl', 'nettle'], option('gpgme', type : 'feature', value : 'auto', description : 'use GPGME for PGP signature verification') -option('gpgme-libdir', type : 'string', value : '/usr/lib', - description : 'search directory for gpgme libraries.') option('i18n', type : 'boolean', value : true, description : 'enable localization of pacman, libalpm and scripts') -- 2.22.0
participants (1)
-
Eli Schwartz