[v1,1/3] meson: add a meson option to install examples

Message ID 20240806134218.3619913-2-g.singh@nxp.com (mailing list archive)
State New
Delegated to: Thomas Monjalon
Headers
Series meson options related changes |

Checks

Context Check Description
ci/checkpatch success coding style OK

Commit Message

Gagandeep Singh Aug. 6, 2024, 1:42 p.m. UTC
Adding a meson option "enable_examples_bin_install"
to install the examples binaries in bin.

Default value is false.

Signed-off-by: Gagandeep Singh <g.singh@nxp.com>
---
 examples/meson.build | 13 ++++++++++++-
 meson_options.txt    |  2 ++
 2 files changed, 14 insertions(+), 1 deletion(-)
  

Comments

Bruce Richardson Aug. 6, 2024, 1:58 p.m. UTC | #1
On Tue, Aug 06, 2024 at 07:12:16PM +0530, Gagandeep Singh wrote:
> Adding a meson option "enable_examples_bin_install"
> to install the examples binaries in bin.
> 
> Default value is false.
> 
> Signed-off-by: Gagandeep Singh <g.singh@nxp.com>
> ---
>  examples/meson.build | 13 ++++++++++++-
>  meson_options.txt    |  2 ++
>  2 files changed, 14 insertions(+), 1 deletion(-)
> 
Is there a particular reason we might want to do this? Installing sample
code binaries in bin seems rather strange to me.

/Bruce
  
Gagandeep Singh Aug. 7, 2024, 4:09 a.m. UTC | #2
Hi,

> -----Original Message-----
> From: Bruce Richardson <bruce.richardson@intel.com>
> Sent: Tuesday, August 6, 2024 7:28 PM
> To: Gagandeep Singh <G.Singh@nxp.com>
> Cc: dev@dpdk.org
> Subject: Re: [v1 1/3] meson: add a meson option to install examples
> 
> On Tue, Aug 06, 2024 at 07:12:16PM +0530, Gagandeep Singh wrote:
> > Adding a meson option "enable_examples_bin_install"
> > to install the examples binaries in bin.
> >
> > Default value is false.
> >
> > Signed-off-by: Gagandeep Singh <g.singh@nxp.com>
> > ---
> >  examples/meson.build | 13 ++++++++++++-
> >  meson_options.txt    |  2 ++
> >  2 files changed, 14 insertions(+), 1 deletion(-)
> >
> Is there a particular reason we might want to do this? Installing sample code
> binaries in bin seems rather strange to me.
> 
Currently, I can see only app binaries are getting installed in bin but not examples binaries. I am not able to
find the particular reason behind this.
The main reason to have the examples in installation directory is to provides a convenient
way for users to explore DPDK's examples without having to manually scan each example build directory and copy them in
their package.
The default behavior remains unchanged.

> /Bruce
  
Thomas Monjalon Oct. 17, 2024, 3:46 p.m. UTC | #3
07/08/2024 06:09, Gagandeep Singh:
> From: Bruce Richardson <bruce.richardson@intel.com>
> > On Tue, Aug 06, 2024 at 07:12:16PM +0530, Gagandeep Singh wrote:
> > > Adding a meson option "enable_examples_bin_install"
> > > to install the examples binaries in bin.
> > >
> > > Default value is false.
> > >
> > > Signed-off-by: Gagandeep Singh <g.singh@nxp.com>
> > > ---
> > >  examples/meson.build | 13 ++++++++++++-
> > >  meson_options.txt    |  2 ++
> > >  2 files changed, 14 insertions(+), 1 deletion(-)
> > >
> > Is there a particular reason we might want to do this? Installing sample code
> > binaries in bin seems rather strange to me.
> > 
> Currently, I can see only app binaries are getting installed in bin but not examples binaries. I am not able to
> find the particular reason behind this.
> The main reason to have the examples in installation directory is to provides a convenient
> way for users to explore DPDK's examples without having to manually scan each example build directory and copy them in
> their package.
> The default behavior remains unchanged.

It does not make sense to me.
Examples must be seen as a doc.
We are compiling them mostly to check there is no error.
Running an example should be educational only, no need to install it somewhere else.

I'm afraid this patch is deviating from the intent behind examples.
  

Patch

diff --git a/examples/meson.build b/examples/meson.build
index 8e8968a1fa..0d0df4e36d 100644
--- a/examples/meson.build
+++ b/examples/meson.build
@@ -124,10 +124,21 @@  foreach example: examples
     if allow_experimental_apis
         cflags += '-DALLOW_EXPERIMENTAL_API'
     endif
-    executable('dpdk-' + name, sources,
+    if get_option('enable_examples_bin_install')
+      executable('dpdk-' + name, sources,
+            include_directories: includes,
+            link_whole: link_whole_libs,
+            link_args: ldflags,
+            c_args: cflags,
+            dependencies: dep_objs,
+	    install_rpath: join_paths(get_option('prefix'), driver_install_path),
+	    install: true)
+    else
+      executable('dpdk-' + name, sources,
             include_directories: includes,
             link_whole: link_whole_libs,
             link_args: ldflags,
             c_args: cflags,
             dependencies: dep_objs)
+    endif
 endforeach
diff --git a/meson_options.txt b/meson_options.txt
index e49b2fc089..e6f83f3f92 100644
--- a/meson_options.txt
+++ b/meson_options.txt
@@ -24,6 +24,8 @@  option('enable_drivers', type: 'string', value: '', description:
        'Comma-separated list of drivers to build. If unspecified, build all drivers.')
 option('enable_driver_sdk', type: 'boolean', value: false, description:
        'Install headers to build drivers.')
+option('enable_examples_bin_install', type: 'boolean', value: false, description:
+       'Install examples binaries')
 option('enable_kmods', type: 'boolean', value: true, description:
        '[Deprecated - will be removed in future release] build kernel modules')
 option('enable_libs', type: 'string', value: '', description: