[v2,2/3] utils: codegen: Make users depend on `controls.py` in meson
diff mbox series

Message ID 20250501095818.3996419-3-barnabas.pocze@ideasonboard.com
State New
Headers show
Series
  • libcamera: controls: String controls as `std::string_view`
Related show

Commit Message

Barnabás Pőcze May 1, 2025, 9:58 a.m. UTC
Currently, modifying `controls.py` does not make those build targets dirty
that use a script that includes it (e.g. `gen-controls.py`) because meson
has no knowledge of this dependency. Add `depend_files` to each
`custom_target()` invocation to fix this.

Ideally it would be possible to attach this dependency to `gen_controls`,
`gen_gst_controls`, etc. objects themselves, so that repetition is
avoided, but this does not seem possible at the moment.

Signed-off-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.com>
---
 include/libcamera/meson.build | 1 +
 src/gstreamer/meson.build     | 1 +
 src/libcamera/meson.build     | 1 +
 src/py/libcamera/meson.build  | 2 ++
 utils/codegen/meson.build     | 2 ++
 5 files changed, 7 insertions(+)

Comments

Kieran Bingham May 2, 2025, 10:16 a.m. UTC | #1
Quoting Barnabás Pőcze (2025-05-01 10:58:17)
> Currently, modifying `controls.py` does not make those build targets dirty
> that use a script that includes it (e.g. `gen-controls.py`) because meson
> has no knowledge of this dependency. Add `depend_files` to each
> `custom_target()` invocation to fix this.
> 
> Ideally it would be possible to attach this dependency to `gen_controls`,
> `gen_gst_controls`, etc. objects themselves, so that repetition is
> avoided, but this does not seem possible at the moment.

I'm fine with that.

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

Maybe a possible future meson extension to optimise setting extra
dependencies ;-) But that wouldn't help us 'now' anyway.


> Signed-off-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.com>
> ---
>  include/libcamera/meson.build | 1 +
>  src/gstreamer/meson.build     | 1 +
>  src/libcamera/meson.build     | 1 +
>  src/py/libcamera/meson.build  | 2 ++
>  utils/codegen/meson.build     | 2 ++
>  5 files changed, 7 insertions(+)
> 
> diff --git a/include/libcamera/meson.build b/include/libcamera/meson.build
> index 9297f3fa3..30ea76f94 100644
> --- a/include/libcamera/meson.build
> +++ b/include/libcamera/meson.build
> @@ -90,6 +90,7 @@ foreach mode, entry : controls_map
>                                       command : [gen_controls, '-o', '@OUTPUT@',
>                                                  '--mode', mode, '-t', template_file,
>                                                  '-r', ranges_file, '@INPUT@'],
> +                                     depend_files : [py_mod_controls],
>                                       env : py_build_env,
>                                       install : true,
>                                       install_dir : libcamera_headers_install_dir)
> diff --git a/src/gstreamer/meson.build b/src/gstreamer/meson.build
> index 6b7e53b55..fd83e073d 100644
> --- a/src/gstreamer/meson.build
> +++ b/src/gstreamer/meson.build
> @@ -33,6 +33,7 @@ libcamera_gst_sources += custom_target('gstlibcamera-controls.cpp',
>                                         output : 'gstlibcamera-controls.cpp',
>                                         command : [gen_gst_controls, '-o', '@OUTPUT@',
>                                                    '-t', gen_gst_controls_template, '@INPUT@'],
> +                                       depend_files : [py_mod_controls],
>                                         env : py_build_env)
>  
>  libcamera_gst_cpp_args = [
> diff --git a/src/libcamera/meson.build b/src/libcamera/meson.build
> index 800d40807..202db1efe 100644
> --- a/src/libcamera/meson.build
> +++ b/src/libcamera/meson.build
> @@ -156,6 +156,7 @@ foreach mode, inout_files : controls_mode_files
>                                       command : [gen_controls, '-o', '@OUTPUT@',
>                                                  '--mode', mode, '-t', template_file,
>                                                  '-r', ranges_file, '@INPUT@'],
> +                                     depend_files : [py_mod_controls],
>                                       env : py_build_env)
>  endforeach
>  
> diff --git a/src/py/libcamera/meson.build b/src/py/libcamera/meson.build
> index 596a203ca..456ee7932 100644
> --- a/src/py/libcamera/meson.build
> +++ b/src/py/libcamera/meson.build
> @@ -36,6 +36,7 @@ pycamera_sources += custom_target('py_gen_controls',
>                                    output : ['py_controls_generated.cpp'],
>                                    command : [gen_py_controls, '--mode', 'controls', '-o', '@OUTPUT@',
>                                               '-t', gen_py_controls_template, '@INPUT@'],
> +                                  depend_files : [py_mod_controls],
>                                    env : py_build_env)
>  
>  pycamera_sources += custom_target('py_gen_properties',
> @@ -43,6 +44,7 @@ pycamera_sources += custom_target('py_gen_properties',
>                                    output : ['py_properties_generated.cpp'],
>                                    command : [gen_py_controls, '--mode', 'properties', '-o', '@OUTPUT@',
>                                               '-t', gen_py_controls_template, '@INPUT@'],
> +                                  depend_files : [py_mod_controls],
>                                    env : py_build_env)
>  
>  # Generate formats
> diff --git a/utils/codegen/meson.build b/utils/codegen/meson.build
> index 904dd66d1..8d1c69086 100644
> --- a/utils/codegen/meson.build
> +++ b/utils/codegen/meson.build
> @@ -16,4 +16,6 @@ gen_header = files('gen-header.sh')
>  gen_ipa_pub_key = files('gen-ipa-pub-key.py')
>  gen_tracepoints = files('gen-tp-header.py')
>  
> +py_mod_controls = files('controls.py')
> +
>  subdir('ipc')
> -- 
> 2.49.0
>
Jacopo Mondi May 2, 2025, 10:18 a.m. UTC | #2
Hi Barnabás
On Fri, May 02, 2025 at 11:16:43AM +0100, Kieran Bingham wrote:
> Quoting Barnabás Pőcze (2025-05-01 10:58:17)
> > Currently, modifying `controls.py` does not make those build targets dirty
> > that use a script that includes it (e.g. `gen-controls.py`) because meson
> > has no knowledge of this dependency. Add `depend_files` to each
> > `custom_target()` invocation to fix this.
> >
> > Ideally it would be possible to attach this dependency to `gen_controls`,
> > `gen_gst_controls`, etc. objects themselves, so that repetition is
> > avoided, but this does not seem possible at the moment.
>
> I'm fine with that.
>
> Acked-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
>
> Maybe a possible future meson extension to optimise setting extra
> dependencies ;-) But that wouldn't help us 'now' anyway.
>

