[gimp/wip/sgrinkov/6257-meson-race-rc-win-build] meson: Force RC file's dependency build order.




commit a21adcae476a1e4fec945f47aa1eae8210f9b75c
Author: Stanislav Grinkov <43956-stanislavgrinkov users noreply gitlab gnome org>
Date:   Mon Sep 27 19:58:53 2021 +0600

    meson: Force RC file's dependency build order.
    
    We still create RC files when we configure the build, but
    by creating 'empty' custom_target() rule which has dependency
    on git-version.h file, we force meson make proper dep chain,
    and build git-version.h file before the other files.
    
    We can't create git-version.h when we configure the build because
    it will contain stale data on incremental builds.

 build/windows/meson.build | 32 ++++++++++++++++++++++++++++++--
 meson.build               | 11 ++++++-----
 2 files changed, 36 insertions(+), 7 deletions(-)
---
diff --git a/build/windows/meson.build b/build/windows/meson.build
index 28362f6e10..1ca8e1c906 100644
--- a/build/windows/meson.build
+++ b/build/windows/meson.build
@@ -1,13 +1,41 @@
 # 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,
 )
+
+# Following rules add the build-time dependency on `git-version.h`
+# for `gimp-plug-ins.rc` and `gimp.rc` to ensure proper order of
+# creation of files.
+# Otherwise meson build on Windows experience race condition when
+# resource compiler tries to do its job before `git-version.h`
+# is built.
+
+# It's better to make one `fake` custom_target() that will ensure
+# proper order of creation of files, rather than to patch 35+ rules
+# to add an explicit dependency
+
+# actual command does not matter as long as it exists on all build systems
+gimp_plugins_rc = custom_target('git-version.h build-time-dependency for gimp_plugins_rc',
+  build_by_default: true,
+  build_always_stale: true,
+  command: ['git', '--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: ['git', '--version'],
+  depends: [gitversion_h],
+  output:  ['gimp.rc']
+).full_path()
diff --git a/meson.build b/meson.build
index 863ad521f3..179d4d9660 100644
--- a/meson.build
+++ b/meson.build
@@ -15,11 +15,6 @@ conf = configuration_data()
 
 warnings = []
 
-# git-version.h is already present and not generated if dist tarball
-is_git_repository = run_command('python3', '-c',
-  'import sys,os; sys.exit(0 if os.path.exists(".git") else 1)'
-).returncode() == 0
-
 ################################################################################
 # Project info
 
@@ -1434,9 +1429,15 @@ endif
   #####   ####  #    # #      #  ####     #       # ###### ######  ####
 
 
+# git-version.h is already present and not generated if dist tarball
+is_git_repository = run_command('python3', '-c',
+  'import sys,os; sys.exit(0 if os.path.exists(".git") else 1)'
+).returncode() == 0
+
 has_version_h = run_command('python3', '-c',
   'import sys,os; sys.exit(0 if os.path.exists("git-version.h") else 1)'
 ).returncode() == 0
+
 if is_git_repository or not has_version_h
   gitversion_h1 = vcs_tag(
     input : 'app/git-version.h.in',


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