fix: find MinGW tools on the path when the compiler is reached through a wrapper

Closes #16
This commit is contained in:
mirkobrombin committed 2026-10-25 20:54:15 +00:00
1 parent 6ddf27d434
commit 5fe10418db
3 files changed
+18 -4

No files matched your search

+9 -2
View File
@@ -1365,8 +1365,15 @@ if(CMAKE_SYSTEM_PROCESSOR MATCHES "^(x86_64|amd64|AMD64)$")
ENVIRONMENT RAVEN_PREFIX=${fixture}/imaging-prefix)
# Messages from the program's own message table, with inserts from a va_list, as installers write their logs.
list(GET installer_compiler 0 installer_driver)
string(REGEX REPLACE "gcc$" "windmc" message_compiler ${installer_driver})
string(REGEX REPLACE "gcc$" "windres" resource_compiler ${installer_driver})
# The tools beside the compiler, or on the path when it is reached through a wrapper directory such as ccache's.
get_filename_component(installer_bin ${installer_driver} DIRECTORY)
get_filename_component(installer_name ${installer_driver} NAME)
string(REGEX REPLACE "gcc$" "windmc" message_name ${installer_name})
string(REGEX REPLACE "gcc$" "windres" resource_name ${installer_name})
find_program(RAVEN_WINDMC_${installer_arch} ${message_name} HINTS ${installer_bin})
find_program(RAVEN_WINDRES_${installer_arch} ${resource_name} HINTS ${installer_bin})
set(message_compiler ${RAVEN_WINDMC_${installer_arch}})
set(resource_compiler ${RAVEN_WINDRES_${installer_arch}})
file(MAKE_DIRECTORY ${fixture}/format)
add_custom_command(OUTPUT ${fixture}/format.exe
COMMAND ${message_compiler} -h ${fixture}/format -r ${fixture}/format ${PROJECT_SOURCE_DIR}/testdata/native_loader/format_messages.mc
+8 -1
View File
@@ -13,6 +13,7 @@ import json
import re
import subprocess
import sys
import shutil
import tempfile
from pathlib import Path
@@ -21,6 +22,12 @@ marshal = importlib.util.module_from_spec(spec)
spec.loader.exec_module(marshal)
def binutil(compiler, name):
"""The MinGW tool beside COMPILER, or on the path when the compiler is reached through a wrapper directory such as ccache's."""
tool = Path(compiler).with_name(Path(compiler).name.replace("gcc", name))
return tool if tool.exists() else shutil.which(tool.name) or tool
def compute_layouts(registry, header_text, compiler, include):
"""sizeof and offsetof/sizeof of every member of every declared structure, as the 32-bit compiler sees them."""
declared = set(re.findall(r"\bVk\w+\b", header_text))
@@ -51,7 +58,7 @@ def compute_layouts(registry, header_text, compiler, include):
sys.stderr.write(result.stderr[-4000:])
sys.exit(1)
# The table is the only initialised data of the object that starts with the marker; its bytes are the values in order.
subprocess.run([Path(compiler).with_name(Path(compiler).name.replace("gcc", "objcopy")), "-O", "binary", "-j", ".rdata", str(objfile), str(raw)], check=True)
subprocess.run([binutil(compiler, "objcopy"), "-O", "binary", "-j", ".rdata", str(objfile), str(raw)], check=True)
data = raw.read_bytes()
values = [int.from_bytes(data[at:at + 4], "little") for at in range(0, len(data) - len(data) % 4, 4)]
values = values[values.index(0xC0FFEE01) + 1:]
+1 -1
View File
@@ -380,7 +380,7 @@ def type_sizes(registry, header_text, compiler, include):
if result.returncode:
sys.stderr.write(result.stderr[-3000:])
sys.exit(1)
subprocess.run([Path(compiler).with_name(Path(compiler).name.replace("gcc", "objcopy")), "-O", "binary", "-j", ".rdata", str(objfile), str(raw)], check=True)
subprocess.run([layout32.binutil(compiler, "objcopy"), "-O", "binary", "-j", ".rdata", str(objfile), str(raw)], check=True)
data = raw.read_bytes()
values = [int.from_bytes(data[at:at + 4], "little") for at in range(0, len(data) - len(data) % 4, 4)]
values = values[values.index(0xC0FFEE01) + 1:]