I trust your and Kieran's judgment here, and the fact that CI doesn't
break anymore

Acked-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>

>
> > Signed-off-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.com>
> > ---
> >  include/libcamera/meson.build | 1 +
> >  src/gstreamer/meson.build     | 1 +
> >  src/libcamera/meson.build     | 1 +
> >  src/py/libcamera/meson.build  | 2 ++
> >  utils/codegen/meson.build     | 2 ++
> >  5 files changed, 7 insertions(+)
> >
> > diff --git a/include/libcamera/meson.build b/include/libcamera/meson.build
> > index 9297f3fa3..30ea76f94 100644
> > --- a/include/libcamera/meson.build
> > +++ b/include/libcamera/meson.build
> > @@ -90,6 +90,7 @@ foreach mode, entry : controls_map
> >                                       command : [gen_controls, '-o', '@OUTPUT@',
> >                                                  '--mode', mode, '-t', template_file,
> >                                                  '-r', ranges_file, '@INPUT@'],
> > +                                     depend_files : [py_mod_controls],
> >                                       env : py_build_env,
> >                                       install : true,
> >                                       install_dir : libcamera_headers_install_dir)
> > diff --git a/src/gstreamer/meson.build b/src/gstreamer/meson.build
> > index 6b7e53b55..fd83e073d 100644
> > --- a/src/gstreamer/meson.build
> > +++ b/src/gstreamer/meson.build
> > @@ -33,6 +33,7 @@ libcamera_gst_sources += custom_target('gstlibcamera-controls.cpp',
> >                                         output : 'gstlibcamera-controls.cpp',
> >                                         command : [gen_gst_controls, '-o', '@OUTPUT@',
> >                                                    '-t', gen_gst_controls_template, '@INPUT@'],
> > +                                       depend_files : [py_mod_controls],
> >                                         env : py_build_env)
> >
> >  libcamera_gst_cpp_args = [
> > diff --git a/src/libcamera/meson.build b/src/libcamera/meson.build
> > index 800d40807..202db1efe 100644
> > --- a/src/libcamera/meson.build
> > +++ b/src/libcamera/meson.build
> > @@ -156,6 +156,7 @@ foreach mode, inout_files : controls_mode_files
> >                                       command : [gen_controls, '-o', '@OUTPUT@',
> >                                                  '--mode', mode, '-t', template_file,
> >                                                  '-r', ranges_file, '@INPUT@'],
> > +                                     depend_files : [py_mod_controls],
> >                                       env : py_build_env)
> >  endforeach
> >
> > diff --git a/src/py/libcamera/meson.build b/src/py/libcamera/meson.build
> > index 596a203ca..456ee7932 100644
> > --- a/src/py/libcamera/meson.build
> > +++ b/src/py/libcamera/meson.build
> > @@ -36,6 +36,7 @@ pycamera_sources += custom_target('py_gen_controls',
> >                                    output : ['py_controls_generated.cpp'],
> >                                    command : [gen_py_controls, '--mode', 'controls', '-o', '@OUTPUT@',
> >                                               '-t', gen_py_controls_template, '@INPUT@'],
> > +                                  depend_files : [py_mod_controls],
> >                                    env : py_build_env)
> >
> >  pycamera_sources += custom_target('py_gen_properties',
> > @@ -43,6 +44,7 @@ pycamera_sources += custom_target('py_gen_properties',
> >                                    output : ['py_properties_generated.cpp'],
> >                                    command : [gen_py_controls, '--mode', 'properties', '-o', '@OUTPUT@',
> >                                               '-t', gen_py_controls_template, '@INPUT@'],
> > +                                  depend_files : [py_mod_controls],
> >                                    env : py_build_env)
> >
> >  # Generate formats
> > diff --git a/utils/codegen/meson.build b/utils/codegen/meson.build
> > index 904dd66d1..8d1c69086 100644
> > --- a/utils/codegen/meson.build
> > +++ b/utils/codegen/meson.build
> > @@ -16,4 +16,6 @@ gen_header = files('gen-header.sh')
> >  gen_ipa_pub_key = files('gen-ipa-pub-key.py')
> >  gen_tracepoints = files('gen-tp-header.py')
> >
> > +py_mod_controls = files('controls.py')
> > +
> >  subdir('ipc')
> > --
> > 2.49.0
> >

Patch
diff mbox series

diff --git a/include/libcamera/meson.build b/include/libcamera/meson.build
index 9297f3fa3..30ea76f94 100644
--- a/include/libcamera/meson.build
+++ b/include/libcamera/meson.build
@@ -90,6 +90,7 @@  foreach mode, entry : controls_map
                                      command : [gen_controls, '-o', '@OUTPUT@',
                                                 '--mode', mode, '-t', template_file,
                                                 '-r', ranges_file, '@INPUT@'],
+                                     depend_files : [py_mod_controls],
                                      env : py_build_env,
                                      install : true,
                                      install_dir : libcamera_headers_install_dir)
