[libcamera-devel] meson: Compile libyaml as a subproject if not available on the system
diff mbox series

Message ID 20220509222558.31342-1-laurent.pinchart@ideasonboard.com
State Accepted
Headers show
Series
  • [libcamera-devel] meson: Compile libyaml as a subproject if not available on the system
Related show

Commit Message

Laurent Pinchart May 9, 2022, 10:25 p.m. UTC
AOSP doesn't ship libyaml, making it more difficult to compile libcamera
for Android. Use a meson wrap to compile libyaml as a subproject if the
dependency is not found.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
---
 src/libcamera/meson.build | 13 ++++++++++++-
 subprojects/.gitignore    |  3 ++-
 subprojects/libyaml.wrap  |  5 +++++
 3 files changed, 19 insertions(+), 2 deletions(-)
 create mode 100644 subprojects/libyaml.wrap


base-commit: 6d990f102fd829feb05e37e5f242a796fcada1b5

Comments

Eric Curtin May 10, 2022, 2:03 p.m. UTC | #1
On Mon, 9 May 2022 at 23:26, Laurent Pinchart via libcamera-devel
<libcamera-devel@lists.libcamera.org> wrote:
>
> AOSP doesn't ship libyaml, making it more difficult to compile libcamera
> for Android. Use a meson wrap to compile libyaml as a subproject if the
> dependency is not found.
>
> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> ---
>  src/libcamera/meson.build | 13 ++++++++++++-
>  subprojects/.gitignore    |  3 ++-
>  subprojects/libyaml.wrap  |  5 +++++
>  3 files changed, 19 insertions(+), 2 deletions(-)
>  create mode 100644 subprojects/libyaml.wrap
>
> diff --git a/src/libcamera/meson.build b/src/libcamera/meson.build
> index f8e18e035575..d1a6c5c88159 100644
> --- a/src/libcamera/meson.build
> +++ b/src/libcamera/meson.build
> @@ -67,7 +67,7 @@ subdir('proxy')
>  libdl = cc.find_library('dl')
>  libgnutls = cc.find_library('gnutls', required : true)
>  libudev = dependency('libudev', required : false)
> -libyaml = dependency('yaml-0.1', required : true)
> +libyaml = dependency('yaml-0.1', required : false)
>
>  if libgnutls.found()
>      config_h.set('HAVE_GNUTLS', 1)
> @@ -88,6 +88,17 @@ if libudev.found()
>      ])
>  endif
>
> +# Fallback to a subproject if libyaml isn't found, as it's not packaged in AOSP.
> +if not libyaml.found()
> +    cmake = import('cmake')
> +
> +    libyaml_vars = cmake.subproject_options()
> +    libyaml_vars.add_cmake_defines({'CMAKE_POSITION_INDEPENDENT_CODE': 'ON'})
> +    libyaml_vars.append_compile_args('c', '-Wno-unused-value')
> +    libyaml_wrap = cmake.subproject('libyaml', options : libyaml_vars)
> +    libyaml = libyaml_wrap.dependency('yaml')
> +endif
> +
>  control_sources = []
>
>  foreach source : control_source_files
> diff --git a/subprojects/.gitignore b/subprojects/.gitignore
> index 391fde2ce1e0..f207720b271a 100644
> --- a/subprojects/.gitignore
> +++ b/subprojects/.gitignore
> @@ -1,3 +1,4 @@
>  /googletest-release*
> +/libyaml
>  /libyuv
> -/packagecache
> \ No newline at end of file
> +/packagecache
> diff --git a/subprojects/libyaml.wrap b/subprojects/libyaml.wrap
> new file mode 100644
> index 000000000000..3d7d0a328be4
> --- /dev/null
> +++ b/subprojects/libyaml.wrap
> @@ -0,0 +1,5 @@
> +[wrap-git]
> +directory = libyaml
> +url = https://github.com/yaml/libyaml
> +# tags/0.2.5
> +revision = 2c891fc7a770e8ba2fec34fc6b545c672beb37e6
>
> base-commit: 6d990f102fd829feb05e37e5f242a796fcada1b5
> --
> Regards,
>
> Laurent Pinchart
>

Works great!

