meson: Improve crypto support build

There are multiple conditional steps for building encryption
support. This is because the support varies from `gnutls` or `nss`.

This has been improved to reduce the number of used conditions.
This commit is contained in:
Iñigo Martínez 2019-09-05 09:11:07 +02:00 committed by Thomas Haller
parent de90fc0810
commit ad4834009b
2 changed files with 25 additions and 35 deletions

View file

@ -177,11 +177,8 @@ shared_nm_libnm_core_intern_dep = declare_dependency(
###############################################################################
deps = [
dl_dep,
crypto_dep,
libnm_utils_base_dep,
libudev_dep,
uuid_dep,
shared_nm_libnm_core_intern_dep,
]
cflags = [
@ -189,37 +186,26 @@ cflags = [
'-DNETWORKMANAGER_COMPILATION=NM_NETWORKMANAGER_COMPILATION_LIBNM_CORE',
]
libnm_crypto = static_library(
'nm-crypto',
sources: 'nm-crypto-@0@.c'.format(crypto),
dependencies: deps,
c_args: cflags,
)
deps = [
dl_dep,
libnm_utils_base_dep,
libudev_dep,
uuid_dep,
shared_nm_libnm_core_intern_dep,
]
if enable_json_validation
libnm_core_sources += files('nm-json.c')
deps += jansson_dep
endif
if (crypto_gnutls_dep.found())
libnm_crypto_gnutls = static_library(
'nm-crypto-gnutls',
sources: [ 'nm-crypto-gnutls.c' ],
dependencies: deps + [ crypto_gnutls_dep ],
c_args: cflags,
)
endif
if (crypto_nss_dep.found())
libnm_crypto_nss = static_library(
'nm-crypto-nss',
sources: [ 'nm-crypto-nss.c' ],
dependencies: deps + [ crypto_nss_dep ],
c_args: cflags,
)
endif
if crypto == 'gnutls'
libnm_crypto = libnm_crypto_gnutls
elif crypto == 'nss'
libnm_crypto = libnm_crypto_nss
else
error('bug')
endif
libnm_core_sources_all = libnm_core_sources
libnm_core_sources_all += libnm_core_enum
libnm_core_sources_all += nm_meta_setting_source

View file

@ -475,14 +475,18 @@ if enable_polkit_agent
endif
config_h.set10('WITH_POLKIT_AGENT', enable_polkit_agent)
crypto_gnutls_dep = dependency('gnutls', version: '>= 2.12', required: false)
crypto_nss_dep = dependency('nss', required: false)
crypto = get_option('crypto')
if crypto == 'nss'
assert(crypto_nss_dep.found(), 'Requires gnutls crypto support')
crypto_dep = dependency('nss', required: false)
assert(crypto_dep.found(), 'Requires nss crypto support')
elif crypto == 'gnutls'
assert(crypto_gnutls_dep.found(), 'Requires gnutls crypto support')
crypto_dep = dependency(
'gnutls',
version: '>= 2.12',
required: false,
)
assert(crypto_dep.found(), 'Requires gnutls crypto support')
else
error('bug')
endif
@ -961,7 +965,7 @@ output += ' code coverage: ' + get_option('b_coverage').to_string() + '\n'
output += ' LTO: ' + enable_lto.to_string() + '\n'
output += ' Linker garbage collection: ' + enable_ld_gc.to_string() + '\n'
output += ' JSON validation for libnm: ' + enable_json_validation.to_string() + '\n'
output += ' crypto: ' + crypto + ' (have-gnutls: ' + crypto_gnutls_dep.found().to_string() + ', have-nss: ' + crypto_nss_dep.found().to_string() + ')\n'
output += ' crypto: ' + crypto + '\n'
output += ' sanitizers: ' + get_option('b_sanitize') + '\n'
output += ' Mozilla Public Suffix List: ' + enable_libpsl.to_string() + '\n'
output += ' vapi: ' + enable_vapi.to_string() + '\n'