[libcamera-devel] meson: Replace hack with usage of '@BASENAME@'
diff mbox series

Message ID 20231207214337.16199-1-laurent.pinchart@ideasonboard.com
State Accepted
Commit 41d6e6e5c166c267e7a15a7b0c1d930bddcbc6b8
Headers show
Series
  • [libcamera-devel] meson: Replace hack with usage of '@BASENAME@'
Related show

Commit Message

Laurent Pinchart Dec. 7, 2023, 9:43 p.m. UTC
Starting with meson 0.59, the custom_target() function substitutes
'@BASENAME@' in the output parameter with the input file name, with the
extension removed. This is exactly what we implement manually when
generating the IPA interface .cpp files.

Furthermore, starting with meson 0.60, the 'name' positional parameter
to the custom_target() function is optional, and defaults to the
basename of the output file (including the extension). This is exactly
the name we compute manually and pass to the function.

As libcamera requires meson 0.60 or newer, we can depend on those two
features and drop manual computation of the base name. This fixes a
warning with recent meson versions that complain that passing a file
object to the format() function is a broken feature:

WARNING: Broken features used:
 * 1.3.0: {'str.format: Value other than strings, integers, bools, options, dictionaries and lists thereof.'}

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
---
 src/libcamera/ipa/meson.build | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)


base-commit: 1c56d2a2cd2dcca86272675e21bbb1770d32db1f

Comments

Kieran Bingham Dec. 7, 2023, 10:13 p.m. UTC | #1
Quoting Laurent Pinchart via libcamera-devel (2023-12-07 21:43:37)
> Starting with meson 0.59, the custom_target() function substitutes
> '@BASENAME@' in the output parameter with the input file name, with the
> extension removed. This is exactly what we implement manually when
> generating the IPA interface .cpp files.

It's a good job you were sitting down when you discovered that one ;-)

> Furthermore, starting with meson 0.60, the 'name' positional parameter
> to the custom_target() function is optional, and defaults to the
> basename of the output file (including the extension). This is exactly
> the name we compute manually and pass to the function.
> 
> As libcamera requires meson 0.60 or newer, we can depend on those two
> features and drop manual computation of the base name. This fixes a
> warning with recent meson versions that complain that passing a file
> object to the format() function is a broken feature:
> 
> WARNING: Broken features used:
>  * 1.3.0: {'str.format: Value other than strings, integers, bools, options, dictionaries and lists thereof.'}
> 
> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>

It's a nice bit of magic.

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

> ---
>  src/libcamera/ipa/meson.build | 7 ++-----
>  1 file changed, 2 insertions(+), 5 deletions(-)
> 
> diff --git a/src/libcamera/ipa/meson.build b/src/libcamera/ipa/meson.build
> index 4469524060de..ef73b3f98816 100644
> --- a/src/libcamera/ipa/meson.build
> +++ b/src/libcamera/ipa/meson.build
> @@ -3,13 +3,10 @@
>  libcamera_ipa_interfaces = []
>  
>  foreach file : ipa_mojom_files
> -    name = '@0@'.format(file).split('/')[-1].split('.')[0]
> -
>      # {pipeline}_ipa_interface.cpp
>      libcamera_ipa_interfaces += \
> -        custom_target(name + '_ipa_interface_cpp',
> -                      input : file,
> -                      output : name + '_ipa_interface.cpp',
> +        custom_target(input : file,
> +                      output : '@BASENAME@_ipa_interface.cpp',
>                        command : [
>                            mojom_docs_extractor,
>                            '-o', '@OUTPUT@', '@INPUT@'
> 
> base-commit: 1c56d2a2cd2dcca86272675e21bbb1770d32db1f
> -- 
> Regards,
> 
> Laurent Pinchart
>

Patch
diff mbox series

diff --git a/src/libcamera/ipa/meson.build b/src/libcamera/ipa/meson.build
index 4469524060de..ef73b3f98816 100644
--- a/src/libcamera/ipa/meson.build
+++ b/src/libcamera/ipa/meson.build
@@ -3,13 +3,10 @@ 
 libcamera_ipa_interfaces = []
 
 foreach file : ipa_mojom_files
-    name = '@0@'.format(file).split('/')[-1].split('.')[0]
-
     # {pipeline}_ipa_interface.cpp
     libcamera_ipa_interfaces += \
-        custom_target(name + '_ipa_interface_cpp',
-                      input : file,
-                      output : name + '_ipa_interface.cpp',
+        custom_target(input : file,
+                      output : '@BASENAME@_ipa_interface.cpp',
                       command : [
                           mojom_docs_extractor,
                           '-o', '@OUTPUT@', '@INPUT@'