Tested-by: Eric Curtin <ecurtin@redhat.com>

Regards,

Eric
Kieran Bingham May 10, 2022, 2:51 p.m. UTC | #2
Quoting Laurent Pinchart via libcamera-devel (2022-05-09 23:25:58)
> AOSP doesn't ship libyaml, making it more difficult to compile libcamera
> for Android. Use a meson wrap to compile libyaml as a subproject if the
> dependency is not found.
> 

I expect (once the newly introduced py path issue is resolved), this
will fix the linux-media jenkins build failure there [0] too?

[0] https://lists.libcamera.org/pipermail/libcamera-devel/2022-May/030292.html

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



> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> ---
>  src/libcamera/meson.build | 13 ++++++++++++-
>  subprojects/.gitignore    |  3 ++-
>  subprojects/libyaml.wrap  |  5 +++++
>  3 files changed, 19 insertions(+), 2 deletions(-)
>  create mode 100644 subprojects/libyaml.wrap
> 
> diff --git a/src/libcamera/meson.build b/src/libcamera/meson.build
> index f8e18e035575..d1a6c5c88159 100644
> --- a/src/libcamera/meson.build
> +++ b/src/libcamera/meson.build
> @@ -67,7 +67,7 @@ subdir('proxy')
>  libdl = cc.find_library('dl')
>  libgnutls = cc.find_library('gnutls', required : true)
>  libudev = dependency('libudev', required : false)
> -libyaml = dependency('yaml-0.1', required : true)
> +libyaml = dependency('yaml-0.1', required : false)
>  
>  if libgnutls.found()
>      config_h.set('HAVE_GNUTLS', 1)
> @@ -88,6 +88,17 @@ if libudev.found()
>      ])
>  endif
>  
> +# Fallback to a subproject if libyaml isn't found, as it's not packaged in AOSP.
> +if not libyaml.found()
> +    cmake = import('cmake')
> +
> +    libyaml_vars = cmake.subproject_options()
> +    libyaml_vars.add_cmake_defines({'CMAKE_POSITION_INDEPENDENT_CODE': 'ON'})
> +    libyaml_vars.append_compile_args('c', '-Wno-unused-value')
> +    libyaml_wrap = cmake.subproject('libyaml', options : libyaml_vars)
> +    libyaml = libyaml_wrap.dependency('yaml')
> +endif
> +
>  control_sources = []
>  
>  foreach source : control_source_files
> diff --git a/subprojects/.gitignore b/subprojects/.gitignore
> index 391fde2ce1e0..f207720b271a 100644
> --- a/subprojects/.gitignore
> +++ b/subprojects/.gitignore
> @@ -1,3 +1,4 @@
>  /googletest-release*
> +/libyaml
>  /libyuv
> -/packagecache
> \ No newline at end of file
> +/packagecache
> diff --git a/subprojects/libyaml.wrap b/subprojects/libyaml.wrap
> new file mode 100644
> index 000000000000..3d7d0a328be4
> --- /dev/null
> +++ b/subprojects/libyaml.wrap
> @@ -0,0 +1,5 @@
> +[wrap-git]
> +directory = libyaml
> +url = https://github.com/yaml/libyaml
> +# tags/0.2.5
> +revision = 2c891fc7a770e8ba2fec34fc6b545c672beb37e6
> 
> base-commit: 6d990f102fd829feb05e37e5f242a796fcada1b5
> -- 
> Regards,
> 
> Laurent Pinchart
>
Laurent Pinchart May 10, 2022, 2:53 p.m. UTC | #3
On Tue, May 10, 2022 at 03:51:20PM +0100, Kieran Bingham wrote:
> Quoting Laurent Pinchart via libcamera-devel (2022-05-09 23:25:58)
> > AOSP doesn't ship libyaml, making it more difficult to compile libcamera
> > for Android. Use a meson wrap to compile libyaml as a subproject if the
> > dependency is not found.
> 
> I expect (once the newly introduced py path issue is resolved), this
> will fix the linux-media jenkins build failure there [0] too?
> 
> [0] https://lists.libcamera.org/pipermail/libcamera-devel/2022-May/030292.html

I expect it would have if Mauro hadn't installed libyaml on the builder
in the meantime :-)

> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
> 
> > Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> > ---
> >  src/libcamera/meson.build | 13 ++++++++++++-
> >  subprojects/.gitignore    |  3 ++-
> >  subprojects/libyaml.wrap  |  5 +++++
> >  3 files changed, 19 insertions(+), 2 deletions(-)
> >  create mode 100644 subprojects/libyaml.wrap
> > 
> > diff --git a/src/libcamera/meson.build b/src/libcamera/meson.build
> > index f8e18e035575..d1a6c5c88159 100644
> > --- a/src/libcamera/meson.build
> > +++ b/src/libcamera/meson.build
> > @@ -67,7 +67,7 @@ subdir('proxy')
> >  libdl = cc.find_library('dl')
> >  libgnutls = cc.find_library('gnutls', required : true)
> >  libudev = dependency('libudev', required : false)
> > -libyaml = dependency('yaml-0.1', required : true)
> > +libyaml = dependency('yaml-0.1', required : false)
> >  
> >  if libgnutls.found()
> >      config_h.set('HAVE_GNUTLS', 1)
> > @@ -88,6 +88,17 @@ if libudev.found()
> >      ])
> >  endif
> >  
> > +# Fallback to a subproject if libyaml isn't found, as it's not packaged in AOSP.
> > +if not libyaml.found()
> > +    cmake = import('cmake')
> > +
> > +    libyaml_vars = cmake.subproject_options()
> > +    libyaml_vars.add_cmake_defines({'CMAKE_POSITION_INDEPENDENT_CODE': 'ON'})
> > +    libyaml_vars.append_compile_args('c', '-Wno-unused-value')
> > +    libyaml_wrap = cmake.subproject('libyaml', options : libyaml_vars)
> > +    libyaml = libyaml_wrap.dependency('yaml')
> > +endif
> > +
> >  control_sources = []
> >  
> >  foreach source : control_source_files
> > diff --git a/subprojects/.gitignore b/subprojects/.gitignore
> > index 391fde2ce1e0..f207720b271a 100644
> > --- a/subprojects/.gitignore
> > +++ b/subprojects/.gitignore
> > @@ -1,3 +1,4 @@
> >  /googletest-release*
> > +/libyaml
> >  /libyuv
> > -/packagecache
> > \ No newline at end of file
> > +/packagecache
> > diff --git a/subprojects/libyaml.wrap b/subprojects/libyaml.wrap
> > new file mode 100644
> > index 000000000000..3d7d0a328be4
> > --- /dev/null
> > +++ b/subprojects/libyaml.wrap
> > @@ -0,0 +1,5 @@
> > +[wrap-git]
> > +directory = libyaml
> > +url = https://github.com/yaml/libyaml
> > +# tags/0.2.5
> > +revision = 2c891fc7a770e8ba2fec34fc6b545c672beb37e6
> > 
> > base-commit: 6d990f102fd829feb05e37e5f242a796fcada1b5
Umang Jain May 18, 2022, 10:48 a.m. UTC | #4
Hi Laurent,

On 5/10/22 00:25, Laurent Pinchart via libcamera-devel wrote:
> AOSP doesn't ship libyaml, making it more difficult to compile libcamera
> for Android. Use a meson wrap to compile libyaml as a subproject if the
> dependency is not found.
>
> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>


Reviewed-by: Umang Jain <umang.jain@ideasonboard.com>

