* Re: [dpdk-dev] [RFC] build: allow build DPDK as a meson submodule
2021-11-03 22:12 [dpdk-dev] [RFC] build: allow build DPDK as a meson submodule Stephen Hemminger
@ 2021-11-04 8:59 ` Bruce Richardson
2021-11-05 0:01 ` [dpdk-dev] [PATCH] " Stephen Hemminger
` (2 subsequent siblings)
3 siblings, 0 replies; 13+ messages in thread
From: Bruce Richardson @ 2021-11-04 8:59 UTC (permalink / raw)
To: Stephen Hemminger; +Cc: dev
On Wed, Nov 03, 2021 at 03:12:05PM -0700, Stephen Hemminger wrote:
> Some other projects using meson may not be able to use DPDK
> using the standard distribution pkg-config mechanism.
> Meson supports a way to handle this via the subproject
> https://mesonbuild.com/Subprojects.html
>
> This patch adds the necessary depedency to follow the
> "Naming convention for depedency variables" from the documentation.
> It has no impact if subproject is not being used.
>
> Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
Thanks for this Stephen. Couple of comments inline below.
/Bruce
> ---
> meson.build | 10 ++++++++++
> 1 file changed, 10 insertions(+)
>
> diff --git a/meson.build b/meson.build
> index 12cb6e0e83f3..6ce5eda2779f 100644
> --- a/meson.build
> +++ b/meson.build
> @@ -97,6 +97,16 @@ configure_file(output: build_cfg,
> # build pkg-config files for dpdk
> subdir('buildtools/pkg-config')
>
> +# If DPDK is being built as subproject then define
> +# varialble with the dependency convention
> +if meson.is_subproject()
I wonder if we should just omit this check. Defining the extra variable in
case of non-subproject should just be harmless.
> + libdpdk_dep = declare_dependency(
> + version: meson.project_version(),
> + compile_args : pkg_extra_cflags,
> + dependencies: shared_deps
> + )
"shared_deps" is almost certainly not the correct variable to use here
without additional changes to guarantee its value. That variable is used in
lib and driver meson.build files to hold the libraries to link for each
shared object, so at this point in the build, it will likely contain only
the dependencies of the final driver built, rather than all the DPDK
libraries. I think it would be safer to define "dpdk_shared_deps" global
variable at the top of this meson.build file and add to that from
lib/meson.build as each library dependency is defined.
> +endif
> +
^ permalink raw reply [flat|nested] 13+ messages in thread
* [dpdk-dev] [PATCH] build: allow build DPDK as a meson submodule
2021-11-03 22:12 [dpdk-dev] [RFC] build: allow build DPDK as a meson submodule Stephen Hemminger
2021-11-04 8:59 ` Bruce Richardson
@ 2021-11-05 0:01 ` Stephen Hemminger
2021-11-05 14:58 ` Bruce Richardson
2021-11-05 17:22 ` [dpdk-dev] [PATCH v2] build: add definitions for use as meson subproject Stephen Hemminger
2022-05-06 14:43 ` [PATCH v3] " Bruce Richardson
3 siblings, 1 reply; 13+ messages in thread
From: Stephen Hemminger @ 2021-11-05 0:01 UTC (permalink / raw)
To: Bruce Richardson; +Cc: dev, Stephen Hemminger
Some other projects using meson may not be able to use DPDK
using the standard distribution pkg-config mechanism.
Meson supports a way to handle this via the subproject
https://mesonbuild.com/Subprojects.html
This patch adds the necessary dependency to follow the
"Naming convention for dependency variables" from the documentation.
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
Cleaned up from RFC and support both static and shared.
lib/meson.build | 5 +++++
meson.build | 12 ++++++++++++
2 files changed, 17 insertions(+)
diff --git a/lib/meson.build b/lib/meson.build
index 499d26060fdd..e6df538bd6ef 100644
--- a/lib/meson.build
+++ b/lib/meson.build
@@ -241,6 +241,11 @@ foreach l:libraries
dpdk_libraries = [shared_lib] + dpdk_libraries
dpdk_static_libraries = [static_lib] + dpdk_static_libraries
+ if get_option('default_library') == 'static'
+ dpdk_libs_deps += static_dep
+ else
+ dpdk_libs_deps += shared_dep
+ endif
set_variable('shared_rte_' + name, shared_dep)
set_variable('static_rte_' + name, static_dep)
diff --git a/meson.build b/meson.build
index 12cb6e0e83f3..032783e4e6cf 100644
--- a/meson.build
+++ b/meson.build
@@ -36,6 +36,7 @@ dpdk_drivers = []
dpdk_extra_ldflags = []
dpdk_libs_disabled = []
dpdk_drvs_disabled = []
+dpdk_libs_deps = []
abi_version_file = files('ABI_VERSION')
if host_machine.cpu_family().startswith('x86')
@@ -97,6 +98,17 @@ configure_file(output: build_cfg,
# build pkg-config files for dpdk
subdir('buildtools/pkg-config')
+# If DPDK is being built as subproject then define
+# variable with the dependency convention
+if meson.is_subproject()
+ libdpdk_dep = declare_dependency(
+ version: meson.project_version(),
+ compile_args : pkg_extra_cflags,
+ dependencies: dpdk_libs_deps,
+ link_args: dpdk_extra_ldflags,
+ )
+endif
+
# final output, list all the libs and drivers to be built
# this does not affect any part of the build, for information only.
output_message = '\n=================\nLibraries Enabled\n=================\n'
--
2.30.2
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [dpdk-dev] [PATCH] build: allow build DPDK as a meson submodule
2021-11-05 0:01 ` [dpdk-dev] [PATCH] " Stephen Hemminger
@ 2021-11-05 14:58 ` Bruce Richardson
2021-11-05 16:17 ` Stephen Hemminger
0 siblings, 1 reply; 13+ messages in thread
From: Bruce Richardson @ 2021-11-05 14:58 UTC (permalink / raw)
To: Stephen Hemminger; +Cc: dev
On Thu, Nov 04, 2021 at 05:01:24PM -0700, Stephen Hemminger wrote:
> Some other projects using meson may not be able to use DPDK
> using the standard distribution pkg-config mechanism.
> Meson supports a way to handle this via the subproject
> https://mesonbuild.com/Subprojects.html
>
> This patch adds the necessary dependency to follow the
> "Naming convention for dependency variables" from the documentation.
>
> Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
> ---
> Cleaned up from RFC and support both static and shared.
>
> lib/meson.build | 5 +++++
> meson.build | 12 ++++++++++++
> 2 files changed, 17 insertions(+)
>
> diff --git a/lib/meson.build b/lib/meson.build
> index 499d26060fdd..e6df538bd6ef 100644
> --- a/lib/meson.build
> +++ b/lib/meson.build
> @@ -241,6 +241,11 @@ foreach l:libraries
>
> dpdk_libraries = [shared_lib] + dpdk_libraries
> dpdk_static_libraries = [static_lib] + dpdk_static_libraries
> + if get_option('default_library') == 'static'
> + dpdk_libs_deps += static_dep
> + else
> + dpdk_libs_deps += shared_dep
> + endif
>
> set_variable('shared_rte_' + name, shared_dep)
> set_variable('static_rte_' + name, static_dep)
> diff --git a/meson.build b/meson.build
> index 12cb6e0e83f3..032783e4e6cf 100644
> --- a/meson.build
> +++ b/meson.build
> @@ -36,6 +36,7 @@ dpdk_drivers = []
> dpdk_extra_ldflags = []
> dpdk_libs_disabled = []
> dpdk_drvs_disabled = []
> +dpdk_libs_deps = []
> abi_version_file = files('ABI_VERSION')
>
> if host_machine.cpu_family().startswith('x86')
> @@ -97,6 +98,17 @@ configure_file(output: build_cfg,
> # build pkg-config files for dpdk
> subdir('buildtools/pkg-config')
>
> +# If DPDK is being built as subproject then define
> +# variable with the dependency convention
> +if meson.is_subproject()
> + libdpdk_dep = declare_dependency(
> + version: meson.project_version(),
> + compile_args : pkg_extra_cflags,
> + dependencies: dpdk_libs_deps,
> + link_args: dpdk_extra_ldflags,
> + )
> +endif
> +
While the code all looks correct to me, when I tested it out, the resulting
app couldn't link. I tested by moving l2fwd/main.c to a new folder and
adding the following as a meson.build file in it:
project('l2fwd', 'C')
dpdk_dep = dependency('libdpdk', fallback : ['libdpdk', 'libdpdk_dep'])
executable('dpdk-l2fwd', 'main.c',
dependencies: dpdk_dep)
Even though dependencies should include both the libs to link with and the
include paths, that didn't seem to work in this case - the compile worked
fine with all cflags present, none of the DPDK libraries were given on the
link command - just the extra -ldl etc. args.
Adding "link_with: dpdk_libraries" fixed this and allowed it work for me,
but I'm surpised that it proved necessary. Stephen, does it work for you
with just the dependencies provided?
/Bruce
PS: My testing was done with meson 0.56.2 on Ubuntu 21.10.
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [dpdk-dev] [PATCH] build: allow build DPDK as a meson submodule
2021-11-05 14:58 ` Bruce Richardson
@ 2021-11-05 16:17 ` Stephen Hemminger
0 siblings, 0 replies; 13+ messages in thread
From: Stephen Hemminger @ 2021-11-05 16:17 UTC (permalink / raw)
To: Bruce Richardson; +Cc: dev
On Fri, 5 Nov 2021 14:58:24 +0000
Bruce Richardson <bruce.richardson@intel.com> wrote:
> On Thu, Nov 04, 2021 at 05:01:24PM -0700, Stephen Hemminger wrote:
> > Some other projects using meson may not be able to use DPDK
> > using the standard distribution pkg-config mechanism.
> > Meson supports a way to handle this via the subproject
> > https://mesonbuild.com/Subprojects.html
> >
> > This patch adds the necessary dependency to follow the
> > "Naming convention for dependency variables" from the documentation.
> >
> > Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
> > ---
> > Cleaned up from RFC and support both static and shared.
> >
> > lib/meson.build | 5 +++++
> > meson.build | 12 ++++++++++++
> > 2 files changed, 17 insertions(+)
> >
> > diff --git a/lib/meson.build b/lib/meson.build
> > index 499d26060fdd..e6df538bd6ef 100644
> > --- a/lib/meson.build
> > +++ b/lib/meson.build
> > @@ -241,6 +241,11 @@ foreach l:libraries
> >
> > dpdk_libraries = [shared_lib] + dpdk_libraries
> > dpdk_static_libraries = [static_lib] + dpdk_static_libraries
> > + if get_option('default_library') == 'static'
> > + dpdk_libs_deps += static_dep
> > + else
> > + dpdk_libs_deps += shared_dep
> > + endif
> >
> > set_variable('shared_rte_' + name, shared_dep)
> > set_variable('static_rte_' + name, static_dep)
> > diff --git a/meson.build b/meson.build
> > index 12cb6e0e83f3..032783e4e6cf 100644
> > --- a/meson.build
> > +++ b/meson.build
> > @@ -36,6 +36,7 @@ dpdk_drivers = []
> > dpdk_extra_ldflags = []
> > dpdk_libs_disabled = []
> > dpdk_drvs_disabled = []
> > +dpdk_libs_deps = []
> > abi_version_file = files('ABI_VERSION')
> >
> > if host_machine.cpu_family().startswith('x86')
> > @@ -97,6 +98,17 @@ configure_file(output: build_cfg,
> > # build pkg-config files for dpdk
> > subdir('buildtools/pkg-config')
> >
> > +# If DPDK is being built as subproject then define
> > +# variable with the dependency convention
> > +if meson.is_subproject()
> > + libdpdk_dep = declare_dependency(
> > + version: meson.project_version(),
> > + compile_args : pkg_extra_cflags,
> > + dependencies: dpdk_libs_deps,
> > + link_args: dpdk_extra_ldflags,
> > + )
> > +endif
> > +
>
> While the code all looks correct to me, when I tested it out, the resulting
> app couldn't link. I tested by moving l2fwd/main.c to a new folder and
> adding the following as a meson.build file in it:
>
> project('l2fwd', 'C')
>
> dpdk_dep = dependency('libdpdk', fallback : ['libdpdk', 'libdpdk_dep'])
> executable('dpdk-l2fwd', 'main.c',
> dependencies: dpdk_dep)
>
> Even though dependencies should include both the libs to link with and the
> include paths, that didn't seem to work in this case - the compile worked
> fine with all cflags present, none of the DPDK libraries were given on the
> link command - just the extra -ldl etc. args.
> Adding "link_with: dpdk_libraries" fixed this and allowed it work for me,
> but I'm surpised that it proved necessary. Stephen, does it work for you
> with just the dependencies provided?
>
> /Bruce
>
> PS: My testing was done with meson 0.56.2 on Ubuntu 21.10.
I was testing with a cross-build with an app that uses quite limited
dependencies, and it worked. Also, the app has same depedencies for some
of the parts that are missed.
Will try l3fwd and something more complex for next version
^ permalink raw reply [flat|nested] 13+ messages in thread
* [dpdk-dev] [PATCH v2] build: add definitions for use as meson subproject
2021-11-03 22:12 [dpdk-dev] [RFC] build: allow build DPDK as a meson submodule Stephen Hemminger
2021-11-04 8:59 ` Bruce Richardson
2021-11-05 0:01 ` [dpdk-dev] [PATCH] " Stephen Hemminger
@ 2021-11-05 17:22 ` Stephen Hemminger
2021-11-05 18:11 ` Bruce Richardson
2022-05-06 14:06 ` Bruce Richardson
2022-05-06 14:43 ` [PATCH v3] " Bruce Richardson
3 siblings, 2 replies; 13+ messages in thread
From: Stephen Hemminger @ 2021-11-05 17:22 UTC (permalink / raw)
To: Bruce Richardson; +Cc: dev, Stephen Hemminger
Some other projects using meson may not be able to use DPDK
using the standard distribution pkg-config mechanism.
Meson supports a way to handle this via the subproject
https://mesonbuild.com/Subprojects.html
This patch adds the necessary dependency to follow the
"Naming convention for dependency variables" from the documentation.
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
v2 - add link libraries
lib/meson.build | 5 +++++
meson.build | 13 +++++++++++++
2 files changed, 18 insertions(+)
diff --git a/lib/meson.build b/lib/meson.build
index 499d26060fdd..e6df538bd6ef 100644
--- a/lib/meson.build
+++ b/lib/meson.build
@@ -241,6 +241,11 @@ foreach l:libraries
dpdk_libraries = [shared_lib] + dpdk_libraries
dpdk_static_libraries = [static_lib] + dpdk_static_libraries
+ if get_option('default_library') == 'static'
+ dpdk_libs_deps += static_dep
+ else
+ dpdk_libs_deps += shared_dep
+ endif
set_variable('shared_rte_' + name, shared_dep)
set_variable('static_rte_' + name, static_dep)
diff --git a/meson.build b/meson.build
index 12cb6e0e83f3..3bf6bb794ce1 100644
--- a/meson.build
+++ b/meson.build
@@ -36,6 +36,7 @@ dpdk_drivers = []
dpdk_extra_ldflags = []
dpdk_libs_disabled = []
dpdk_drvs_disabled = []
+dpdk_libs_deps = []
abi_version_file = files('ABI_VERSION')
if host_machine.cpu_family().startswith('x86')
@@ -97,6 +98,18 @@ configure_file(output: build_cfg,
# build pkg-config files for dpdk
subdir('buildtools/pkg-config')
+# If DPDK is being built as subproject then define
+# variable with the dependency convention
+if meson.is_subproject()
+ libdpdk_dep = declare_dependency(
+ version: meson.project_version(),
+ compile_args : pkg_extra_cflags,
+ dependencies: dpdk_libs_deps,
+ link_args: dpdk_extra_ldflags,
+ link_with: dpdk_libraries
+ )
+endif
+
# final output, list all the libs and drivers to be built
# this does not affect any part of the build, for information only.
output_message = '\n=================\nLibraries Enabled\n=================\n'
--
2.30.2
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [dpdk-dev] [PATCH v2] build: add definitions for use as meson subproject
2021-11-05 17:22 ` [dpdk-dev] [PATCH v2] build: add definitions for use as meson subproject Stephen Hemminger
@ 2021-11-05 18:11 ` Bruce Richardson
2022-02-02 20:59 ` Thomas Monjalon
2022-05-06 14:06 ` Bruce Richardson
1 sibling, 1 reply; 13+ messages in thread
From: Bruce Richardson @ 2021-11-05 18:11 UTC (permalink / raw)
To: Stephen Hemminger; +Cc: dev
On Fri, Nov 05, 2021 at 10:22:13AM -0700, Stephen Hemminger wrote:
> Some other projects using meson may not be able to use DPDK
> using the standard distribution pkg-config mechanism.
> Meson supports a way to handle this via the subproject
> https://mesonbuild.com/Subprojects.html
>
> This patch adds the necessary dependency to follow the
> "Naming convention for dependency variables" from the documentation.
>
> Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
One comment inline below. Otherwise:
Acked-by: Bruce Richardson <bruce.richardson@intel.com>
> ---
>
> v2 - add link libraries
>
> lib/meson.build | 5 +++++
> meson.build | 13 +++++++++++++
> 2 files changed, 18 insertions(+)
>
> diff --git a/lib/meson.build b/lib/meson.build
> index 499d26060fdd..e6df538bd6ef 100644
> --- a/lib/meson.build
> +++ b/lib/meson.build
> @@ -241,6 +241,11 @@ foreach l:libraries
>
> dpdk_libraries = [shared_lib] + dpdk_libraries
> dpdk_static_libraries = [static_lib] + dpdk_static_libraries
> + if get_option('default_library') == 'static'
> + dpdk_libs_deps += static_dep
> + else
> + dpdk_libs_deps += shared_dep
> + endif
>
> set_variable('shared_rte_' + name, shared_dep)
> set_variable('static_rte_' + name, static_dep)
> diff --git a/meson.build b/meson.build
> index 12cb6e0e83f3..3bf6bb794ce1 100644
> --- a/meson.build
> +++ b/meson.build
> @@ -36,6 +36,7 @@ dpdk_drivers = []
> dpdk_extra_ldflags = []
> dpdk_libs_disabled = []
> dpdk_drvs_disabled = []
> +dpdk_libs_deps = []
> abi_version_file = files('ABI_VERSION')
>
> if host_machine.cpu_family().startswith('x86')
> @@ -97,6 +98,18 @@ configure_file(output: build_cfg,
> # build pkg-config files for dpdk
> subdir('buildtools/pkg-config')
>
> +# If DPDK is being built as subproject then define
> +# variable with the dependency convention
> +if meson.is_subproject()
> + libdpdk_dep = declare_dependency(
> + version: meson.project_version(),
> + compile_args : pkg_extra_cflags,
> + dependencies: dpdk_libs_deps,
> + link_args: dpdk_extra_ldflags,
> + link_with: dpdk_libraries
Minor nit, but the dpdk_libraries is always the shared libs, it's
dpdk_static_libraries in the static case. Since elsewhere you switched on
the "default_library" value, maybe you should do so here.
Personally, I'd tend more towards having two new vars, "dpdk_libs_deps" and
"dpdk_static_libs_deps", and then define two global dependency objects:
"libdpdk_dep" and "libdpdk_static_dep", to make it easy for subprojects to
pull in the one they want.
> + )
> +endif
> +
> # final output, list all the libs and drivers to be built
> # this does not affect any part of the build, for information only.
> output_message = '\n=================\nLibraries Enabled\n=================\n'
> --
> 2.30.2
>
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [dpdk-dev] [PATCH v2] build: add definitions for use as meson subproject
2021-11-05 18:11 ` Bruce Richardson
@ 2022-02-02 20:59 ` Thomas Monjalon
0 siblings, 0 replies; 13+ messages in thread
From: Thomas Monjalon @ 2022-02-02 20:59 UTC (permalink / raw)
To: Stephen Hemminger; +Cc: dev, Bruce Richardson, david.marchand
05/11/2021 19:11, Bruce Richardson:
> On Fri, Nov 05, 2021 at 10:22:13AM -0700, Stephen Hemminger wrote:
> > +# If DPDK is being built as subproject then define
> > +# variable with the dependency convention
> > +if meson.is_subproject()
> > + libdpdk_dep = declare_dependency(
> > + version: meson.project_version(),
> > + compile_args : pkg_extra_cflags,
> > + dependencies: dpdk_libs_deps,
> > + link_args: dpdk_extra_ldflags,
> > + link_with: dpdk_libraries
>
> Minor nit, but the dpdk_libraries is always the shared libs, it's
> dpdk_static_libraries in the static case. Since elsewhere you switched on
> the "default_library" value, maybe you should do so here.
>
> Personally, I'd tend more towards having two new vars, "dpdk_libs_deps" and
> "dpdk_static_libs_deps", and then define two global dependency objects:
> "libdpdk_dep" and "libdpdk_static_dep", to make it easy for subprojects to
> pull in the one they want.
I don't want to merge this patch without having an answer to this comment.
Stephen, what do you think?
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH v2] build: add definitions for use as meson subproject
2021-11-05 17:22 ` [dpdk-dev] [PATCH v2] build: add definitions for use as meson subproject Stephen Hemminger
2021-11-05 18:11 ` Bruce Richardson
@ 2022-05-06 14:06 ` Bruce Richardson
1 sibling, 0 replies; 13+ messages in thread
From: Bruce Richardson @ 2022-05-06 14:06 UTC (permalink / raw)
To: Stephen Hemminger; +Cc: dev
On Fri, Nov 05, 2021 at 10:22:13AM -0700, Stephen Hemminger wrote:
> Some other projects using meson may not be able to use DPDK
> using the standard distribution pkg-config mechanism.
> Meson supports a way to handle this via the subproject
> https://mesonbuild.com/Subprojects.html
>
> This patch adds the necessary dependency to follow the
> "Naming convention for dependency variables" from the documentation.
>
> Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
> ---
>
> v2 - add link libraries
>
Playing around with DPDK as a meson subproject myself, I have some
additional thoughts on how to put this in DPDK and some further comments on
this patch. For example:
* For static builds we need to "link_whole" the drivers, as well as doing a
"link_with" on the libraries
* for shared builds - which will need to be done explicitly by passing the
subproject the default_library type parameter we actually don't need to
include the "link_with" line since the libs are already included in the
shared deps. [I think they should be added to the static deps too, if
that doesn't cause any problems]
* we therefore likely need slightly different subproject definitions for
shared vs static, and I'd suggest moving that to a new file e.g. in
"buildtools/subproject" - to avoid cluttering the main file too much.
If you don't mind, I'll do a re-spin of this functionality in a
V3 patch, based on above ideas, and we can see where we go there.
/Bruce
^ permalink raw reply [flat|nested] 13+ messages in thread
* [PATCH v3] build: add definitions for use as meson subproject
2021-11-03 22:12 [dpdk-dev] [RFC] build: allow build DPDK as a meson submodule Stephen Hemminger
` (2 preceding siblings ...)
2021-11-05 17:22 ` [dpdk-dev] [PATCH v2] build: add definitions for use as meson subproject Stephen Hemminger
@ 2022-05-06 14:43 ` Bruce Richardson
2022-05-21 0:54 ` Ben Magistro
3 siblings, 1 reply; 13+ messages in thread
From: Bruce Richardson @ 2022-05-06 14:43 UTC (permalink / raw)
To: dev; +Cc: Bruce Richardson, Stephen Hemminger
To allow other projects to easily use DPDK as a subproject, add in the
necessary dependency definitions. Slightly different definitions are
necessary for static and shared builds, since for shared builds the
drivers should not be linked in, and the internal meson dependency
objects are more complete.
To use DPDK as a subproject fallback i.e. use installed DPDK if present,
otherwise the shipped one, the following meson statement can be used:
libdpdk = dependency('libdpdk', fallback: ['dpdk', 'dpdk_dep'])
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
---
buildtools/subproject/meson.build | 21 +++++++++++++++++++++
drivers/meson.build | 4 ++++
lib/meson.build | 2 ++
meson.build | 6 ++++++
4 files changed, 33 insertions(+)
create mode 100644 buildtools/subproject/meson.build
diff --git a/buildtools/subproject/meson.build b/buildtools/subproject/meson.build
new file mode 100644
index 0000000000..3192efaa40
--- /dev/null
+++ b/buildtools/subproject/meson.build
@@ -0,0 +1,21 @@
+# SPDX-License-Identifier: BSD-3-Clause
+# Copyright(c) 2022 Intel Corporation
+
+message('DPDK subproject linking: ' + get_option('default_library'))
+if get_option('default_library') == 'static'
+ dpdk_dep = declare_dependency(
+ version: meson.project_version(),
+ dependencies: dpdk_static_lib_deps,
+ # static library deps in DPDK build don't include "link_with" parameters,
+ # so explicitly link-in both libs and drivers
+ link_with: dpdk_static_libraries,
+ link_whole: dpdk_drivers,
+ link_args: dpdk_extra_ldflags)
+else
+ dpdk_dep = declare_dependency(
+ version: meson.project_version(),
+ # shared library deps include all necessary linking parameters
+ dependencies: dpdk_shared_lib_deps)
+endif
+
+libdpdk_dep = dpdk_dep
diff --git a/drivers/meson.build b/drivers/meson.build
index 1d8123b00c..db4d9c73bd 100644
--- a/drivers/meson.build
+++ b/drivers/meson.build
@@ -245,6 +245,10 @@ foreach subpath:subdirs
set_variable('shared_@0@'.format(lib_name), shared_dep)
set_variable('static_@0@'.format(lib_name), static_dep)
+ # for drivers, we only need to add dependency objects for static libs,
+ # shared lib drivers are not linked in
+ dpdk_static_lib_deps += static_dep
+
dependency_name = ''.join(lib_name.split('rte_'))
if developer_mode
message('drivers/@0@: Defining dependency "@1@"'.format(
diff --git a/lib/meson.build b/lib/meson.build
index 24adbe44c9..c648f7d800 100644
--- a/lib/meson.build
+++ b/lib/meson.build
@@ -266,6 +266,8 @@ foreach l:libraries
set_variable('shared_rte_' + name, shared_dep)
set_variable('static_rte_' + name, static_dep)
+ dpdk_shared_lib_deps += shared_dep
+ dpdk_static_lib_deps += static_dep
if developer_mode
message('lib/@0@: Defining dependency "@1@"'.format(l, name))
endif
diff --git a/meson.build b/meson.build
index 937f6110c0..6085e32a79 100644
--- a/meson.build
+++ b/meson.build
@@ -36,6 +36,8 @@ dpdk_build_root = meson.current_build_dir()
dpdk_conf = configuration_data()
dpdk_libraries = []
dpdk_static_libraries = []
+dpdk_shared_lib_deps = []
+dpdk_static_lib_deps = []
dpdk_chkinc_headers = []
dpdk_driver_classes = []
dpdk_drivers = []
@@ -103,6 +105,10 @@ configure_file(output: build_cfg,
# build pkg-config files for dpdk
subdir('buildtools/pkg-config')
+if meson.is_subproject()
+ subdir('buildtools/subproject')
+endif
+
# final output, list all the libs and drivers to be built
# this does not affect any part of the build, for information only.
output_message = '\n=================\nLibraries Enabled\n=================\n'
--
2.34.1
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH v3] build: add definitions for use as meson subproject
2022-05-06 14:43 ` [PATCH v3] " Bruce Richardson
@ 2022-05-21 0:54 ` Ben Magistro
2022-06-07 16:05 ` Thomas Monjalon
0 siblings, 1 reply; 13+ messages in thread
From: Ben Magistro @ 2022-05-21 0:54 UTC (permalink / raw)
To: Bruce Richardson; +Cc: dev, Stephen Hemminger
[-- Attachment #1: Type: text/plain, Size: 4435 bytes --]
Currently utilizing this in an upcoming set of changes for TLDK and all
seems to be working for fallback dependency support under both shared and
static linkage.
Reviewed-by: Ben Magistro <koncept1@gmail.com>
Tested-by: Ben Magistro <koncept1@gmail.com>
On Fri, May 6, 2022 at 10:43 AM Bruce Richardson <bruce.richardson@intel.com>
wrote:
> To allow other projects to easily use DPDK as a subproject, add in the
> necessary dependency definitions. Slightly different definitions are
> necessary for static and shared builds, since for shared builds the
> drivers should not be linked in, and the internal meson dependency
> objects are more complete.
>
> To use DPDK as a subproject fallback i.e. use installed DPDK if present,
> otherwise the shipped one, the following meson statement can be used:
>
> libdpdk = dependency('libdpdk', fallback: ['dpdk', 'dpdk_dep'])
>
> Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
> Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
> ---
> buildtools/subproject/meson.build | 21 +++++++++++++++++++++
> drivers/meson.build | 4 ++++
> lib/meson.build | 2 ++
> meson.build | 6 ++++++
> 4 files changed, 33 insertions(+)
> create mode 100644 buildtools/subproject/meson.build
>
> diff --git a/buildtools/subproject/meson.build
> b/buildtools/subproject/meson.build
> new file mode 100644
> index 0000000000..3192efaa40
> --- /dev/null
> +++ b/buildtools/subproject/meson.build
> @@ -0,0 +1,21 @@
> +# SPDX-License-Identifier: BSD-3-Clause
> +# Copyright(c) 2022 Intel Corporation
> +
> +message('DPDK subproject linking: ' + get_option('default_library'))
> +if get_option('default_library') == 'static'
> + dpdk_dep = declare_dependency(
> + version: meson.project_version(),
> + dependencies: dpdk_static_lib_deps,
> + # static library deps in DPDK build don't include "link_with"
> parameters,
> + # so explicitly link-in both libs and drivers
> + link_with: dpdk_static_libraries,
> + link_whole: dpdk_drivers,
> + link_args: dpdk_extra_ldflags)
> +else
> + dpdk_dep = declare_dependency(
> + version: meson.project_version(),
> + # shared library deps include all necessary linking parameters
> + dependencies: dpdk_shared_lib_deps)
> +endif
> +
> +libdpdk_dep = dpdk_dep
> diff --git a/drivers/meson.build b/drivers/meson.build
> index 1d8123b00c..db4d9c73bd 100644
> --- a/drivers/meson.build
> +++ b/drivers/meson.build
> @@ -245,6 +245,10 @@ foreach subpath:subdirs
>
> set_variable('shared_@0@'.format(lib_name), shared_dep)
> set_variable('static_@0@'.format(lib_name), static_dep)
> + # for drivers, we only need to add dependency objects for static
> libs,
> + # shared lib drivers are not linked in
> + dpdk_static_lib_deps += static_dep
> +
> dependency_name = ''.join(lib_name.split('rte_'))
> if developer_mode
> message('drivers/@0@: Defining dependency "@1@"'.format(
> diff --git a/lib/meson.build b/lib/meson.build
> index 24adbe44c9..c648f7d800 100644
> --- a/lib/meson.build
> +++ b/lib/meson.build
> @@ -266,6 +266,8 @@ foreach l:libraries
>
> set_variable('shared_rte_' + name, shared_dep)
> set_variable('static_rte_' + name, static_dep)
> + dpdk_shared_lib_deps += shared_dep
> + dpdk_static_lib_deps += static_dep
> if developer_mode
> message('lib/@0@: Defining dependency "@1@"'.format(l, name))
> endif
> diff --git a/meson.build b/meson.build
> index 937f6110c0..6085e32a79 100644
> --- a/meson.build
> +++ b/meson.build
> @@ -36,6 +36,8 @@ dpdk_build_root = meson.current_build_dir()
> dpdk_conf = configuration_data()
> dpdk_libraries = []
> dpdk_static_libraries = []
> +dpdk_shared_lib_deps = []
> +dpdk_static_lib_deps = []
> dpdk_chkinc_headers = []
> dpdk_driver_classes = []
> dpdk_drivers = []
> @@ -103,6 +105,10 @@ configure_file(output: build_cfg,
> # build pkg-config files for dpdk
> subdir('buildtools/pkg-config')
>
> +if meson.is_subproject()
> + subdir('buildtools/subproject')
> +endif
> +
> # final output, list all the libs and drivers to be built
> # this does not affect any part of the build, for information only.
> output_message = '\n=================\nLibraries
> Enabled\n=================\n'
> --
> 2.34.1
>
>
[-- Attachment #2: Type: text/html, Size: 5649 bytes --]
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH v3] build: add definitions for use as meson subproject
2022-05-21 0:54 ` Ben Magistro
@ 2022-06-07 16:05 ` Thomas Monjalon
0 siblings, 0 replies; 13+ messages in thread
From: Thomas Monjalon @ 2022-06-07 16:05 UTC (permalink / raw)
To: Bruce Richardson; +Cc: dev, Stephen Hemminger, Ben Magistro
21/05/2022 02:54, Ben Magistro:
> Currently utilizing this in an upcoming set of changes for TLDK and all
> seems to be working for fallback dependency support under both shared and
> static linkage.
>
> Reviewed-by: Ben Magistro <koncept1@gmail.com>
> Tested-by: Ben Magistro <koncept1@gmail.com>
>
> On Fri, May 6, 2022 at 10:43 AM Bruce Richardson <bruce.richardson@intel.com>
> wrote:
>
> > To allow other projects to easily use DPDK as a subproject, add in the
> > necessary dependency definitions. Slightly different definitions are
> > necessary for static and shared builds, since for shared builds the
> > drivers should not be linked in, and the internal meson dependency
> > objects are more complete.
> >
> > To use DPDK as a subproject fallback i.e. use installed DPDK if present,
> > otherwise the shipped one, the following meson statement can be used:
> >
> > libdpdk = dependency('libdpdk', fallback: ['dpdk', 'dpdk_dep'])
> >
> > Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
> > Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
Applied, thanks.
^ permalink raw reply [flat|nested] 13+ messages in thread