From 46a11a07a202f5f8544c40b25c55eb65cac75360 Mon Sep 17 00:00:00 2001
From: Simon McVittie <smcv@collabora.com>
Date: Mon, 9 Nov 2020 15:43:54 +0000
Subject: [PATCH] build: Generate a dependency for libs-r-t's generated headers

There's currently only one generated header, enums.h, but we could add
more in future.

We need to make sure the test_utils static library depends on that
generated header, otherwise it could be compiled before the header itself
is generated, leading to intermittent and unreproducible build failures
(for some reason scout i386 seems especially prone to this).

Signed-off-by: Simon McVittie <smcv@collabora.com>
---
 steam-runtime-tools/meson.build | 10 ++++++++--
 tests/meson.build               |  1 +
 2 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/steam-runtime-tools/meson.build b/steam-runtime-tools/meson.build
index 2d69c4042..964a56fce 100644
--- a/steam-runtime-tools/meson.build
+++ b/steam-runtime-tools/meson.build
@@ -82,6 +82,10 @@ install_headers(
   subdir : join_paths('steam-runtime-tools-' + api_major, 'steam-runtime-tools'),
 )
 
+libsteamrt_generated_headers_dep = declare_dependency(
+  include_directories : project_include_dirs,
+  sources : [enums[1]],
+)
 libsteamrt_static = static_library(
   'steam-runtime-tools-internal',
   libsteamrt_sources + libsteamrt_public_headers + enums,
@@ -101,6 +105,7 @@ libsteamrt_static = static_library(
     gobject,
     libglnx_dep,
     json_glib,
+    libsteamrt_generated_headers_dep,
   ],
   install : false,
 )
@@ -115,6 +120,7 @@ libsteamrt = library(
     gobject,
     libglnx_dep,
     json_glib,
+    libsteamrt_generated_headers_dep,
   ],
   objects : [libsteamrt_static.extract_all_objects()],
   soversion : abi_major,
@@ -130,14 +136,14 @@ pkg.generate(
   version : meson.project_version(),
 )
 libsteamrt_dep = declare_dependency(
+  dependencies : libsteamrt_generated_headers_dep,
   include_directories : project_include_dirs,
   link_with : libsteamrt,
-  sources : libsteamrt_public_headers + [enums[1]],
 )
 libsteamrt_static_dep = declare_dependency(
+  dependencies : libsteamrt_generated_headers_dep,
   include_directories : project_include_dirs,
   link_with : libsteamrt_static,
-  sources : libsteamrt_public_headers + [enums[1]],
 )
 
 if get_option('introspection')
diff --git a/tests/meson.build b/tests/meson.build
index 423556865..84e241530 100644
--- a/tests/meson.build
+++ b/tests/meson.build
@@ -57,6 +57,7 @@ test_utils = static_library(
     gio_unix,
     json_glib,
     libglnx_dep,
+    libsteamrt_generated_headers_dep,
   ],
   include_directories : project_include_dirs,
   install: false,
-- 
GitLab