Commit c9f92cee authored by Tim-Philipp Müller's avatar Tim-Philipp Müller 🐠 Committed by Akira TAGOH

meson: fix install failure on Windows if bindir is not in PATH

We try to run fc-cache as part of the install, which runs
the fc-cache binary in the build directory. On Windows this
might fail because nothing sets up the environment in such
a way that Windows can find the libs required by fc-cache
(unless by luck we are operating in an environment where
the install bindir is already in PATH, but this is not
guaranteed).

Ideally Meson should set up the environment properly here,
but currently it doesn't do that, so until it does we need
to work around this problem somehow.

For now we simply ignore any fc-cache failures on Windows
and print a big warning message. We have to suppress the
dialog boxes that pop up when a DLL is not found in order
to make this work nicely. This isn't pretty, but seems
that least bad option for now.

See https://github.com/mesonbuild/meson/issues/8187

Fixes #260
parent 4b142e92
Pipeline #259948 passed with stage
in 8 minutes and 47 seconds
......@@ -167,7 +167,8 @@ meson-mingw-w64-build:
- cmd.exe /C "C:\BuildTools\Common7\Tools\VsDevCmd.bat -host_arch=amd64 -arch=$env:ARCH &&
meson build $env:MESON_ARGS &&
ninja -C build &&
ninja -C build test"
ninja -C build test &&
ninja -C build install"
meson vs2017 amd64:
extends: '.build meson windows'
......
......@@ -9,5 +9,9 @@ tools_man_pages += ['fc-cache']
# Do not try to execute target's fc-cache on host when cross compiling
if not meson.is_cross_build()
# FIXME: get rid of script and change to use executable directly like this
# meson.add_install_script(fccache, '-s', '-f', '-v')
# once https://github.com/mesonbuild/meson/issues/8187 is fixed for Windows
# (plus meson requirement bump to 0.55 or whatever contains the fix for this)
meson.add_install_script('../install-cache.py', fccache.full_path())
endif
endif
\ No newline at end of file
......@@ -3,9 +3,34 @@
import sys
import argparse
import subprocess
import platform
if __name__=='__main__':
parser = argparse.ArgumentParser()
parser.add_argument('fccache')
args = parser.parse_args()
sys.exit(subprocess.run([args.fccache, '-s', '-f', '-v']).returncode)
# we ignore failures on Windows, they might be due to Meson not setting
# up the right environment, which means the built libs required by fc-cache
# can't be found. Might still work if the environment already contains the
# install bindir though, so we don't want to unconditionally skip it either.
# See https://gitlab.freedesktop.org/fontconfig/fontconfig/-/issues/260
# and https://github.com/mesonbuild/meson/issues/8187
allow_failure = False
if platform.system() == 'Windows' or platform.system().startswith('CYGWIN'):
allow_failure = True
# suppress dialog box if fontconfig dll can't be found when running fc-cache
try:
import ctypes
# SEM_FAILCRITICALERRORS|SEM_NOGPFAULTERRORBOX|SEM_NOOPENFILEERRORBOX
ctypes.windll.kernel32.SetErrorMode(0x0001|0x0002|0x8000)
except:
pass
returncode = subprocess.run([args.fccache, '-s', '-f', '-v'], check=not allow_failure).returncode
if returncode != 0 and allow_failure:
print('''
================================
WARNING: could not run fc-cache!
================================
''', file=sys.stderr)
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment