[libcamera-devel,v10,3/7] meson: add 'check: true' for run_command() calls
diff mbox series

Message ID 20220509101023.35569-4-tomi.valkeinen@ideasonboard.com
State Accepted
Headers show
Series
  • Python bindings
Related show

Commit Message

Tomi Valkeinen May 9, 2022, 10:10 a.m. UTC
Add 'check: true' to all run_command() calls as suggested in
https://github.com/mesonbuild/meson/issues/9300 to get rid of meson
warning "You should add the boolean check kwarg to the run_command
call."

This makes meson fail if the executed command fails, which makes sense.

Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
---
 meson.build | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

Comments

Kieran Bingham May 9, 2022, 8:58 p.m. UTC | #1
Quoting Tomi Valkeinen (2022-05-09 11:10:19)
> Add 'check: true' to all run_command() calls as suggested in
> https://github.com/mesonbuild/meson/issues/9300 to get rid of meson
> warning "You should add the boolean check kwarg to the run_command
> call."
> 
> This makes meson fail if the executed command fails, which makes sense.
> 
> Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>
> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> ---
>  meson.build | 8 +++++---
>  1 file changed, 5 insertions(+), 3 deletions(-)
> 
> diff --git a/meson.build b/meson.build
> index 10ad8c5c..0124e7d3 100644
> --- a/meson.build
> +++ b/meson.build
> @@ -18,7 +18,8 @@ project('libcamera', 'c', 'cpp',
>  # libcamera_git_version.
>  libcamera_git_version = run_command('utils/gen-version.sh',
>                                      meson.project_build_root(),
> -                                    meson.project_source_root()).stdout().strip()
> +                                    meson.project_source_root(),
> +                                    check: true).stdout().strip()

This breaks on CrOS. A simple fix is:

================================================================================
diff --git a/meson.build b/meson.build
index 60a911e0c05e..6d7d3ca6bca7 100644
--- a/meson.build
+++ b/meson.build
@@ -19,7 +19,7 @@ project('libcamera', 'c', 'cpp',
 libcamera_git_version = run_command('utils/gen-version.sh',
                                     meson.project_build_root(),
                                     meson.project_source_root(),
-                                    check: true).stdout().strip()
+                                    check: false).stdout().strip()
 if libcamera_git_version == ''
     libcamera_git_version = meson.project_version()
 endif
================================================================================

Which I think is reasonable as the "if libcamera_git_version = '' "
check follows immediately.

However, I can either drop this patch from integration, apply the
suggested change, or ... <insert suggestion here>




>  if libcamera_git_version == ''
>      libcamera_git_version = meson.project_version()
>  endif
> @@ -148,7 +149,7 @@ subdir('test')
>  
>  if not meson.is_cross_build()
>      kernel_version_req = '>= 5.0.0'
> -    kernel_version = run_command('uname', '-r').stdout().strip()
> +    kernel_version = run_command('uname', '-r', check: true).stdout().strip()
>      if not kernel_version.version_compare(kernel_version_req)
>          warning('The current running kernel version @0@ is too old to run libcamera.'
>                  .format(kernel_version))
> @@ -160,7 +161,8 @@ endif
>  # Create a symlink from the build root to the source root. This is used when
>  # running libcamera from the build directory to locate resources in the source
>  # directory (such as IPA configuration files).
> -run_command('ln', '-fsT', meson.project_source_root(), meson.project_build_root() / 'source')
> +run_command('ln', '-fsT', meson.project_source_root(), meson.project_build_root() / 'source',
> +            check: true)
>  
>  configure_file(output : 'config.h', configuration : config_h)
>  
> -- 
> 2.34.1
>
Laurent Pinchart May 9, 2022, 9:14 p.m. UTC | #2
Hi Kieran,

