[libcamera-devel,v3,7/7] libcamera: Declare dependency on generated headers

Message ID 20200307211326.26994-8-laurent.pinchart@ideasonboard.com
State Superseded
Headers show
Series
  • Fix race condition and other build issues
Related show

Commit Message

Laurent Pinchart March 7, 2020, 9:13 p.m. UTC
From: Kieran Bingham <kieran.bingham@ideasonboard.com>

The control headers are generated automatically by parsing our YAML
descriptions, and creating the control headers.

These headers are included by internal libcamera source files, but the
build system isn't informed of this dependency. This allows a race
condition to occur in builds where objects are attempted to be built
before the included headers have been generated, resulting in a build
failure or, worse, in a successful but incorrect build.

Declare a dependency on the control headers for libcamera to ensure that
they are built before compiling any object within the libcamera library.

Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
[Split the change out and reworded commit message]
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
---
 src/libcamera/meson.build | 1 +
 1 file changed, 1 insertion(+)

Comments

Kieran Bingham March 7, 2020, 10:33 p.m. UTC | #1
Hi Laurent,

On 07/03/2020 21:13, Laurent Pinchart wrote:
> From: Kieran Bingham <kieran.bingham@ideasonboard.com>
> 
> The control headers are generated automatically by parsing our YAML
> descriptions, and creating the control headers.
> 
> These headers are included by internal libcamera source files, but the
> build system isn't informed of this dependency. This allows a race
> condition to occur in builds where objects are attempted to be built
> before the included headers have been generated, resulting in a build
> failure or, worse, in a successful but incorrect build.
> 
> Declare a dependency on the control headers for libcamera to ensure that
> they are built before compiling any object within the libcamera library.
> 

Having re-tested without this, (now with the control_headers
definitively assigned to libcamera_sources), I can confirm the generated
headers are built before the libcamera pipelines again.

It may very well be the case that this patch can be dropped and perhaps
I likely (incorrectly) believed it was necessary due to (again
incorrectly) removing the headers from the libcamera_sources.

> Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
> [Split the change out and reworded commit message]
> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> ---
>  src/libcamera/meson.build | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/src/libcamera/meson.build b/src/libcamera/meson.build
> index ac6f597c6188..692ca5899f3a 100644
> --- a/src/libcamera/meson.build
> +++ b/src/libcamera/meson.build
> @@ -97,6 +97,7 @@ libcamera_deps = [
>      cc.find_library('dl'),
>      libudev,
>      dependency('threads'),
> +    declare_dependency(sources : [control_headers])
>  ]
>  
>  libcamera_link_with = []
>

Patch

diff --git a/src/libcamera/meson.build b/src/libcamera/meson.build
index ac6f597c6188..692ca5899f3a 100644
--- a/src/libcamera/meson.build
+++ b/src/libcamera/meson.build
@@ -97,6 +97,7 @@  libcamera_deps = [
     cc.find_library('dl'),
     libudev,
     dependency('threads'),
+    declare_dependency(sources : [control_headers])
 ]
 
 libcamera_link_with = []