From 52928e04a5a162f554e5a9e0b3632a96a433fb38 Mon Sep 17 00:00:00 2001 From: Jehan Date: Tue, 12 Oct 2021 16:00:33 +0200 Subject: [PATCH] Issue #7327: Cannot build GIMP3 on MSYS2 using Meson. This is untested on my side, because the bug only happens on native builds with meson (our CI has cross-builds with meson and native builds with autotools and I only do cross-builds locally) but I think/hope it will work. Basically we were using .full_path() because these rc files were also used as input of some configure_file() calls which doesn't like custom target objects as input (it wants strings or file objects). Yet a bug in meson didn't like the colon used in native Windows full paths ('C:' and such) when used in windows.compile_resources(). This has been fixed by Luca Bacci in: https://github.com/mesonbuild/meson/pull/9368 Yet we just cannot depend on very early meson (or worse dev meson code). On the other hand, if the input is a custom_tgt object, it uses the object ID which we give as first parameter of custom_target() so we know it's appropriately named without colons (such as 'gimp_plugins_rc'). Thus we should not bump into this issue again. For the few usage in configure_file(), I just add a .full_path() only when needed at call time. Last but not least, I replace the bogus `meson --version` call by a `python3 -c 'exit()'` as advised by Eli Schwartz: https://gitlab.gnome.org/GNOME/gimp/-/commit/2afa019c708869ef84a2d24c96552b380a504d4d#note_1284951 The reason is that it is apparently possible (or will be when some reimplementation of meson will be done) that the `meson` executable itself does not exist. On the other hand, `python3` should always be there, as a mandatory dependency of the build tool. In order to use an appropriate `python3`, I made the pythonmod.find_installation() check required in our build (which should not be a problem since it's a meson requirement as well), even when the -Dpython option is false (this one depends on other requirements too anyway, such as version and pygobject). This way I can call this meson variable of discovered python in my bogus call, instead of calling a (potentially different) python from PATH environment. --- app/meson.build | 4 ++-- build/windows/meson.build | 16 +++++++--------- meson.build | 6 +++--- plug-ins/common/meson.build | 2 +- plug-ins/file-raw/meson.build | 2 +- plug-ins/metadata/meson.build | 4 ++-- 6 files changed, 16 insertions(+), 18 deletions(-) diff --git a/app/meson.build b/app/meson.build index 6f615c6e7c..4bc7ea2cca 100644 --- a/app/meson.build +++ b/app/meson.build @@ -161,7 +161,7 @@ app_gui_links = [ if platform_windows console_rc_name = 'gimp-console-'+ gimp_app_version gimp_app_console_rc = configure_file( - input : gimp_plugins_rc, + input : gimp_plugins_rc.full_path(), output: console_rc_name + '.rc', copy: true, ) @@ -179,7 +179,7 @@ if platform_windows gui_rc_name = 'gimp-'+ gimp_app_version gimp_app_gui_rc = configure_file( - input : gimp_plugins_rc, + input : gimp_plugins_rc.full_path(), output: gui_rc_name + '.rc', copy: true, ) diff --git a/build/windows/meson.build b/build/windows/meson.build index 4ec187e3e5..c59fbd5581 100644 --- a/build/windows/meson.build +++ b/build/windows/meson.build @@ -12,26 +12,24 @@ configure_file( configuration: versionconfig, ) -# Basically, the build rules below do nothing (a mere `meson --version` call). +# Basically, the build rules below do nothing (a mere `python -c 'exit()'` call). # But because they depends on `git-version.h`, meson ensure that it gets built first, # Then the result of this targets is used in 35+ resource compiler build rules. # # Nasty trick indeed, but it fixes race condition issue described in GNOME/GIMP#6257. -meson_command = find_program('meson') - -gimp_plugins_rc = custom_target('git-version.h build-time-dependency for gimp_plugins_rc', +gimp_plugins_rc = custom_target('gimp_plugins_rc', build_by_default: true, build_always_stale: true, - command: [meson_command, '--version'], + command: [python, '-c', 'exit()'], depends: [gitversion_h], output: ['gimp-plug-ins.rc'] -).full_path() +) -gimp_app_rc = custom_target('git-version.h build-time-dependency for gimp.rc', +gimp_app_rc = custom_target('gimp_app_rc', build_by_default: true, build_always_stale: true, - command: [meson_command, '--version'], + command: [python, '-c', 'exit()'], depends: [gitversion_h], output: ['gimp.rc'] -).full_path() +) diff --git a/meson.build b/meson.build index 22c167a14e..d1c8ba62e4 100644 --- a/meson.build +++ b/meson.build @@ -918,12 +918,12 @@ perl = find_program('perl5', 'perl', 'perl5.005', 'perl5.004', 'perl') python3_minver = '>=3.6' +python = pythonmod.find_installation('python3') +message('Found Python @0@'.format(python.language_version())) + have_python = get_option('python') if have_python - python = pythonmod.find_installation('python3', required: false) - message('Found Python @0@'.format(python.language_version())) - python_found = ( python.found() and python.language_version().version_compare(python3_minver) diff --git a/plug-ins/common/meson.build b/plug-ins/common/meson.build index c4b3b5e209..eb0b9d7569 100644 --- a/plug-ins/common/meson.build +++ b/plug-ins/common/meson.build @@ -164,7 +164,7 @@ foreach plugin : common_plugins_list if platform_windows plugin_rc = configure_file( - input : gimp_plugins_rc, + input : gimp_plugins_rc.full_path(), output: plugin_name + '.rc', copy: true, ) diff --git a/plug-ins/file-raw/meson.build b/plug-ins/file-raw/meson.build index b16144d0a1..a573e9fb22 100644 --- a/plug-ins/file-raw/meson.build +++ b/plug-ins/file-raw/meson.build @@ -14,7 +14,7 @@ foreach plugin_name : file_raw_exes if platform_windows plugin_rc = configure_file( - input : gimp_plugins_rc, + input : gimp_plugins_rc.full_path(), output: plugin_name + '.rc', copy: true, ) diff --git a/plug-ins/metadata/meson.build b/plug-ins/metadata/meson.build index 5f2353fcf0..b4d6cbf8a5 100644 --- a/plug-ins/metadata/meson.build +++ b/plug-ins/metadata/meson.build @@ -10,7 +10,7 @@ plugin_sources = [ if platform_windows plugin_rc = configure_file( - input : gimp_plugins_rc, + input : gimp_plugins_rc.full_path(), output: plugin_name + '.rc', copy: true, ) @@ -48,7 +48,7 @@ plugin_sources = [ if platform_windows plugin_rc = configure_file( - input : gimp_plugins_rc, + input : gimp_plugins_rc.full_path(), output: plugin_name + '.rc', copy: true, )