[v2] libcamera: meson: Fix libyuv detection
diff mbox series

Message ID 20250207135035.1104174-1-kieran.bingham@ideasonboard.com
State Accepted
Headers show
Series
  • [v2] libcamera: meson: Fix libyuv detection
Related show

Commit Message

Kieran Bingham Feb. 7, 2025, 1:50 p.m. UTC
From: Dylan Aïssi <dylan.aissi@collabora.com>

We already fall back to a subproject to support the libyuv package when
it can not be discovered through the usual dependency() mechanism.

Unfortunately libyuv may be packaged without any corresponding
pkg-config support as can be seen at [0], so further extend the
dependency search by using an explicit cxx.find_library() call.

[0] https://packages.debian.org/bookworm/amd64/libyuv-dev/filelist

Signed-off-by: Dylan Aïssi <dylan.aissi@collabora.com>
Tested-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>

---
v2:
Handle review/suggestion from Barnabás:
 - include yuv.h explicitly as a header check
 - support the force_fallback_for option.

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

 src/meson.build | 18 ++++++++++++++----
 1 file changed, 14 insertions(+), 4 deletions(-)

Comments

Laurent Pinchart Feb. 10, 2025, 11:47 a.m. UTC | #1
Hi Kieran,

Thank you for the patch.

On Fri, Feb 07, 2025 at 01:50:35PM +0000, Kieran Bingham wrote:
> From: Dylan Aïssi <dylan.aissi@collabora.com>
> 
> We already fall back to a subproject to support the libyuv package when
> it can not be discovered through the usual dependency() mechanism.
> 
> Unfortunately libyuv may be packaged without any corresponding
> pkg-config support as can be seen at [0], so further extend the
> dependency search by using an explicit cxx.find_library() call.
> 
> [0] https://packages.debian.org/bookworm/amd64/libyuv-dev/filelist
> 
> Signed-off-by: Dylan Aïssi <dylan.aissi@collabora.com>
> Tested-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
> Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
> 
> ---
> v2:
> Handle review/suggestion from Barnabás:
>  - include yuv.h explicitly as a header check
>  - support the force_fallback_for option.
> 
> Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
> 
>  src/meson.build | 18 ++++++++++++++----
>  1 file changed, 14 insertions(+), 4 deletions(-)
> 
> diff --git a/src/meson.build b/src/meson.build
> index 76198e9535db..b664448699aa 100644
> --- a/src/meson.build
> +++ b/src/meson.build
> @@ -27,10 +27,20 @@ else
>      ipa_sign_module = false
>  endif
>  
> -# libyuv, used by the Android adaptation layer and the virtual pipeline handler.
> -# Fallback to a subproject if libyuv isn't found, as it's typically not provided
> -# by distributions.
> -libyuv_dep = dependency('libyuv', required : false)
> +# libyuv, used by the Android adaptation layer and the virtual pipeline
> +# handler. Fallback to a subproject if libyuv isn't found, as it's typically

Nitpicking, no need to reflow the first two lines.

Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>

> +# not provided by distributions. Where libyuv is provided by a distribution, it
> +# may not always supply a pkg-config implementation, requiring cxx.find_library()
> +# to search for it.
> +if not get_option('force_fallback_for').contains('libyuv')
> +    libyuv_dep = dependency('libyuv', required : false)
> +    if not libyuv_dep.found()
> +        libyuv_dep = cxx.find_library('yuv', has_headers : 'libyuv.h',
> +                                      required : false)
> +    endif
> +else
> +    libyuv_dep = dependency('', required : false)
> +endif
>  
>  if (pipelines.contains('virtual') or get_option('android').allowed()) and \
>     not libyuv_dep.found()

Patch
diff mbox series

diff --git a/src/meson.build b/src/meson.build
index 76198e9535db..b664448699aa 100644
--- a/src/meson.build
+++ b/src/meson.build
@@ -27,10 +27,20 @@  else
     ipa_sign_module = false
 endif
 
-# libyuv, used by the Android adaptation layer and the virtual pipeline handler.
-# Fallback to a subproject if libyuv isn't found, as it's typically not provided
-# by distributions.
-libyuv_dep = dependency('libyuv', required : false)
+# libyuv, used by the Android adaptation layer and the virtual pipeline
+# handler. Fallback to a subproject if libyuv isn't found, as it's typically
+# not provided by distributions. Where libyuv is provided by a distribution, it
+# may not always supply a pkg-config implementation, requiring cxx.find_library()
+# to search for it.
+if not get_option('force_fallback_for').contains('libyuv')
+    libyuv_dep = dependency('libyuv', required : false)
+    if not libyuv_dep.found()
+        libyuv_dep = cxx.find_library('yuv', has_headers : 'libyuv.h',
+                                      required : false)
+    endif
+else
+    libyuv_dep = dependency('', required : false)
+endif
 
 if (pipelines.contains('virtual') or get_option('android').allowed()) and \
    not libyuv_dep.found()