diff --git a/src/gstreamer/meson.build b/src/gstreamer/meson.build
index 6b7e53b55..fd83e073d 100644
--- a/src/gstreamer/meson.build
+++ b/src/gstreamer/meson.build
@@ -33,6 +33,7 @@  libcamera_gst_sources += custom_target('gstlibcamera-controls.cpp',
                                        output : 'gstlibcamera-controls.cpp',
                                        command : [gen_gst_controls, '-o', '@OUTPUT@',
                                                   '-t', gen_gst_controls_template, '@INPUT@'],
+                                       depend_files : [py_mod_controls],
                                        env : py_build_env)
 
 libcamera_gst_cpp_args = [
diff --git a/src/libcamera/meson.build b/src/libcamera/meson.build
index 800d40807..202db1efe 100644
--- a/src/libcamera/meson.build
+++ b/src/libcamera/meson.build
@@ -156,6 +156,7 @@  foreach mode, inout_files : controls_mode_files
                                      command : [gen_controls, '-o', '@OUTPUT@',
                                                 '--mode', mode, '-t', template_file,
                                                 '-r', ranges_file, '@INPUT@'],
+                                     depend_files : [py_mod_controls],
                                      env : py_build_env)
 endforeach
 
diff --git a/src/py/libcamera/meson.build b/src/py/libcamera/meson.build
index 596a203ca..456ee7932 100644
--- a/src/py/libcamera/meson.build
+++ b/src/py/libcamera/meson.build
@@ -36,6 +36,7 @@  pycamera_sources += custom_target('py_gen_controls',
                                   output : ['py_controls_generated.cpp'],
                                   command : [gen_py_controls, '--mode', 'controls', '-o', '@OUTPUT@',
                                              '-t', gen_py_controls_template, '@INPUT@'],
+                                  depend_files : [py_mod_controls],
                                   env : py_build_env)
 
 pycamera_sources += custom_target('py_gen_properties',
@@ -43,6 +44,7 @@  pycamera_sources += custom_target('py_gen_properties',
                                   output : ['py_properties_generated.cpp'],
                                   command : [gen_py_controls, '--mode', 'properties', '-o', '@OUTPUT@',
                                              '-t', gen_py_controls_template, '@INPUT@'],
+                                  depend_files : [py_mod_controls],
                                   env : py_build_env)
 
 # Generate formats
diff --git a/utils/codegen/meson.build b/utils/codegen/meson.build
index 904dd66d1..8d1c69086 100644
--- a/utils/codegen/meson.build
+++ b/utils/codegen/meson.build
@@ -16,4 +16,6 @@  gen_header = files('gen-header.sh')
 gen_ipa_pub_key = files('gen-ipa-pub-key.py')
 gen_tracepoints = files('gen-tp-header.py')
 
+py_mod_controls = files('controls.py')
+
 subdir('ipc')