[v3,2/4] build: use dependency() instead of find_library()
Checks
Commit Message
Whenever possible (if the library ships a pkg-config file) use meson's
dependency() function to look for it, as it will automatically add it
to the Requires.private list if needed, to allow for static builds to
succeed for reverse dependencies of DPDK. Otherwise the recursive
dependencies are not parsed, and users doing static builds have to
resolve them manually by themselves.
When using this API avoid additional checks that are superfluos and
take extra time, and avoid adding the linker flag manually which causes
it to be duplicated.
Signed-off-by: Luca Boccassi <bluca@debian.org>
---
v2: split libbsd change in a separate commit, remove CC to stable
as a meson bump will be required
drivers/crypto/ccp/meson.build | 1 -
drivers/crypto/openssl/meson.build | 1 -
drivers/crypto/qat/meson.build | 1 -
drivers/meson.build | 2 +-
drivers/net/bnx2x/meson.build | 2 +-
drivers/net/mlx4/meson.build | 6 +++---
drivers/net/mlx5/meson.build | 6 +++---
drivers/net/pcap/meson.build | 5 ++---
lib/librte_bpf/meson.build | 4 ++--
lib/librte_telemetry/meson.build | 2 +-
10 files changed, 13 insertions(+), 17 deletions(-)
Comments
On Fri, Jan 11, 2019 at 04:26:06PM +0000, Luca Boccassi wrote:
> Whenever possible (if the library ships a pkg-config file) use meson's
> dependency() function to look for it, as it will automatically add it
> to the Requires.private list if needed, to allow for static builds to
> succeed for reverse dependencies of DPDK. Otherwise the recursive
> dependencies are not parsed, and users doing static builds have to
> resolve them manually by themselves.
> When using this API avoid additional checks that are superfluos and
Spelling: superfluous
> take extra time, and avoid adding the linker flag manually which causes
> it to be duplicated.
>
> Signed-off-by: Luca Boccassi <bluca@debian.org>
> ---
> v2: split libbsd change in a separate commit, remove CC to stable
> as a meson bump will be required
>
> drivers/crypto/ccp/meson.build | 1 -
> drivers/crypto/openssl/meson.build | 1 -
> drivers/crypto/qat/meson.build | 1 -
> drivers/meson.build | 2 +-
> drivers/net/bnx2x/meson.build | 2 +-
> drivers/net/mlx4/meson.build | 6 +++---
> drivers/net/mlx5/meson.build | 6 +++---
> drivers/net/pcap/meson.build | 5 ++---
> lib/librte_bpf/meson.build | 4 ++--
> lib/librte_telemetry/meson.build | 2 +-
> 10 files changed, 13 insertions(+), 17 deletions(-)
>
> diff --git a/drivers/crypto/ccp/meson.build b/drivers/crypto/ccp/meson.build
> index e43b00591..915c4c854 100644
> --- a/drivers/crypto/ccp/meson.build
> +++ b/drivers/crypto/ccp/meson.build
> @@ -18,4 +18,3 @@ sources = files('rte_ccp_pmd.c',
> 'ccp_pmd_ops.c')
>
> ext_deps += dep
> -pkgconfig_extra_libs += '-lcrypto'
> diff --git a/drivers/crypto/openssl/meson.build b/drivers/crypto/openssl/meson.build
> index c2a0dd8ba..80e5e8835 100644
> --- a/drivers/crypto/openssl/meson.build
> +++ b/drivers/crypto/openssl/meson.build
> @@ -8,4 +8,3 @@ endif
> deps += 'bus_vdev'
> sources = files('rte_openssl_pmd.c', 'rte_openssl_pmd_ops.c')
> ext_deps += dep
> -pkgconfig_extra_libs += '-lcrypto'
> diff --git a/drivers/crypto/qat/meson.build b/drivers/crypto/qat/meson.build
> index 9cc98d2c2..21f969735 100644
> --- a/drivers/crypto/qat/meson.build
> +++ b/drivers/crypto/qat/meson.build
> @@ -13,6 +13,5 @@ if dep.found()
> 'qat_sym.c',
> 'qat_sym_session.c')
> qat_ext_deps += dep
> - pkgconfig_extra_libs += '-lcrypto'
> qat_cflags += '-DBUILD_QAT_SYM'
> endif
> diff --git a/drivers/meson.build b/drivers/meson.build
> index e37d4fe2b..d17ca76eb 100644
> --- a/drivers/meson.build
> +++ b/drivers/meson.build
> @@ -46,7 +46,7 @@ foreach class:driver_classes
> # set up internal deps. Drivers can append/override as necessary
> deps = std_deps
> # ext_deps: Stores external library dependency got
> - # using dependency() or cc.find_library(). For most cases, we
> + # using dependency() (preferred) or find_library(). For most cases, we
> # probably also need to specify the "-l" flags in
> # pkgconfig_extra_libs variable too, so that it can be reflected
> # in the pkgconfig output for static builds
The last part of this comment can now be deleted, right? If we use
dependency() we don't need to use pkgconfig_extra_libs.
Is the pkgconfig_extra_libs variable still needed after these changes?
/Bruce
On Fri, 2019-01-11 at 17:21 +0000, Bruce Richardson wrote:
> On Fri, Jan 11, 2019 at 04:26:06PM +0000, Luca Boccassi wrote:
> > Whenever possible (if the library ships a pkg-config file) use
> > meson's
> > dependency() function to look for it, as it will automatically add
> > it
> > to the Requires.private list if needed, to allow for static builds
> > to
> > succeed for reverse dependencies of DPDK. Otherwise the recursive
> > dependencies are not parsed, and users doing static builds have to
> > resolve them manually by themselves.
> > When using this API avoid additional checks that are superfluos and
>
> Spelling: superfluous
I _always_ get that one wrong :-)
> > take extra time, and avoid adding the linker flag manually which
> > causes
> > it to be duplicated.
> >
> > Signed-off-by: Luca Boccassi <bluca@debian.org>
> > ---
> > v2: split libbsd change in a separate commit, remove CC to stable
> > as a meson bump will be required
> >
> > drivers/crypto/ccp/meson.build | 1 -
> > drivers/crypto/openssl/meson.build | 1 -
> > drivers/crypto/qat/meson.build | 1 -
> > drivers/meson.build | 2 +-
> > drivers/net/bnx2x/meson.build | 2 +-
> > drivers/net/mlx4/meson.build | 6 +++---
> > drivers/net/mlx5/meson.build | 6 +++---
> > drivers/net/pcap/meson.build | 5 ++---
> > lib/librte_bpf/meson.build | 4 ++--
> > lib/librte_telemetry/meson.build | 2 +-
> > 10 files changed, 13 insertions(+), 17 deletions(-)
> >
> > diff --git a/drivers/crypto/ccp/meson.build
> > b/drivers/crypto/ccp/meson.build
> > index e43b00591..915c4c854 100644
> > --- a/drivers/crypto/ccp/meson.build
> > +++ b/drivers/crypto/ccp/meson.build
> > @@ -18,4 +18,3 @@ sources = files('rte_ccp_pmd.c',
> > 'ccp_pmd_ops.c')
> >
> > ext_deps += dep
> > -pkgconfig_extra_libs += '-lcrypto'
> > diff --git a/drivers/crypto/openssl/meson.build
> > b/drivers/crypto/openssl/meson.build
> > index c2a0dd8ba..80e5e8835 100644
> > --- a/drivers/crypto/openssl/meson.build
> > +++ b/drivers/crypto/openssl/meson.build
> > @@ -8,4 +8,3 @@ endif
> > deps += 'bus_vdev'
> > sources = files('rte_openssl_pmd.c', 'rte_openssl_pmd_ops.c')
> > ext_deps += dep
> > -pkgconfig_extra_libs += '-lcrypto'
> > diff --git a/drivers/crypto/qat/meson.build
> > b/drivers/crypto/qat/meson.build
> > index 9cc98d2c2..21f969735 100644
> > --- a/drivers/crypto/qat/meson.build
> > +++ b/drivers/crypto/qat/meson.build
> > @@ -13,6 +13,5 @@ if dep.found()
> > 'qat_sym.c',
> > 'qat_sym_session.c')
> > qat_ext_deps += dep
> > - pkgconfig_extra_libs += '-lcrypto'
> > qat_cflags += '-DBUILD_QAT_SYM'
> > endif
> > diff --git a/drivers/meson.build b/drivers/meson.build
> > index e37d4fe2b..d17ca76eb 100644
> > --- a/drivers/meson.build
> > +++ b/drivers/meson.build
> > @@ -46,7 +46,7 @@ foreach class:driver_classes
> > # set up internal deps. Drivers can
> > append/override as necessary
> > deps = std_deps
> > # ext_deps: Stores external library dependency got
> > - # using dependency() or cc.find_library(). For
> > most cases, we
> > + # using dependency() (preferred) or
> > find_library(). For most cases, we
> > # probably also need to specify the "-l" flags in
> > # pkgconfig_extra_libs variable too, so that it
> > can be reflected
> > # in the pkgconfig output for static builds
>
> The last part of this comment can now be deleted, right? If we use
> dependency() we don't need to use pkgconfig_extra_libs.
>
> Is the pkgconfig_extra_libs variable still needed after these
> changes?
>
> /Bruce
Yes, as we can't use dependency() for everything unfortunately - only
for those projects that ship a pkg-config file, a cmake file or that
Meson has built-in knowledge of (like llvm or libpcap).
I'll update that comment accordingly in v4.
On Fri, Jan 11, 2019 at 06:16:23PM +0000, Luca Boccassi wrote:
> On Fri, 2019-01-11 at 17:21 +0000, Bruce Richardson wrote:
> > On Fri, Jan 11, 2019 at 04:26:06PM +0000, Luca Boccassi wrote:
> > > Whenever possible (if the library ships a pkg-config file) use
> > > meson's
> > > dependency() function to look for it, as it will automatically add
> > > it
> > > to the Requires.private list if needed, to allow for static builds
> > > to
> > > succeed for reverse dependencies of DPDK. Otherwise the recursive
> > > dependencies are not parsed, and users doing static builds have to
> > > resolve them manually by themselves.
> > > When using this API avoid additional checks that are superfluos and
> >
> > Spelling: superfluous
>
> I _always_ get that one wrong :-)
>
I often spell it as "unnecessary" to make life easier :-)
@@ -18,4 +18,3 @@ sources = files('rte_ccp_pmd.c',
'ccp_pmd_ops.c')
ext_deps += dep
-pkgconfig_extra_libs += '-lcrypto'
@@ -8,4 +8,3 @@ endif
deps += 'bus_vdev'
sources = files('rte_openssl_pmd.c', 'rte_openssl_pmd_ops.c')
ext_deps += dep
-pkgconfig_extra_libs += '-lcrypto'
@@ -13,6 +13,5 @@ if dep.found()
'qat_sym.c',
'qat_sym_session.c')
qat_ext_deps += dep
- pkgconfig_extra_libs += '-lcrypto'
qat_cflags += '-DBUILD_QAT_SYM'
endif
@@ -46,7 +46,7 @@ foreach class:driver_classes
# set up internal deps. Drivers can append/override as necessary
deps = std_deps
# ext_deps: Stores external library dependency got
- # using dependency() or cc.find_library(). For most cases, we
+ # using dependency() (preferred) or find_library(). For most cases, we
# probably also need to specify the "-l" flags in
# pkgconfig_extra_libs variable too, so that it can be reflected
# in the pkgconfig output for static builds
@@ -1,7 +1,7 @@
# SPDX-License-Identifier: BSD-3-Clause
# Copyright(c) 2018 Intel Corporation
-dep = cc.find_library('z', required: false)
+dep = dependency('zlib', required: false)
build = dep.found()
ext_deps += dep
cflags += '-DZLIB_CONST'
@@ -14,9 +14,9 @@ if pmd_dlopen
]
endif
libs = [
- cc.find_library('mnl', required:false),
- cc.find_library('mlx4', required:false),
- cc.find_library('ibverbs', required:false),
+ dependency('libmnl', required:false),
+ dependency('libmlx4', required:false),
+ dependency('libibverbs', required:false),
]
build = true
foreach lib:libs
@@ -14,9 +14,9 @@ if pmd_dlopen
]
endif
libs = [
- cc.find_library('mnl', required:false),
- cc.find_library('mlx5', required:false),
- cc.find_library('ibverbs', required:false),
+ dependency('libmnl', required:false),
+ dependency('libmlx5', required:false),
+ dependency('libibverbs', required:false),
]
build = true
foreach lib:libs
@@ -1,12 +1,11 @@
# SPDX-License-Identifier: BSD-3-Clause
# Copyright(c) 2017 Intel Corporation
-pcap_dep = cc.find_library('pcap', required: false)
-if pcap_dep.found() and cc.has_header('pcap.h', dependencies: pcap_dep)
+pcap_dep = dependency('pcap', required: false)
+if pcap_dep.found()
build = true
else
build = false
endif
sources = files('rte_eth_pcap.c')
ext_deps += pcap_dep
-pkgconfig_extra_libs += '-lpcap'
@@ -18,8 +18,8 @@ install_headers = files('bpf_def.h',
deps += ['mbuf', 'net', 'ethdev']
-dep = cc.find_library('elf', required: false)
-if dep.found() == true and cc.has_header('libelf.h', dependencies: dep)
+dep = dependency('libelf', required: false)
+if dep.found()
sources += files('bpf_load_elf.c')
ext_deps += dep
endif
@@ -6,7 +6,7 @@ headers = files('rte_telemetry.h', 'rte_telemetry_internal.h', 'rte_telemetry_pa
deps += ['metrics', 'ethdev']
cflags += '-DALLOW_EXPERIMENTAL_API'
-jansson = cc.find_library('jansson', required: false)
+jansson = dependency('jansson', required: false)
if jansson.found()
ext_deps += jansson
dpdk_app_link_libraries += ['telemetry']