> ---
>   src/libcamera/meson.build | 13 ++++++++++++-
>   subprojects/.gitignore    |  3 ++-
>   subprojects/libyaml.wrap  |  5 +++++
>   3 files changed, 19 insertions(+), 2 deletions(-)
>   create mode 100644 subprojects/libyaml.wrap
>
> diff --git a/src/libcamera/meson.build b/src/libcamera/meson.build
> index f8e18e035575..d1a6c5c88159 100644
> --- a/src/libcamera/meson.build
> +++ b/src/libcamera/meson.build
> @@ -67,7 +67,7 @@ subdir('proxy')
>   libdl = cc.find_library('dl')
>   libgnutls = cc.find_library('gnutls', required : true)
>   libudev = dependency('libudev', required : false)
> -libyaml = dependency('yaml-0.1', required : true)
> +libyaml = dependency('yaml-0.1', required : false)
>   
>   if libgnutls.found()
>       config_h.set('HAVE_GNUTLS', 1)
> @@ -88,6 +88,17 @@ if libudev.found()
>       ])
>   endif
>   
> +# Fallback to a subproject if libyaml isn't found, as it's not packaged in AOSP.
> +if not libyaml.found()
> +    cmake = import('cmake')
> +
> +    libyaml_vars = cmake.subproject_options()
> +    libyaml_vars.add_cmake_defines({'CMAKE_POSITION_INDEPENDENT_CODE': 'ON'})
> +    libyaml_vars.append_compile_args('c', '-Wno-unused-value')
> +    libyaml_wrap = cmake.subproject('libyaml', options : libyaml_vars)
> +    libyaml = libyaml_wrap.dependency('yaml')
> +endif
> +
>   control_sources = []
>   
>   foreach source : control_source_files
> diff --git a/subprojects/.gitignore b/subprojects/.gitignore
> index 391fde2ce1e0..f207720b271a 100644
> --- a/subprojects/.gitignore
> +++ b/subprojects/.gitignore
> @@ -1,3 +1,4 @@
>   /googletest-release*
> +/libyaml
>   /libyuv
> -/packagecache
> \ No newline at end of file
> +/packagecache
> diff --git a/subprojects/libyaml.wrap b/subprojects/libyaml.wrap
> new file mode 100644
> index 000000000000..3d7d0a328be4
> --- /dev/null
> +++ b/subprojects/libyaml.wrap
> @@ -0,0 +1,5 @@
> +[wrap-git]
> +directory = libyaml
> +url = https://github.com/yaml/libyaml
> +# tags/0.2.5
> +revision = 2c891fc7a770e8ba2fec34fc6b545c672beb37e6
>
> base-commit: 6d990f102fd829feb05e37e5f242a796fcada1b5

Patch
diff mbox series

diff --git a/src/libcamera/meson.build b/src/libcamera/meson.build
index f8e18e035575..d1a6c5c88159 100644
--- a/src/libcamera/meson.build
+++ b/src/libcamera/meson.build
@@ -67,7 +67,7 @@  subdir('proxy')
 libdl = cc.find_library('dl')
 libgnutls = cc.find_library('gnutls', required : true)
 libudev = dependency('libudev', required : false)
-libyaml = dependency('yaml-0.1', required : true)
+libyaml = dependency('yaml-0.1', required : false)
 
 if libgnutls.found()
     config_h.set('HAVE_GNUTLS', 1)
@@ -88,6 +88,17 @@  if libudev.found()
     ])
 endif
 
+# Fallback to a subproject if libyaml isn't found, as it's not packaged in AOSP.
+if not libyaml.found()
+    cmake = import('cmake')
+
+    libyaml_vars = cmake.subproject_options()
+    libyaml_vars.add_cmake_defines({'CMAKE_POSITION_INDEPENDENT_CODE': 'ON'})
+    libyaml_vars.append_compile_args('c', '-Wno-unused-value')
+    libyaml_wrap = cmake.subproject('libyaml', options : libyaml_vars)
+    libyaml = libyaml_wrap.dependency('yaml')
+endif
+
 control_sources = []
 
 foreach source : control_source_files
diff --git a/subprojects/.gitignore b/subprojects/.gitignore
index 391fde2ce1e0..f207720b271a 100644
--- a/subprojects/.gitignore
+++ b/subprojects/.gitignore
@@ -1,3 +1,4 @@ 
 /googletest-release*
+/libyaml
 /libyuv
-/packagecache
\ No newline at end of file
+/packagecache
diff --git a/subprojects/libyaml.wrap b/subprojects/libyaml.wrap
new file mode 100644
index 000000000000..3d7d0a328be4
--- /dev/null
+++ b/subprojects/libyaml.wrap
@@ -0,0 +1,5 @@ 
+[wrap-git]
+directory = libyaml
+url = https://github.com/yaml/libyaml
+# tags/0.2.5
+revision = 2c891fc7a770e8ba2fec34fc6b545c672beb37e6