[libcamera-devel] libcamera: Turn the android option into a feature

Message ID 20200916130612.27694-1-laurent.pinchart@ideasonboard.com
State Accepted
Commit d5ce2679c67877295ce0096afd3d24d28ad34d16
Headers show
Series
  • [libcamera-devel] libcamera: Turn the android option into a feature
Related show

Commit Message

Laurent Pinchart Sept. 16, 2020, 1:06 p.m. UTC
Allow disabling compilation of the Android HAL adaptation layer
automatically when a dependency is missing by turning the android option
into a feature. The default value is set to 'disabled' to match the
current behaviour.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
---
 meson_options.txt         |  4 ++--
 src/android/meson.build   | 19 ++++++++++++++-----
 src/libcamera/meson.build |  2 +-
 src/meson.build           |  4 +---
 4 files changed, 18 insertions(+), 11 deletions(-)

Comments

Kieran Bingham Sept. 16, 2020, 1:09 p.m. UTC | #1
Hi Laurent,

On 16/09/2020 14:06, Laurent Pinchart wrote:
> Allow disabling compilation of the Android HAL adaptation layer
> automatically when a dependency is missing by turning the android option
> into a feature. The default value is set to 'disabled' to match the
> current behaviour.
> 

Thanks, this was something that was on my radar too.

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

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

