[v1] build: make gpudev optional

Message ID 20211117203351.6087-1-eagostini@nvidia.com (mailing list archive)
State Superseded, archived
Headers
Series [v1] build: make gpudev optional |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel-compilation success Compilation OK
ci/intel-Testing success Testing PASS
ci/iol-testing warning apply patch failure
ci/github-robot: build success github build: passed

Commit Message

Elena Agostini Nov. 17, 2021, 8:33 p.m. UTC
  From: Elena Agostini <eagostini@nvidia.com>

This library can be made optional.
drivers/gpu and app/test-gpudev depend on this library,
so there is a check for dependencies.

Signed-off-by: Elena Agostini <eagostini@nvidia.com>
---
 app/test-gpudev/meson.build      | 11 +++++++++--
 doc/guides/prog_guide/gpudev.rst |  1 +
 drivers/gpu/meson.build          |  9 ++++++++-
 lib/meson.build                  |  1 +
 4 files changed, 19 insertions(+), 3 deletions(-)
  

Comments

Thomas Monjalon Nov. 17, 2021, 12:36 p.m. UTC | #1
17/11/2021 21:33, eagostini@nvidia.com:
> --- a/app/test-gpudev/meson.build
> +++ b/app/test-gpudev/meson.build
> @@ -1,5 +1,12 @@
>  # SPDX-License-Identifier: BSD-3-Clause
>  # Copyright (c) 2021 NVIDIA Corporation & Affiliates
>  
> -sources = files('main.c')
> -deps = ['gpudev', 'ethdev']
> +if dpdk_conf.has('RTE_LIB_GPUDEV')
> +    sources = files('main.c')
> +    deps = ['gpudev', 'ethdev']
> +else
> +    build = false
> +    reason = 'gpudev library is disabled'
> +    subdir_done()
> +endif

I would prefer the form "if not" so we can save the "else".

> --- a/lib/meson.build
> +++ b/lib/meson.build
> @@ -76,6 +76,7 @@ optional_libs = [
>          'pdump',
>          'power',
>          'vhost',
> +        'gpudev',
>  ]

It should be sorted alphabetically.
  
Thomas Monjalon Nov. 17, 2021, 12:56 p.m. UTC | #2
17/11/2021 13:36, Thomas Monjalon:
> 17/11/2021 21:33, eagostini@nvidia.com:
> > --- a/app/test-gpudev/meson.build
> > +++ b/app/test-gpudev/meson.build
> > @@ -1,5 +1,12 @@
> >  # SPDX-License-Identifier: BSD-3-Clause
> >  # Copyright (c) 2021 NVIDIA Corporation & Affiliates
> >  
> > -sources = files('main.c')
> > -deps = ['gpudev', 'ethdev']
> > +if dpdk_conf.has('RTE_LIB_GPUDEV')
> > +    sources = files('main.c')
> > +    deps = ['gpudev', 'ethdev']
> > +else
> > +    build = false
> > +    reason = 'gpudev library is disabled'
> > +    subdir_done()
> > +endif
> 
> I would prefer the form "if not" so we can save the "else".

Actually no need to check at all in app and driver.
If the dependency is missing the driver is disabled already
with this reason:
	reason = 'missing internal dependency, "@0@"'.format(d)
For the app, there is an automatic message:
	message('Missing dependency "@0@" for app "@1@"'.format(d, name))

> > --- a/lib/meson.build
> > +++ b/lib/meson.build
> > @@ -76,6 +76,7 @@ optional_libs = [
> >          'pdump',
> >          'power',
> >          'vhost',
> > +        'gpudev',
> >  ]
> 
> It should be sorted alphabetically.
  

Patch

diff --git a/app/test-gpudev/meson.build b/app/test-gpudev/meson.build
index 17bdef3646..7340fe29d6 100644
--- a/app/test-gpudev/meson.build
+++ b/app/test-gpudev/meson.build
@@ -1,5 +1,12 @@ 
 # SPDX-License-Identifier: BSD-3-Clause
 # Copyright (c) 2021 NVIDIA Corporation & Affiliates
 
-sources = files('main.c')
-deps = ['gpudev', 'ethdev']
+if dpdk_conf.has('RTE_LIB_GPUDEV')
+    sources = files('main.c')
+    deps = ['gpudev', 'ethdev']
+else
+    build = false
+    reason = 'gpudev library is disabled'
+    subdir_done()
+endif
+
diff --git a/doc/guides/prog_guide/gpudev.rst b/doc/guides/prog_guide/gpudev.rst
index e464109d35..8970c43865 100644
--- a/doc/guides/prog_guide/gpudev.rst
+++ b/doc/guides/prog_guide/gpudev.rst
@@ -23,6 +23,7 @@  Out of scope of this library is to provide a wrapper for GPU specific libraries
 on the device or create GPU specific objects
 (e.g. CUDA Driver context or CUDA Streams in case of NVIDIA GPUs).
 
+This library is set as optional and can be disabled with ``-Ddisable_libs=gpudev``.
 
 Features
 --------
diff --git a/drivers/gpu/meson.build b/drivers/gpu/meson.build
index 601bedcd61..f04594e712 100644
--- a/drivers/gpu/meson.build
+++ b/drivers/gpu/meson.build
@@ -1,4 +1,11 @@ 
 # SPDX-License-Identifier: BSD-3-Clause
 # Copyright (c) 2021 NVIDIA Corporation & Affiliates
 
-drivers = [ 'cuda' ]
+if dpdk_conf.has('RTE_LIB_GPUDEV')
+    drivers = [ 'cuda' ]
+else
+    build = false
+    reason = 'gpudev library is disabled'
+    subdir_done()
+endif
+
diff --git a/lib/meson.build b/lib/meson.build
index dad9fce14d..d6e7cac178 100644
--- a/lib/meson.build
+++ b/lib/meson.build
@@ -76,6 +76,7 @@  optional_libs = [
         'pdump',
         'power',
         'vhost',
+        'gpudev',
 ]
 
 disabled_libs = []