+++ /dev/null
-#--- webkitgtk-2.38.5/Source/WebKit/PlatformGTK.cmake.orig 2022-09-14 13:58:10.556863500 +0200
-#+++ webkitgtk-2.38.5/Source/WebKit/PlatformGTK.cmake 2023-04-22 19:21:53.186764446 +0200
-#@@ -764,3 +764,6 @@ GI_INTROSPECT(WebKit2WebExtension ${WEBK
-# GI_DOCGEN(WebKit2WebExtension gtk/webkit2gtk-webextension.toml.in
-# CONTENT_TEMPLATES gtk/urlmap.js
-# )
-#+
-#+add_dependencies(gir-WebKit2 gir-JavaScriptCore)
-#+add_dependencies(gir-WebKit2WebExtension gir-JavaScriptCore)
---- webkitgtk-2.38.5/Source/cmake/FindGI.cmake.orig 2023-02-14 10:01:07.457508800 +0100
-+++ webkitgtk-2.38.5/Source/cmake/FindGI.cmake 2023-04-22 19:21:53.186764446 +0200
-@@ -265,7 +265,7 @@ function(GI_INTROSPECT namespace nsversi
- get_property(dep_gir_lib TARGET "gir-${dep}" PROPERTY GI_GIR_LIBRARY)
- if (dep_gir_path)
- list(APPEND scanner_flags "--include-uninstalled=${dep_gir_path}")
-- list(APPEND gir_deps "${dep_gir_path}")
-+ list(APPEND gir_deps "gir-${dep}")
- else ()
- message(AUTHOR_WARNING
- "Target '${dep}' listed as a dependency but it has not "
--- /dev/null
+From bbe8d64377e2ff81cfe146d961d3ce3d7005d666 Mon Sep 17 00:00:00 2001
+From: Jan Palus <jpalus@fastmail.com>
+Date: Sat, 1 Jul 2023 14:36:09 +0200
+Subject: [PATCH] Generate GIR once to fix intermittent parallel build failures
+
+typelib, doc-check and doc targets add file dependency on generated GIR
+file. As per CMake documentation that pulls commands to generate GIR
+file in every of those targets:
+
+https://cmake.org/cmake/help/latest/command/add_custom_command.html
+
+> If any dependency is an OUTPUT of another custom command in the same
+> directory (CMakeLists.txt file), CMake automatically brings the other
+> custom command into the target in which this command is built.
+
+Meaning there will be 4 different commands in total trying to create
+same file independently without any ordering enforced between them. This
+causes intermittent failures depending on timing in which those commands
+execute when invoking parallel build.
+
+To ensure that GIR is created only once and that proper ordering is in
+place replace file dependency with dependency on target creating GIR
+file.
+
+Signed-off-by: Jan Palus <jpalus@fastmail.com>
+---
+ Source/cmake/FindGI.cmake | 2 +-
+ Source/cmake/FindGIDocgen.cmake | 5 +++--
+ 2 files changed, 4 insertions(+), 3 deletions(-)
+
+diff --git a/Source/cmake/FindGI.cmake b/Source/cmake/FindGI.cmake
+index fdc56b21b148..6b636af69a28 100644
+--- a/Source/cmake/FindGI.cmake
++++ b/Source/cmake/FindGI.cmake
+@@ -376,7 +376,7 @@ function(GI_INTROSPECT namespace nsversion header)
+ add_custom_command(
+ OUTPUT "${typ_path}"
+ COMMENT "Generating ${gir_name}.typelib"
+- DEPENDS "${gir_path}"
++ DEPENDS "gir-${namespace}"
+ VERBATIM
+ COMMAND "${GI_COMPILER_EXE}"
+ "--includedir=${CMAKE_BINARY_DIR}"
+diff --git a/Source/cmake/FindGIDocgen.cmake b/Source/cmake/FindGIDocgen.cmake
+index 88c90633e63f..ef560db7a2f0 100644
+--- a/Source/cmake/FindGIDocgen.cmake
++++ b/Source/cmake/FindGIDocgen.cmake
+@@ -180,7 +180,7 @@ function(GI_DOCGEN namespace toml)
+ endif ()
+ set(outdir "${CMAKE_BINARY_DIR}/Documentation/${package}")
+
+- set(docdeps "${toml_path};${gir_path}")
++ set(docdeps "${toml_path};gir-${namespace}")
+ foreach (item IN LISTS opt_CONTENT_TEMPLATES)
+ get_filename_component(filename "${item}" NAME)
+ configure_file("${item}.in" "${contentdir}/${filename}" @ONLY)
+@@ -239,10 +239,11 @@ function(GI_DOCGEN namespace toml)
+ add_custom_target("doc-check-${namespace}"
+ COMMENT "Checking documentation: ${namespace}"
+ WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}"
+- DEPENDS "${toml_path}" "${gir_path}"
++ DEPENDS "${toml_path}"
+ VERBATIM
+ COMMAND "${GIDocgen_EXE}" check ${common_flags} "${gir_path}"
+ )
++ add_dependencies("doc-check-${namespace}" "gir-${namespace}")
+
+ if (NOT TARGET doc-check-all)
+ add_custom_target(doc-check-all COMMENT "Check all documentation targets")
+--
+2.41.0
+