From e0766fa2051c4bcdd12a0b6a838be757018d103a Mon Sep 17 00:00:00 2001 From: Laurent Pinchart Date: Wed, 29 Dec 2021 12:07:35 +0200 Subject: meson: Compile libyaml as a subproject if not available on the system 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 Tested-by: Eric Curtin Reviewed-by: Kieran Bingham Reviewed-by: Umang Jain --- src/libcamera/meson.build | 13 ++++++++++++- subprojects/.gitignore | 1 + subprojects/libyaml.wrap | 5 +++++ 3 files changed, 18 insertions(+), 1 deletion(-) create mode 100644 subprojects/libyaml.wrap diff --git a/src/libcamera/meson.build b/src/libcamera/meson.build index 75d3a692..b57bee7e 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 0e194289..fd3f4a5b 100644 --- a/subprojects/.gitignore +++ b/subprojects/.gitignore @@ -1,4 +1,5 @@ /googletest-release* +/libyaml /libyuv /packagecache /pybind11 diff --git a/subprojects/libyaml.wrap b/subprojects/libyaml.wrap new file mode 100644 index 00000000..3d7d0a32 --- /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 -- cgit v1.2.1