[libcamera-devel,07/11] Makes libdl optional when the runtime includes a dynamic loader.
diff mbox series

Message ID 20221024055543.116040-8-nicholas@rothemail.net
State Superseded
Headers show
Series
  • [libcamera-devel,01/11] Fixes Bug 156, which breaks libcamera on Android < 12.
Related show

Commit Message

Nicolas Dufresne via libcamera-devel Oct. 24, 2022, 5:55 a.m. UTC
From: Nicholas Roth <nicholas@rothemail.net>

---
 src/libcamera/meson.build | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

Comments

Laurent Pinchart Oct. 24, 2022, 11:42 p.m. UTC | #1
Hi Nicholas,

Thank you for the patch.

On Mon, Oct 24, 2022 at 12:55:39AM -0500, Nicholas Roth via libcamera-devel wrote:
> From: Nicholas Roth <nicholas@rothemail.net>
> 
> ---
>  src/libcamera/meson.build | 7 ++++++-
>  1 file changed, 6 insertions(+), 1 deletion(-)
> 
> diff --git a/src/libcamera/meson.build b/src/libcamera/meson.build
> index 5f39d2e2..0494e808 100644
> --- a/src/libcamera/meson.build
> +++ b/src/libcamera/meson.build
> @@ -65,7 +65,12 @@ subdir('ipa')
>  subdir('pipeline')
>  subdir('proxy')
>  
> -libdl = cc.find_library('dl')
> +null_dep = dependency('', required : false)
> +
> +libdl = null_dep
> +if not cc.has_function('dlopen')
> +    libdl = cc.find_library('dl')
> +endif

I would have written that

if not cc.has_function('dlopen')
    libdl = cc.find_library('dl')
else
    libdl = null_dep
endif

but it's a matter of personal preference I suppose, I'm fine either way.

It would be nice to use dependency('dl') instead, but that has been
added in meson 0.62.0, and upgrading the minimum meson version would be
inconvenient as 0.62.0 isn't shipped by the latest Debian stable. Let's
capture that in a comment to simplify the code when we'll update the
requirement:

# TODO: Use dependency('dl') when updating to meson 0.62.0.
libdl = null_dep
if not cc.has_function('dlopen')
    libdl = cc.find_library('dl')
endif

Apart from that, this looks good.

>  libudev = dependency('libudev', required : false)
>  libyaml = dependency('yaml-0.1', required : false)
>

Patch
diff mbox series

diff --git a/src/libcamera/meson.build b/src/libcamera/meson.build
index 5f39d2e2..0494e808 100644
--- a/src/libcamera/meson.build
+++ b/src/libcamera/meson.build
@@ -65,7 +65,12 @@  subdir('ipa')
 subdir('pipeline')
 subdir('proxy')
 
-libdl = cc.find_library('dl')
+null_dep = dependency('', required : false)
+
+libdl = null_dep
+if not cc.has_function('dlopen')
+    libdl = cc.find_library('dl')
+endif
 libudev = dependency('libudev', required : false)
 libyaml = dependency('yaml-0.1', required : false)