windows: Support wrc resource compiler

It has a similar interface to windres, but it produces ELF instead of
COFF binaries. It uses its own preprocessor which doesn't support
creating depfiles, but we can convince it to use the system preprocessor
instead and pass those arguments using the --preprocessor option.

Together with some hacks to override the shared library/executable
suffix and some wine patches [1] this is enough to compile dxvk when
ripping out the hand-rolled rc support.

[1] https://www.winehq.org/pipermail/wine-devel/2021-July/190100.html
https://www.winehq.org/pipermail/wine-devel/2021-July/190098.html
https://www.winehq.org/pipermail/wine-devel/2021-July/190099.html
https://www.winehq.org/pipermail/wine-devel/2021-July/190101.html
pull/8973/head
Connor Abbott 3 years ago committed by Jussi Pakkanen
parent 81d9acab87
commit 62702005eb
  1. 7
      docs/markdown/snippets/wrc.md
  2. 7
      mesonbuild/modules/windows.py

@ -0,0 +1,7 @@
## Support for the Wine Resource Compiler
Users can now choose `wrc` as the `windres` binary in their cross files and
`windows.compile_resources` will handle it correctly. Together with `winegcc`
patches in Wine 6.12 this enables basic support for compiling projects as a
winelib by specifying `winegcc`/`wineg++` as the compiler and `wrc` as the
resource compiler in a cross file.

@ -27,6 +27,7 @@ from ..programs import ExternalProgram
class ResourceCompilerType(enum.Enum):
windres = 1
rc = 2
wrc = 3
class WindowsModule(ExtensionModule):
def __init__(self, interpreter):
@ -66,6 +67,7 @@ class WindowsModule(ExtensionModule):
for (arg, match, rc_type) in [
('/?', '^.*Microsoft.*Resource Compiler.*$', ResourceCompilerType.rc),
('--version', '^.*GNU windres.*$', ResourceCompilerType.windres),
('--version', '^.*Wine Resource Compiler.*$', ResourceCompilerType.wrc),
]:
p, o, e = mesonlib.Popen_safe(rescomp.get_command() + [arg])
m = re.search(match, o, re.MULTILINE)
@ -102,7 +104,7 @@ class WindowsModule(ExtensionModule):
# CVTRES internally to convert this to a COFF object)
suffix = 'res'
res_args = extra_args + ['/nologo', '/fo@OUTPUT@', '@INPUT@']
else:
elif rescomp_type == ResourceCompilerType.windres:
# ld only supports object files, so windres is used to generate a
# COFF object
suffix = 'o'
@ -113,6 +115,9 @@ class WindowsModule(ExtensionModule):
for arg in extra_args:
if ' ' in arg:
mlog.warning(m.format(arg), fatal=False)
else:
suffix = 'o'
res_args = extra_args + ['@INPUT@', '-o', '@OUTPUT@']
res_targets = []

Loading…
Cancel
Save