On Mon, May 09, 2022 at 09:58:56PM +0100, Kieran Bingham wrote:
> Quoting Tomi Valkeinen (2022-05-09 11:10:19)
> > Add 'check: true' to all run_command() calls as suggested in
> > https://github.com/mesonbuild/meson/issues/9300 to get rid of meson
> > warning "You should add the boolean check kwarg to the run_command
> > call."
> > 
> > This makes meson fail if the executed command fails, which makes sense.
> > 
> > Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>
> > Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
> > Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> > ---
> >  meson.build | 8 +++++---
> >  1 file changed, 5 insertions(+), 3 deletions(-)
> > 
> > diff --git a/meson.build b/meson.build
> > index 10ad8c5c..0124e7d3 100644
> > --- a/meson.build
> > +++ b/meson.build
> > @@ -18,7 +18,8 @@ project('libcamera', 'c', 'cpp',
> >  # libcamera_git_version.
> >  libcamera_git_version = run_command('utils/gen-version.sh',
> >                                      meson.project_build_root(),
> > -                                    meson.project_source_root()).stdout().strip()
> > +                                    meson.project_source_root(),
> > +                                    check: true).stdout().strip()
> 
> This breaks on CrOS. A simple fix is:
> 
> ================================================================================
> diff --git a/meson.build b/meson.build
> index 60a911e0c05e..6d7d3ca6bca7 100644
> --- a/meson.build
> +++ b/meson.build
> @@ -19,7 +19,7 @@ project('libcamera', 'c', 'cpp',
>  libcamera_git_version = run_command('utils/gen-version.sh',
>                                      meson.project_build_root(),
>                                      meson.project_source_root(),
> -                                    check: true).stdout().strip()
> +                                    check: false).stdout().strip()
>  if libcamera_git_version == ''
>      libcamera_git_version = meson.project_version()
>  endif
> ================================================================================
> 
> Which I think is reasonable as the "if libcamera_git_version = '' "
> check follows immediately.
> 
> However, I can either drop this patch from integration, apply the
> suggested change, or ... <insert suggestion here>

I think it comes from

# Bail out if the directory isn't under git control
git_dir=$(git rev-parse --git-dir 2>&1) || exit 1

so "check: false" sounds right.

> >  if libcamera_git_version == ''
> >      libcamera_git_version = meson.project_version()
> >  endif
> > @@ -148,7 +149,7 @@ subdir('test')
> >  
> >  if not meson.is_cross_build()
> >      kernel_version_req = '>= 5.0.0'
> > -    kernel_version = run_command('uname', '-r').stdout().strip()
> > +    kernel_version = run_command('uname', '-r', check: true).stdout().strip()
> >      if not kernel_version.version_compare(kernel_version_req)
> >          warning('The current running kernel version @0@ is too old to run libcamera.'
> >                  .format(kernel_version))
> > @@ -160,7 +161,8 @@ endif
> >  # Create a symlink from the build root to the source root. This is used when
> >  # running libcamera from the build directory to locate resources in the source
> >  # directory (such as IPA configuration files).
> > -run_command('ln', '-fsT', meson.project_source_root(), meson.project_build_root() / 'source')
> > +run_command('ln', '-fsT', meson.project_source_root(), meson.project_build_root() / 'source',
> > +            check: true)
> >  
> >  configure_file(output : 'config.h', configuration : config_h)
> >

Patch
diff mbox series

diff --git a/meson.build b/meson.build
index 10ad8c5c..0124e7d3 100644
--- a/meson.build
+++ b/meson.build
@@ -18,7 +18,8 @@  project('libcamera', 'c', 'cpp',
 # libcamera_git_version.
 libcamera_git_version = run_command('utils/gen-version.sh',
                                     meson.project_build_root(),
-                                    meson.project_source_root()).stdout().strip()
+                                    meson.project_source_root(),
+                                    check: true).stdout().strip()
 if libcamera_git_version == ''
     libcamera_git_version = meson.project_version()
 endif
@@ -148,7 +149,7 @@  subdir('test')
 
 if not meson.is_cross_build()
     kernel_version_req = '>= 5.0.0'
-    kernel_version = run_command('uname', '-r').stdout().strip()
+    kernel_version = run_command('uname', '-r', check: true).stdout().strip()
     if not kernel_version.version_compare(kernel_version_req)
         warning('The current running kernel version @0@ is too old to run libcamera.'
                 .format(kernel_version))
@@ -160,7 +161,8 @@  endif
 # Create a symlink from the build root to the source root. This is used when
 # running libcamera from the build directory to locate resources in the source
 # directory (such as IPA configuration files).
-run_command('ln', '-fsT', meson.project_source_root(), meson.project_build_root() / 'source')
+run_command('ln', '-fsT', meson.project_source_root(), meson.project_build_root() / 'source',
+            check: true)
 
 configure_file(output : 'config.h', configuration : config_h)