> ---
>  meson_options.txt         |  4 ++--
>  src/android/meson.build   | 19 ++++++++++++++-----
>  src/libcamera/meson.build |  2 +-
>  src/meson.build           |  4 +---
>  4 files changed, 18 insertions(+), 11 deletions(-)
> 
> diff --git a/meson_options.txt b/meson_options.txt
> index e9e815fde366..d2e07ef1450f 100644
> --- a/meson_options.txt
> +++ b/meson_options.txt
> @@ -1,8 +1,8 @@
>  # SPDX-License-Identifier: CC0-1.0
>  
>  option('android',
> -        type : 'boolean',
> -        value : false,
> +        type : 'feature',
> +        value : 'disabled',
>          description : 'Compile libcamera with Android Camera3 HAL interface')
>  
>  option('documentation',
> diff --git a/src/android/meson.build b/src/android/meson.build
> index ecb92f6e9b3a..0293c2036561 100644
> --- a/src/android/meson.build
> +++ b/src/android/meson.build
> @@ -1,5 +1,19 @@
>  # SPDX-License-Identifier: CC0-1.0
>  
> +android_deps = [
> +    dependency('libexif', required : get_option('android')),
> +    dependency('libjpeg', required : get_option('android')),
> +]
> +
> +android_enabled = true
> +
> +foreach dep : android_deps
> +    if not dep.found()
> +        android_enabled = false
> +        subdir_done()
> +    endif
> +endforeach
> +
>  android_hal_sources = files([
>      'camera3_hal.cpp',
>      'camera_hal_manager.cpp',
> @@ -14,11 +28,6 @@ android_camera_metadata_sources = files([
>      'metadata/camera_metadata.c',
>  ])
>  
> -android_deps = [
> -    dependency('libexif'),
> -    dependency('libjpeg'),
> -]
> -
>  android_camera_metadata = static_library('camera_metadata',
>                                           android_camera_metadata_sources,
>                                           include_directories : android_includes)
> diff --git a/src/libcamera/meson.build b/src/libcamera/meson.build
> index af2f3d950be6..0e6ecf5060a4 100644
> --- a/src/libcamera/meson.build
> +++ b/src/libcamera/meson.build
> @@ -121,7 +121,7 @@ libcamera_deps = [
>  
>  libcamera_link_with = []
>  
> -if get_option('android')
> +if android_enabled
>      libcamera_sources += android_hal_sources
>      includes += android_includes
>      libcamera_link_with += android_camera_metadata
> diff --git a/src/meson.build b/src/meson.build
> index d69b4c1ea978..0c5b64d68c15 100644
> --- a/src/meson.build
> +++ b/src/meson.build
> @@ -1,8 +1,6 @@
>  # SPDX-License-Identifier: CC0-1.0
>  
> -if get_option('android')
> -    subdir('android')
> -endif
> +subdir('android')
>  
>  openssl = find_program('openssl', required : true)
>  if openssl.found()
>
Laurent Pinchart Sept. 16, 2020, 1:11 p.m. UTC | #2
On Wed, Sep 16, 2020 at 02:09:53PM +0100, Kieran Bingham wrote:
> Hi Laurent,
> 
> On 16/09/2020 14:06, Laurent Pinchart wrote:
> > Allow disabling compilation of the Android HAL adaptation layer
> > automatically when a dependency is missing by turning the android option
> > into a feature. The default value is set to 'disabled' to match the
> > current behaviour.
> 
> Thanks, this was something that was on my radar too.

It was that, or updating my build scripts to selectively enable/disable
the Android HAL based on the target. I think this is better :-)

> > Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> 
> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
> 
> > ---
> >  meson_options.txt         |  4 ++--
> >  src/android/meson.build   | 19 ++++++++++++++-----
> >  src/libcamera/meson.build |  2 +-
> >  src/meson.build           |  4 +---
> >  4 files changed, 18 insertions(+), 11 deletions(-)
> > 
> > diff --git a/meson_options.txt b/meson_options.txt
> > index e9e815fde366..d2e07ef1450f 100644
> > --- a/meson_options.txt
> > +++ b/meson_options.txt
> > @@ -1,8 +1,8 @@
> >  # SPDX-License-Identifier: CC0-1.0
> >  
> >  option('android',
> > -        type : 'boolean',
> > -        value : false,
> > +        type : 'feature',
> > +        value : 'disabled',
> >          description : 'Compile libcamera with Android Camera3 HAL interface')
> >  
> >  option('documentation',
> > diff --git a/src/android/meson.build b/src/android/meson.build
> > index ecb92f6e9b3a..0293c2036561 100644
> > --- a/src/android/meson.build
> > +++ b/src/android/meson.build
> > @@ -1,5 +1,19 @@
> >  # SPDX-License-Identifier: CC0-1.0
> >  
> > +android_deps = [
> > +    dependency('libexif', required : get_option('android')),
> > +    dependency('libjpeg', required : get_option('android')),
> > +]
> > +
> > +android_enabled = true
> > +
> > +foreach dep : android_deps
> > +    if not dep.found()
> > +        android_enabled = false
> > +        subdir_done()
> > +    endif
> > +endforeach
> > +
> >  android_hal_sources = files([
> >      'camera3_hal.cpp',
> >      'camera_hal_manager.cpp',
> > @@ -14,11 +28,6 @@ android_camera_metadata_sources = files([
> >      'metadata/camera_metadata.c',
> >  ])
> >  
> > -android_deps = [
> > -    dependency('libexif'),
> > -    dependency('libjpeg'),
> > -]
> > -
> >  android_camera_metadata = static_library('camera_metadata',
> >                                           android_camera_metadata_sources,
> >                                           include_directories : android_includes)
> > diff --git a/src/libcamera/meson.build b/src/libcamera/meson.build
> > index af2f3d950be6..0e6ecf5060a4 100644
> > --- a/src/libcamera/meson.build
> > +++ b/src/libcamera/meson.build
> > @@ -121,7 +121,7 @@ libcamera_deps = [
> >  
> >  libcamera_link_with = []
> >  
> > -if get_option('android')
> > +if android_enabled
> >      libcamera_sources += android_hal_sources
> >      includes += android_includes
> >      libcamera_link_with += android_camera_metadata
> > diff --git a/src/meson.build b/src/meson.build
> > index d69b4c1ea978..0c5b64d68c15 100644
> > --- a/src/meson.build
> > +++ b/src/meson.build
> > @@ -1,8 +1,6 @@
> >  # SPDX-License-Identifier: CC0-1.0
> >  
> > -if get_option('android')
> > -    subdir('android')
> > -endif
> > +subdir('android')
> >  
> >  openssl = find_program('openssl', required : true)
> >  if openssl.found()
> > 
> 
> -- 
> Regards
> --
> Kieran
Kieran Bingham Sept. 16, 2020, 1:13 p.m. UTC | #3
On 16/09/2020 14:11, Laurent Pinchart wrote:
> On Wed, Sep 16, 2020 at 02:09:53PM +0100, Kieran Bingham wrote:
>> Hi Laurent,
>>
>> On 16/09/2020 14:06, Laurent Pinchart wrote:
>>> Allow disabling compilation of the Android HAL adaptation layer
>>> automatically when a dependency is missing by turning the android option
>>> into a feature. The default value is set to 'disabled' to match the
>>> current behaviour.
>>
>> Thanks, this was something that was on my radar too.
> 
> It was that, or updating my build scripts to selectively enable/disable
> the Android HAL based on the target. I think this is better :-)

Well ...
You could have installed libjpeg and libexif on the target hehe ;-)

Now we just need to do the same with the RPi IPA and that boost dependency!

--
Kieran


>>> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
>>
>> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
>>
>>> ---
>>>  meson_options.txt         |  4 ++--
>>>  src/android/meson.build   | 19 ++++++++++++++-----
>>>  src/libcamera/meson.build |  2 +-
>>>  src/meson.build           |  4 +---
>>>  4 files changed, 18 insertions(+), 11 deletions(-)
>>>
>>> diff --git a/meson_options.txt b/meson_options.txt
>>> index e9e815fde366..d2e07ef1450f 100644
>>> --- a/meson_options.txt
>>> +++ b/meson_options.txt
>>> @@ -1,8 +1,8 @@
>>>  # SPDX-License-Identifier: CC0-1.0
>>>  
>>>  option('android',
>>> -        type : 'boolean',
>>> -        value : false,
>>> +        type : 'feature',
>>> +        value : 'disabled',
>>>          description : 'Compile libcamera with Android Camera3 HAL interface')
>>>  
>>>  option('documentation',
>>> diff --git a/src/android/meson.build b/src/android/meson.build
>>> index ecb92f6e9b3a..0293c2036561 100644
>>> --- a/src/android/meson.build
>>> +++ b/src/android/meson.build
>>> @@ -1,5 +1,19 @@
>>>  # SPDX-License-Identifier: CC0-1.0
>>>  
>>> +android_deps = [
>>> +    dependency('libexif', required : get_option('android')),
>>> +    dependency('libjpeg', required : get_option('android')),
>>> +]
>>> +
>>> +android_enabled = true
>>> +
>>> +foreach dep : android_deps
>>> +    if not dep.found()
>>> +        android_enabled = false
>>> +        subdir_done()
>>> +    endif
>>> +endforeach
>>> +
>>>  android_hal_sources = files([
>>>      'camera3_hal.cpp',
>>>      'camera_hal_manager.cpp',
>>> @@ -14,11 +28,6 @@ android_camera_metadata_sources = files([
>>>      'metadata/camera_metadata.c',
>>>  ])
>>>  
>>> -android_deps = [
>>> -    dependency('libexif'),
>>> -    dependency('libjpeg'),
>>> -]
>>> -
>>>  android_camera_metadata = static_library('camera_metadata',
>>>                                           android_camera_metadata_sources,
>>>                                           include_directories : android_includes)
>>> diff --git a/src/libcamera/meson.build b/src/libcamera/meson.build
>>> index af2f3d950be6..0e6ecf5060a4 100644
>>> --- a/src/libcamera/meson.build
>>> +++ b/src/libcamera/meson.build
>>> @@ -121,7 +121,7 @@ libcamera_deps = [
>>>  
>>>  libcamera_link_with = []
>>>  
>>> -if get_option('android')
>>> +if android_enabled
>>>      libcamera_sources += android_hal_sources
>>>      includes += android_includes
>>>      libcamera_link_with += android_camera_metadata
>>> diff --git a/src/meson.build b/src/meson.build
>>> index d69b4c1ea978..0c5b64d68c15 100644
>>> --- a/src/meson.build
>>> +++ b/src/meson.build
>>> @@ -1,8 +1,6 @@
>>>  # SPDX-License-Identifier: CC0-1.0
>>>  
>>> -if get_option('android')
>>> -    subdir('android')
>>> -endif
>>> +subdir('android')
>>>  
>>>  openssl = find_program('openssl', required : true)
>>>  if openssl.found()
>>>
>>
>> -- 
>> Regards
>> --
>> Kieran
>
Laurent Pinchart Sept. 16, 2020, 1:14 p.m. UTC | #4
On Wed, Sep 16, 2020 at 02:13:46PM +0100, Kieran Bingham wrote:
> On 16/09/2020 14:11, Laurent Pinchart wrote:
> > On Wed, Sep 16, 2020 at 02:09:53PM +0100, Kieran Bingham wrote:
> >> Hi Laurent,
> >>
> >> On 16/09/2020 14:06, Laurent Pinchart wrote:
> >>> Allow disabling compilation of the Android HAL adaptation layer
> >>> automatically when a dependency is missing by turning the android option
> >>> into a feature. The default value is set to 'disabled' to match the
> >>> current behaviour.
> >>
> >> Thanks, this was something that was on my radar too.
> > 
> > It was that, or updating my build scripts to selectively enable/disable
> > the Android HAL based on the target. I think this is better :-)
> 
> Well ...
> You could have installed libjpeg and libexif on the target hehe ;-)
> 
> Now we just need to do the same with the RPi IPA and that boost dependency!

That's something I'd like to see being done, it may require some manual
logic though.

> >>> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> >>
> >> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
> >>
> >>> ---
> >>>  meson_options.txt         |  4 ++--
> >>>  src/android/meson.build   | 19 ++++++++++++++-----
> >>>  src/libcamera/meson.build |  2 +-
> >>>  src/meson.build           |  4 +---
> >>>  4 files changed, 18 insertions(+), 11 deletions(-)
> >>>
> >>> diff --git a/meson_options.txt b/meson_options.txt
> >>> index e9e815fde366..d2e07ef1450f 100644
> >>> --- a/meson_options.txt
> >>> +++ b/meson_options.txt
> >>> @@ -1,8 +1,8 @@
> >>>  # SPDX-License-Identifier: CC0-1.0
> >>>  
> >>>  option('android',
> >>> -        type : 'boolean',
> >>> -        value : false,
> >>> +        type : 'feature',
> >>> +        value : 'disabled',
> >>>          description : 'Compile libcamera with Android Camera3 HAL interface')
> >>>  
> >>>  option('documentation',
> >>> diff --git a/src/android/meson.build b/src/android/meson.build
> >>> index ecb92f6e9b3a..0293c2036561 100644
> >>> --- a/src/android/meson.build
> >>> +++ b/src/android/meson.build
> >>> @@ -1,5 +1,19 @@
> >>>  # SPDX-License-Identifier: CC0-1.0
> >>>  
> >>> +android_deps = [
> >>> +    dependency('libexif', required : get_option('android')),
> >>> +    dependency('libjpeg', required : get_option('android')),
> >>> +]
> >>> +
> >>> +android_enabled = true
> >>> +
> >>> +foreach dep : android_deps
> >>> +    if not dep.found()
> >>> +        android_enabled = false
> >>> +        subdir_done()
> >>> +    endif
> >>> +endforeach
> >>> +
> >>>  android_hal_sources = files([
> >>>      'camera3_hal.cpp',
> >>>      'camera_hal_manager.cpp',
> >>> @@ -14,11 +28,6 @@ android_camera_metadata_sources = files([
> >>>      'metadata/camera_metadata.c',
> >>>  ])
> >>>  
> >>> -android_deps = [
> >>> -    dependency('libexif'),
> >>> -    dependency('libjpeg'),
> >>> -]
> >>> -
> >>>  android_camera_metadata = static_library('camera_metadata',
> >>>                                           android_camera_metadata_sources,
> >>>                                           include_directories : android_includes)
> >>> diff --git a/src/libcamera/meson.build b/src/libcamera/meson.build
> >>> index af2f3d950be6..0e6ecf5060a4 100644
> >>> --- a/src/libcamera/meson.build
> >>> +++ b/src/libcamera/meson.build
> >>> @@ -121,7 +121,7 @@ libcamera_deps = [
> >>>  
> >>>  libcamera_link_with = []
> >>>  
> >>> -if get_option('android')
> >>> +if android_enabled
> >>>      libcamera_sources += android_hal_sources
> >>>      includes += android_includes
> >>>      libcamera_link_with += android_camera_metadata
> >>> diff --git a/src/meson.build b/src/meson.build
> >>> index d69b4c1ea978..0c5b64d68c15 100644
> >>> --- a/src/meson.build
> >>> +++ b/src/meson.build
> >>> @@ -1,8 +1,6 @@
> >>>  # SPDX-License-Identifier: CC0-1.0
> >>>  
> >>> -if get_option('android')
> >>> -    subdir('android')
> >>> -endif
> >>> +subdir('android')
> >>>  
> >>>  openssl = find_program('openssl', required : true)
> >>>  if openssl.found()
Niklas Söderlund Sept. 16, 2020, 2:57 p.m. UTC | #5
Hi Laurent,

Thanks for your work.

On 2020-09-16 16:06:12 +0300, Laurent Pinchart wrote:
> Allow disabling compilation of the Android HAL adaptation layer
> automatically when a dependency is missing by turning the android option
> into a feature. The default value is set to 'disabled' to match the
> current behaviour.
> 
> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>

Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>

> ---
>  meson_options.txt         |  4 ++--
>  src/android/meson.build   | 19 ++++++++++++++-----
>  src/libcamera/meson.build |  2 +-
>  src/meson.build           |  4 +---
>  4 files changed, 18 insertions(+), 11 deletions(-)
> 
> diff --git a/meson_options.txt b/meson_options.txt
> index e9e815fde366..d2e07ef1450f 100644
> --- a/meson_options.txt
> +++ b/meson_options.txt
> @@ -1,8 +1,8 @@
>  # SPDX-License-Identifier: CC0-1.0
>  
>  option('android',
> -        type : 'boolean',
> -        value : false,
> +        type : 'feature',
> +        value : 'disabled',
>          description : 'Compile libcamera with Android Camera3 HAL interface')
>  
>  option('documentation',
> diff --git a/src/android/meson.build b/src/android/meson.build
> index ecb92f6e9b3a..0293c2036561 100644
> --- a/src/android/meson.build
> +++ b/src/android/meson.build
> @@ -1,5 +1,19 @@
>  # SPDX-License-Identifier: CC0-1.0
>  
> +android_deps = [
> +    dependency('libexif', required : get_option('android')),
> +    dependency('libjpeg', required : get_option('android')),
> +]
> +
> +android_enabled = true
> +
> +foreach dep : android_deps
> +    if not dep.found()
> +        android_enabled = false
> +        subdir_done()
> +    endif
> +endforeach
> +
>  android_hal_sources = files([
>      'camera3_hal.cpp',
>      'camera_hal_manager.cpp',
> @@ -14,11 +28,6 @@ android_camera_metadata_sources = files([
>      'metadata/camera_metadata.c',
>  ])
>  
> -android_deps = [
> -    dependency('libexif'),
> -    dependency('libjpeg'),
> -]
> -
>  android_camera_metadata = static_library('camera_metadata',
>                                           android_camera_metadata_sources,
>                                           include_directories : android_includes)
> diff --git a/src/libcamera/meson.build b/src/libcamera/meson.build
> index af2f3d950be6..0e6ecf5060a4 100644
> --- a/src/libcamera/meson.build
> +++ b/src/libcamera/meson.build
> @@ -121,7 +121,7 @@ libcamera_deps = [
>  
>  libcamera_link_with = []
>  
> -if get_option('android')
> +if android_enabled
>      libcamera_sources += android_hal_sources
>      includes += android_includes
>      libcamera_link_with += android_camera_metadata
> diff --git a/src/meson.build b/src/meson.build
> index d69b4c1ea978..0c5b64d68c15 100644
> --- a/src/meson.build
> +++ b/src/meson.build
> @@ -1,8 +1,6 @@
>  # SPDX-License-Identifier: CC0-1.0
>  
> -if get_option('android')
> -    subdir('android')
> -endif
> +subdir('android')
>  
>  openssl = find_program('openssl', required : true)
>  if openssl.found()
> -- 
> Regards,
> 
> Laurent Pinchart
> 
> _______________________________________________
> libcamera-devel mailing list
> libcamera-devel@lists.libcamera.org
> https://lists.libcamera.org/listinfo/libcamera-devel

Patch

diff --git a/meson_options.txt b/meson_options.txt
index e9e815fde366..d2e07ef1450f 100644
--- a/meson_options.txt
+++ b/meson_options.txt
@@ -1,8 +1,8 @@ 
 # SPDX-License-Identifier: CC0-1.0
 
 option('android',
-        type : 'boolean',
-        value : false,
+        type : 'feature',
+        value : 'disabled',
         description : 'Compile libcamera with Android Camera3 HAL interface')
 
 option('documentation',
diff --git a/src/android/meson.build b/src/android/meson.build
index ecb92f6e9b3a..0293c2036561 100644
--- a/src/android/meson.build
+++ b/src/android/meson.build
@@ -1,5 +1,19 @@ 
 # SPDX-License-Identifier: CC0-1.0
 
+android_deps = [
+    dependency('libexif', required : get_option('android')),
+    dependency('libjpeg', required : get_option('android')),
+]
+
+android_enabled = true
+
+foreach dep : android_deps
+    if not dep.found()
+        android_enabled = false
+        subdir_done()
+    endif
+endforeach
+
 android_hal_sources = files([
     'camera3_hal.cpp',
     'camera_hal_manager.cpp',
@@ -14,11 +28,6 @@  android_camera_metadata_sources = files([
     'metadata/camera_metadata.c',
 ])
 
-android_deps = [
-    dependency('libexif'),
-    dependency('libjpeg'),
-]
-
 android_camera_metadata = static_library('camera_metadata',
                                          android_camera_metadata_sources,
                                          include_directories : android_includes)
diff --git a/src/libcamera/meson.build b/src/libcamera/meson.build
index af2f3d950be6..0e6ecf5060a4 100644
--- a/src/libcamera/meson.build
+++ b/src/libcamera/meson.build
@@ -121,7 +121,7 @@  libcamera_deps = [
 
 libcamera_link_with = []
 
-if get_option('android')
+if android_enabled
     libcamera_sources += android_hal_sources
     includes += android_includes
     libcamera_link_with += android_camera_metadata
diff --git a/src/meson.build b/src/meson.build
index d69b4c1ea978..0c5b64d68c15 100644
--- a/src/meson.build
+++ b/src/meson.build
@@ -1,8 +1,6 @@ 
 # SPDX-License-Identifier: CC0-1.0
 
-if get_option('android')
-    subdir('android')
-endif
+subdir('android')
 
 openssl = find_program('openssl', required : true)
 if openssl.found()