[gimp/wip/sgrinkov/6257-meson-race-rc-win-build: 10/10] build, meson: Fix rc files build order dependency...




commit 5c41385f08c39d040d5155ffe47cfab12643f859
Author: Stanislav Grinkov <43956-stanislavgrinkov users noreply gitlab gnome org>
Date:   Wed Sep 29 00:30:25 2021 +0600

    build, meson: Fix rc files build order dependency...
    
    by adding special custom_target() build rules.
    
    Basically, these build rules do nothing (a mere meson --version call),
    but they ensure that `git-version.h` is built first before the dependant
    rc files are used in respective resource compiler build targets.
    
    This still (sort of) a nasty trick but it do the job.
    
    See #6257 for additional information.

 build/windows/meson.build | 41 +++++++++++++++++++++++++++++++++++++++--
 1 file changed, 39 insertions(+), 2 deletions(-)
---
diff --git a/build/windows/meson.build b/build/windows/meson.build
index 28362f6e10..bc4aa0a314 100644
--- a/build/windows/meson.build
+++ b/build/windows/meson.build
@@ -1,13 +1,50 @@
 # Windows specific
 
-gimp_plugins_rc = configure_file(
+configure_file(
   input : 'gimp-plug-ins.rc.in',
   output: 'gimp-plug-ins.rc',
   configuration: versionconfig,
 )
 
-gimp_app_rc = configure_file(
+configure_file(
   input : 'gimp.rc.in',
   output: 'gimp.rc',
   configuration: versionconfig,
 )
+
+# Targets below define build-time dependency on `git-version.h`
+# for `gimp-plug-ins.rc` and `gimp.rc` to force meson to build
+# `git-version.h` before (indirect) dependants.
+#
+# Nasty trick indeed, but it fixes the race condition issue
+# described in gnome#6257.
+#
+# Otherwise, on Windows resource compiler (often) tries to compile
+# RC resource before `git-version.h` is built and errors out.
+
+# Alternative solutions:
+# - Patch 35+ RC configuration rules to add an explicit dependency (error prone and)
+# - Generate *.rc files using custom_target which will do search/replace as configure_file()
+#   but when build is actually run (not when it is configured)
+
+# What this command do is irrelevant as long as it:
+# - exist on all build systems by default (*nix, win, os, tarball)
+# - executes without errors
+# - safe, keep build tree files intact, and doesn't change anything in the system
+meson_command = find_program('meson')
+
+gimp_plugins_rc = custom_target('git-version.h build-time-dependency for gimp_plugins_rc',
+  build_by_default: true,
+  build_always_stale: true,
+  command: [meson_command, '--version'],
+  depends: [gitversion_h],
+  output:  ['gimp-plug-ins.rc']
+).full_path()
+
+gimp_app_rc = custom_target('git-version.h build-time-dependency for gimp.rc',
+  build_by_default: true,
+  build_always_stale: true,
+  command: [meson_command, '--version'],
+  depends: [gitversion_h],
+  output:  ['gimp.rc']
+).full_path()


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]