[04/10] py: libcamera: Move function declarations to common header
diff mbox series

Message ID 20240624192941.22943-5-laurent.pinchart@ideasonboard.com
State Accepted
Headers show
Series
  • libcamera: Enable -Wmissing-declarations
Related show

Commit Message

Laurent Pinchart June 24, 2024, 7:29 p.m. UTC
The init_py_*() functions are called by the top-level entry point of the
libcamera Python module to initialize different parts of the bindings.
They are declared in py_main.cpp where they are called, and defined in
separate compilation units. This results in functions being defined
without a corresponding declaration, and will generate warnings when we
enable -Wmissing-declarations.

Fix this by moving the function declarations from py_main.c to
py_main.h, and including py_main.h in the various compilation units that
need it.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
---
 src/py/libcamera/py_color_space.cpp             |  2 ++
 src/py/libcamera/py_controls_generated.cpp.in   |  2 ++
 src/py/libcamera/py_enums.cpp                   |  2 ++
 src/py/libcamera/py_formats_generated.cpp.in    |  2 ++
 src/py/libcamera/py_geometry.cpp                |  2 ++
 src/py/libcamera/py_main.cpp                    |  8 --------
 src/py/libcamera/py_main.h                      | 10 ++++++++++
 src/py/libcamera/py_properties_generated.cpp.in |  2 ++
 src/py/libcamera/py_transform.cpp               |  2 ++
 9 files changed, 24 insertions(+), 8 deletions(-)

Comments

Kieran Bingham June 25, 2024, 8:32 a.m. UTC | #1
Quoting Laurent Pinchart (2024-06-24 20:29:35)
> The init_py_*() functions are called by the top-level entry point of the
> libcamera Python module to initialize different parts of the bindings.
> They are declared in py_main.cpp where they are called, and defined in
> separate compilation units. This results in functions being defined
> without a corresponding declaration, and will generate warnings when we
> enable -Wmissing-declarations.
> 
> Fix this by moving the function declarations from py_main.c to
> py_main.h, and including py_main.h in the various compilation units that
> need it.
> 

Looks easy enough...

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

> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> ---
>  src/py/libcamera/py_color_space.cpp             |  2 ++
>  src/py/libcamera/py_controls_generated.cpp.in   |  2 ++
>  src/py/libcamera/py_enums.cpp                   |  2 ++
>  src/py/libcamera/py_formats_generated.cpp.in    |  2 ++
>  src/py/libcamera/py_geometry.cpp                |  2 ++
>  src/py/libcamera/py_main.cpp                    |  8 --------
>  src/py/libcamera/py_main.h                      | 10 ++++++++++
>  src/py/libcamera/py_properties_generated.cpp.in |  2 ++
>  src/py/libcamera/py_transform.cpp               |  2 ++
>  9 files changed, 24 insertions(+), 8 deletions(-)
> 
> diff --git a/src/py/libcamera/py_color_space.cpp b/src/py/libcamera/py_color_space.cpp
> index 5201121a79ca..fd5a5dabe597 100644
> --- a/src/py/libcamera/py_color_space.cpp
> +++ b/src/py/libcamera/py_color_space.cpp
> @@ -12,6 +12,8 @@
>  #include <pybind11/pybind11.h>
>  #include <pybind11/stl.h>
>  
> +#include "py_main.h"
> +
>  namespace py = pybind11;
>  
>  using namespace libcamera;
> diff --git a/src/py/libcamera/py_controls_generated.cpp.in b/src/py/libcamera/py_controls_generated.cpp.in
> index 8d282ce51856..26d5a104f209 100644
> --- a/src/py/libcamera/py_controls_generated.cpp.in
> +++ b/src/py/libcamera/py_controls_generated.cpp.in
> @@ -11,6 +11,8 @@
>  
>  #include <pybind11/pybind11.h>
>  
> +#include "py_main.h"
> +
>  namespace py = pybind11;
>  
>  class PyControls
> diff --git a/src/py/libcamera/py_enums.cpp b/src/py/libcamera/py_enums.cpp
> index e25689c674ef..ca6aeb868cbe 100644
> --- a/src/py/libcamera/py_enums.cpp
> +++ b/src/py/libcamera/py_enums.cpp
> @@ -9,6 +9,8 @@
>  
>  #include <pybind11/pybind11.h>
>  
> +#include "py_main.h"
> +
>  namespace py = pybind11;
>  
>  using namespace libcamera;
> diff --git a/src/py/libcamera/py_formats_generated.cpp.in b/src/py/libcamera/py_formats_generated.cpp.in
> index a3f7f94d525d..c5fb9063992c 100644
> --- a/src/py/libcamera/py_formats_generated.cpp.in
> +++ b/src/py/libcamera/py_formats_generated.cpp.in
> @@ -11,6 +11,8 @@
>  
>  #include <pybind11/pybind11.h>
>  
> +#include "py_main.h"
> +
>  namespace py = pybind11;
>  
>  class PyFormats
> diff --git a/src/py/libcamera/py_geometry.cpp b/src/py/libcamera/py_geometry.cpp
> index 5c2aeac483db..c7e303609427 100644
> --- a/src/py/libcamera/py_geometry.cpp
> +++ b/src/py/libcamera/py_geometry.cpp
> @@ -14,6 +14,8 @@
>  #include <pybind11/pybind11.h>
>  #include <pybind11/stl.h>
>  
> +#include "py_main.h"
> +
>  namespace py = pybind11;
>  
>  using namespace libcamera;
> diff --git a/src/py/libcamera/py_main.cpp b/src/py/libcamera/py_main.cpp
> index bce082186a8b..ab33f38a8fb7 100644
> --- a/src/py/libcamera/py_main.cpp
> +++ b/src/py/libcamera/py_main.cpp
> @@ -85,14 +85,6 @@ PYBIND11_DECLARE_HOLDER_TYPE(T, PyCameraSmartPtr<T>)
>   */
>  static std::weak_ptr<PyCameraManager> gCameraManager;
>  
> -void init_py_color_space(py::module &m);
> -void init_py_controls_generated(py::module &m);
> -void init_py_enums(py::module &m);
> -void init_py_formats_generated(py::module &m);
> -void init_py_geometry(py::module &m);
> -void init_py_properties_generated(py::module &m);
> -void init_py_transform(py::module &m);
> -
>  PYBIND11_MODULE(_libcamera, m)
>  {
>         init_py_enums(m);
> diff --git a/src/py/libcamera/py_main.h b/src/py/libcamera/py_main.h
> index 5bb5f2d1b303..4d594326e212 100644
> --- a/src/py/libcamera/py_main.h
> +++ b/src/py/libcamera/py_main.h
> @@ -7,8 +7,18 @@
>  
>  #include <libcamera/base/log.h>
>  
> +#include <pybind11/pybind11.h>
> +
>  namespace libcamera {
>  
>  LOG_DECLARE_CATEGORY(Python)
>  
>  }
> +
> +void init_py_color_space(pybind11::module &m);
> +void init_py_controls_generated(pybind11::module &m);
> +void init_py_enums(pybind11::module &m);
> +void init_py_formats_generated(pybind11::module &m);
> +void init_py_geometry(pybind11::module &m);
> +void init_py_properties_generated(pybind11::module &m);
> +void init_py_transform(pybind11::module &m);
> diff --git a/src/py/libcamera/py_properties_generated.cpp.in b/src/py/libcamera/py_properties_generated.cpp.in
> index e3802b81a075..d28f1ab8b61a 100644
> --- a/src/py/libcamera/py_properties_generated.cpp.in
> +++ b/src/py/libcamera/py_properties_generated.cpp.in
> @@ -11,6 +11,8 @@
>  
>  #include <pybind11/pybind11.h>
>  
> +#include "py_main.h"
> +
>  namespace py = pybind11;
>  
>  class PyProperties
> diff --git a/src/py/libcamera/py_transform.cpp b/src/py/libcamera/py_transform.cpp
> index f3a0bfaf4fc5..768260ffccf0 100644
> --- a/src/py/libcamera/py_transform.cpp
> +++ b/src/py/libcamera/py_transform.cpp
> @@ -12,6 +12,8 @@
>  #include <pybind11/pybind11.h>
>  #include <pybind11/stl.h>
>  
> +#include "py_main.h"
> +
>  namespace py = pybind11;
>  
>  using namespace libcamera;
> -- 
> Regards,
> 
> Laurent Pinchart
>

Patch
diff mbox series

diff --git a/src/py/libcamera/py_color_space.cpp b/src/py/libcamera/py_color_space.cpp
index 5201121a79ca..fd5a5dabe597 100644
--- a/src/py/libcamera/py_color_space.cpp
+++ b/src/py/libcamera/py_color_space.cpp
@@ -12,6 +12,8 @@ 
 #include <pybind11/pybind11.h>
 #include <pybind11/stl.h>
 
+#include "py_main.h"
+
 namespace py = pybind11;
 
 using namespace libcamera;
diff --git a/src/py/libcamera/py_controls_generated.cpp.in b/src/py/libcamera/py_controls_generated.cpp.in
index 8d282ce51856..26d5a104f209 100644
--- a/src/py/libcamera/py_controls_generated.cpp.in
+++ b/src/py/libcamera/py_controls_generated.cpp.in
@@ -11,6 +11,8 @@ 
 
 #include <pybind11/pybind11.h>
 
+#include "py_main.h"
+
 namespace py = pybind11;
 
 class PyControls
diff --git a/src/py/libcamera/py_enums.cpp b/src/py/libcamera/py_enums.cpp
index e25689c674ef..ca6aeb868cbe 100644
--- a/src/py/libcamera/py_enums.cpp
+++ b/src/py/libcamera/py_enums.cpp
@@ -9,6 +9,8 @@ 
 
 #include <pybind11/pybind11.h>
 
+#include "py_main.h"
+
 namespace py = pybind11;
 
 using namespace libcamera;
diff --git a/src/py/libcamera/py_formats_generated.cpp.in b/src/py/libcamera/py_formats_generated.cpp.in
index a3f7f94d525d..c5fb9063992c 100644
--- a/src/py/libcamera/py_formats_generated.cpp.in
+++ b/src/py/libcamera/py_formats_generated.cpp.in
@@ -11,6 +11,8 @@ 
 
 #include <pybind11/pybind11.h>
 
+#include "py_main.h"
+
 namespace py = pybind11;
 
 class PyFormats
diff --git a/src/py/libcamera/py_geometry.cpp b/src/py/libcamera/py_geometry.cpp
index 5c2aeac483db..c7e303609427 100644
--- a/src/py/libcamera/py_geometry.cpp
+++ b/src/py/libcamera/py_geometry.cpp
@@ -14,6 +14,8 @@ 
 #include <pybind11/pybind11.h>
 #include <pybind11/stl.h>
 
+#include "py_main.h"
+
 namespace py = pybind11;
 
 using namespace libcamera;
diff --git a/src/py/libcamera/py_main.cpp b/src/py/libcamera/py_main.cpp
index bce082186a8b..ab33f38a8fb7 100644
--- a/src/py/libcamera/py_main.cpp
+++ b/src/py/libcamera/py_main.cpp
@@ -85,14 +85,6 @@  PYBIND11_DECLARE_HOLDER_TYPE(T, PyCameraSmartPtr<T>)
  */
 static std::weak_ptr<PyCameraManager> gCameraManager;
 
-void init_py_color_space(py::module &m);
-void init_py_controls_generated(py::module &m);
-void init_py_enums(py::module &m);
-void init_py_formats_generated(py::module &m);
-void init_py_geometry(py::module &m);
-void init_py_properties_generated(py::module &m);
-void init_py_transform(py::module &m);
-
 PYBIND11_MODULE(_libcamera, m)
 {
 	init_py_enums(m);
diff --git a/src/py/libcamera/py_main.h b/src/py/libcamera/py_main.h
index 5bb5f2d1b303..4d594326e212 100644
--- a/src/py/libcamera/py_main.h
+++ b/src/py/libcamera/py_main.h
@@ -7,8 +7,18 @@ 
 
 #include <libcamera/base/log.h>
 
+#include <pybind11/pybind11.h>
+
 namespace libcamera {
 
 LOG_DECLARE_CATEGORY(Python)
 
 }
+
+void init_py_color_space(pybind11::module &m);
+void init_py_controls_generated(pybind11::module &m);
+void init_py_enums(pybind11::module &m);
+void init_py_formats_generated(pybind11::module &m);
+void init_py_geometry(pybind11::module &m);
+void init_py_properties_generated(pybind11::module &m);
+void init_py_transform(pybind11::module &m);
diff --git a/src/py/libcamera/py_properties_generated.cpp.in b/src/py/libcamera/py_properties_generated.cpp.in
index e3802b81a075..d28f1ab8b61a 100644
--- a/src/py/libcamera/py_properties_generated.cpp.in
+++ b/src/py/libcamera/py_properties_generated.cpp.in
@@ -11,6 +11,8 @@ 
 
 #include <pybind11/pybind11.h>
 
+#include "py_main.h"
+
 namespace py = pybind11;
 
 class PyProperties
diff --git a/src/py/libcamera/py_transform.cpp b/src/py/libcamera/py_transform.cpp
index f3a0bfaf4fc5..768260ffccf0 100644
--- a/src/py/libcamera/py_transform.cpp
+++ b/src/py/libcamera/py_transform.cpp
@@ -12,6 +12,8 @@ 
 #include <pybind11/pybind11.h>
 #include <pybind11/stl.h>
 
+#include "py_main.h"
+
 namespace py = pybind11;
 
 using namespace libcamera;