[libcamera-devel,v5] meson: detect kernel version

Message ID 20200611102614.14355-1-scerveau@collabora.com
State Superseded
Headers show
Series
  • [libcamera-devel,v5] meson: detect kernel version
Related show

Commit Message

Stéphane Cerveau June 11, 2020, 10:26 a.m. UTC
Add kernel version detection to warn user
that only >= 5.0.0 V4L API are supported in
libcamera.

Signed-off-by: Stéphane Cerveau <scerveau@collabora.com>
---
 meson.build | 9 +++++++++
 1 file changed, 9 insertions(+)

Comments

Kieran Bingham June 12, 2020, 8:27 a.m. UTC | #1
Hi Stéphane

On 11/06/2020 11:26, Stéphane Cerveau wrote:
> Add kernel version detection to warn user
> that only >= 5.0.0 V4L API are supported in
> libcamera.
> 
> Signed-off-by: Stéphane Cerveau <scerveau@collabora.com>

Please carry tags you receive forwards on patches, unless they need to
be dropped perhaps due to drastic changes or re-architecture of the patch.

In this instance, you can carry my RB tag from v4 to this patch:

Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>

> ---
>  meson.build | 9 +++++++++
>  1 file changed, 9 insertions(+)
> 
> diff --git a/meson.build b/meson.build
> index e898782..69d2d63 100644
> --- a/meson.build
> +++ b/meson.build
> @@ -105,6 +105,15 @@ if get_option('test')
>      subdir('test')
>  endif
>  
> +if not meson.is_cross_build()
> +  kernel_version_req = '>= 5.0.0'
> +  kernel_version = run_command('uname', '-r').stdout()
> +  if not kernel_version.version_compare(kernel_version_req)
> +    warning('Consider upgrading your kernel, as only @0@ is supported by libcamera at runtime'
> +            .format(kernel_version_req))
> +  endif
> +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).
>
Laurent Pinchart June 12, 2020, 8:50 a.m. UTC | #2
Hi Stéphane,

Thank you for the patch.

On Thu, Jun 11, 2020 at 12:26:14PM +0200, Stéphane Cerveau wrote:
> Add kernel version detection to warn user
> that only >= 5.0.0 V4L API are supported in
> libcamera.
> 
> Signed-off-by: Stéphane Cerveau <scerveau@collabora.com>
> ---
>  meson.build | 9 +++++++++
>  1 file changed, 9 insertions(+)
> 
> diff --git a/meson.build b/meson.build
> index e898782..69d2d63 100644
> --- a/meson.build
> +++ b/meson.build
> @@ -105,6 +105,15 @@ if get_option('test')
>      subdir('test')
>  endif
>  
> +if not meson.is_cross_build()
> +  kernel_version_req = '>= 5.0.0'

We use 4 spaces indentation in meson.build files.

> +  kernel_version = run_command('uname', '-r').stdout()

You should add .strip() here to remove the trailing newline output by
uname. version_compare() will cope, but printing kernel_version (see
below) would output an extra newline in the middle.

> +  if not kernel_version.version_compare(kernel_version_req)
> +    warning('Consider upgrading your kernel, as only @0@ is supported by libcamera at runtime'
> +            .format(kernel_version_req))

Even when not cross-building, it may be possible to build libcamera on a
different machine than the target machine. How about wording the message
as follows ?

        warning('The current running kernel version @0@ is too old to run libcamera.'
                .format(kernel_version))
        warning('If you intend to use libcamera on this maching, please upgrade to kernel @0@.'
                .format(kernel_version_req))

Splitting the warning in two lines doesn't just make it more readable in
the meson.build file, but also on the output of meson.

> +  endif
> +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).

Patch

diff --git a/meson.build b/meson.build
index e898782..69d2d63 100644
--- a/meson.build
+++ b/meson.build
@@ -105,6 +105,15 @@  if get_option('test')
     subdir('test')
 endif
 
+if not meson.is_cross_build()
+  kernel_version_req = '>= 5.0.0'
+  kernel_version = run_command('uname', '-r').stdout()
+  if not kernel_version.version_compare(kernel_version_req)
+    warning('Consider upgrading your kernel, as only @0@ is supported by libcamera at runtime'
+            .format(kernel_version_req))
+  endif
+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).