[libcamera-devel] [PATCH v3 2/3] meson: Create and use a dependency for libcamera and its headers
Kieran Bingham
kieran.bingham at ideasonboard.com
Thu May 23 12:44:38 CEST 2019
Hi Laurent,
On 23/05/2019 11:40, Laurent Pinchart wrote:
> Hi Kieran,
>
> On Thu, May 23, 2019 at 11:07:22AM +0100, Kieran Bingham wrote:
>> On 22/05/2019 22:22, Laurent Pinchart wrote:
>>> Instead of manually adding the libcamera library and include path to
>>> every target that requires it, declare a dependency that groups the
>>> headers as source, the library and the include path, and use it through
>>> the project. This simplifies handling of the dependency.
>>
>> Aha, this looks interesting!
>>
>>> Signed-off-by: Laurent Pinchart <laurent.pinchart at ideasonboard.com>
>>> ---
>>> src/cam/meson.build | 5 ++---
>>> src/libcamera/meson.build | 4 ++++
>>> src/qcam/meson.build | 4 +---
>>> test/camera/meson.build | 1 +
>>> test/ipa/meson.build | 2 ++
>>> test/libtest/meson.build | 3 +--
>>> test/media_device/meson.build | 2 ++
>>> test/meson.build | 2 ++
>>> test/pipeline/ipu3/meson.build | 1 +
>>> test/v4l2_device/meson.build | 1 +
>>> test/v4l2_subdevice/meson.build | 1 +
>>> 11 files changed, 18 insertions(+), 8 deletions(-)
>>>
>>> diff --git a/src/cam/meson.build b/src/cam/meson.build
>>> index 851295091d0d..3faddc6c8d85 100644
>>> --- a/src/cam/meson.build
>>> +++ b/src/cam/meson.build
>>> @@ -6,6 +6,5 @@ cam_sources = files([
>>> ])
>>>
>>> cam = executable('cam', cam_sources,
>>> - link_with : libcamera,
>>> - install : true,
>>> - include_directories : libcamera_includes)
>>> + dependencies : libcamera_dep,
>>> + install : true)
>>> diff --git a/src/libcamera/meson.build b/src/libcamera/meson.build
>>> index 8294ed357154..0ebb25bcb821 100644
>>> --- a/src/libcamera/meson.build
>>> +++ b/src/libcamera/meson.build
>>> @@ -65,3 +65,7 @@ libcamera = shared_library('camera',
>>> install : true,
>>> include_directories : includes,
>>> dependencies : libudev)
>>> +
>>> +libcamera_dep = declare_dependency(sources : libcamera_api,
>>> + include_directories : libcamera_includes,
>>> + link_with : libcamera)
>>> diff --git a/src/qcam/meson.build b/src/qcam/meson.build
>>> index 56b57a266b29..9f1fa75f9813 100644
>>> --- a/src/qcam/meson.build
>>> +++ b/src/qcam/meson.build
>>> @@ -15,9 +15,7 @@ qt5_dep = dependency('qt5',
>>>
>>> if qt5_dep.found()
>>> qcam = executable('qcam', qcam_sources,
>>> - link_with : libcamera,
>>> install : true,
>>> - include_directories : libcamera_includes,
>>> - dependencies : qt5_dep,
>>> + dependencies : [libcamera_dep, qt5_dep],
>>> cpp_args : '-DQT_NO_KEYWORDS')
>>> endif
>>> diff --git a/test/camera/meson.build b/test/camera/meson.build
>>> index b01e7e025de1..35e97ce5de1a 100644
>>> --- a/test/camera/meson.build
>>> +++ b/test/camera/meson.build
>>> @@ -9,6 +9,7 @@ camera_tests = [
>>>
>>> foreach t : camera_tests
>>> exe = executable(t[0], [t[1], 'camera_test.cpp'],
>>> + dependencies : libcamera_dep,
>>> link_with : test_libraries,
>>> include_directories : test_includes_internal)
>>> test(t[0], exe, suite : 'camera', is_parallel : false)
>>> diff --git a/test/ipa/meson.build b/test/ipa/meson.build
>>> index 53015e38381f..ecde313c6dc5 100644
>>> --- a/test/ipa/meson.build
>>> +++ b/test/ipa/meson.build
>>> @@ -5,6 +5,7 @@ ipa_modules_sources = [
>>>
>>> foreach m : ipa_modules_sources
>>> shared_library(m, name_prefix : '',
>>> + dependencies : libcamera_dep,
>>> include_directories : test_includes_public)
>>> endforeach
>>>
>>> @@ -14,6 +15,7 @@ ipa_test = [
>>>
>>> foreach t : ipa_test
>>> exe = executable(t[0], t[1],
>>> + dependencies : libcamera_dep,
>>> link_with : test_libraries,
>>
>> Should the 'test_libraries' be moved to some sort of dependency too ?
>
> They could, yes. I think it should go on top of this series though.
>
>> Can test_libraries then depend on libcamera_dep to act in a dependency
>> chain?
>
> They can depend on them, but I'm not sure it can act as a chain. From a
> dependency point of view, yes, but from a linking point of view if dep A
> includes lib A and dep B depends on dep A, dep B will link agaisnt lib
> A, but meson may not mak an application depending on lib B link against
> lib A automatically. That's an expected behaviour I believe, and I think
> we should thus still depend on libcamera_dep explicitly here.
Ok that's fine.
>
>>> include_directories : test_includes_internal)
>>>
>>> diff --git a/test/libtest/meson.build b/test/libtest/meson.build
>>> index e0893b70c3d4..112debbce30f 100644
>>> --- a/test/libtest/meson.build
>>> +++ b/test/libtest/meson.build
>>> @@ -6,11 +6,10 @@ libtest = static_library('libtest', libtest_sources)
>>
>> What about putting a dependency on libcamera in the libtest as you did
>> below for lib_mdev_test ?
>
> Good idea, I'll do that
Ok - well with that and the above clarified,
Reviewed-by: Kieran Bingham <kieran.bingham at ideasonboard.com>
>
>>> libtest_includes = include_directories('.')
>>>
>>> -test_libraries = [libcamera, libtest]
>>> +test_libraries = [libtest]
>>>
>>> test_includes_public = [
>>> libtest_includes,
>>> - libcamera_includes,
>>> ]
>>>
>>> test_includes_internal = [
>>> diff --git a/test/media_device/meson.build b/test/media_device/meson.build
>>> index 124f454ec865..6a0e468434b5 100644
>>> --- a/test/media_device/meson.build
>>> +++ b/test/media_device/meson.build
>>> @@ -9,10 +9,12 @@ media_device_tests = [
>>> ]
>>>
>>> lib_mdev_test = static_library('lib_mdev_test', lib_mdev_test_sources,
>>> + dependencies : libcamera_dep,
>>> include_directories : test_includes_internal)
>>>
>>> foreach t : media_device_tests
>>> exe = executable(t[0], t[1],
>>> + dependencies : libcamera_dep,
>>> link_with : [test_libraries, lib_mdev_test],
>>> include_directories : test_includes_internal)
>>>
>>> diff --git a/test/meson.build b/test/meson.build
>>> index ef4136793f03..609aeab80e7d 100644
>>> --- a/test/meson.build
>>> +++ b/test/meson.build
>>> @@ -21,6 +21,7 @@ internal_tests = [
>>>
>>> foreach t : public_tests
>>> exe = executable(t[0], t[1],
>>> + dependencies : libcamera_dep,
>>> link_with : test_libraries,
>>> include_directories : test_includes_public)
>>>
>>> @@ -29,6 +30,7 @@ endforeach
>>>
>>> foreach t : internal_tests
>>> exe = executable(t[0], t[1],
>>> + dependencies : libcamera_dep,
>>> link_with : test_libraries,
>>> include_directories : test_includes_internal)
>>>
>>> diff --git a/test/pipeline/ipu3/meson.build b/test/pipeline/ipu3/meson.build
>>> index 87074588c651..d02927c9af86 100644
>>> --- a/test/pipeline/ipu3/meson.build
>>> +++ b/test/pipeline/ipu3/meson.build
>>> @@ -4,6 +4,7 @@ ipu3_test = [
>>>
>>> foreach t : ipu3_test
>>> exe = executable(t[0], t[1],
>>> + dependencies : libcamera_dep,
>>> link_with : test_libraries,
>>> include_directories : test_includes_internal)
>>>
>>> diff --git a/test/v4l2_device/meson.build b/test/v4l2_device/meson.build
>>> index 32556cf5ea18..de540b1ba6f5 100644
>>> --- a/test/v4l2_device/meson.build
>>> +++ b/test/v4l2_device/meson.build
>>> @@ -11,6 +11,7 @@ v4l2_device_tests = [
>>>
>>> foreach t : v4l2_device_tests
>>> exe = executable(t[0], [t[1], 'v4l2_device_test.cpp'],
>>> + dependencies : libcamera_dep,
>>> link_with : test_libraries,
>>> include_directories : test_includes_internal)
>>> test(t[0], exe, suite : 'v4l2_device', is_parallel : false)
>>> diff --git a/test/v4l2_subdevice/meson.build b/test/v4l2_subdevice/meson.build
>>> index 282f6e234ec1..0521984b2a78 100644
>>> --- a/test/v4l2_subdevice/meson.build
>>> +++ b/test/v4l2_subdevice/meson.build
>>> @@ -5,6 +5,7 @@ v4l2_subdevice_tests = [
>>>
>>> foreach t : v4l2_subdevice_tests
>>> exe = executable(t[0], [t[1], 'v4l2_subdevice_test.cpp'],
>>> + dependencies : libcamera_dep,
>>> link_with : test_libraries,
>>> include_directories : test_includes_internal)
>>> test(t[0], exe, suite : 'v4l2_subdevice', is_parallel : false)
>
--
Regards
--
Kieran
More information about the libcamera-devel
mailing list