Skip to content

Commit

Permalink
Fix using Binutils AR with TEMPFILE on Windows
Browse files Browse the repository at this point in the history
Set `TEMPFILEARGESCFUNC`[1] to replace backslashes with forward slashes
in paths.

[1]: https://scons.org/doc/production/HTML/scons-user/apa.html#cv-TEMPFILEARGESCFUNC
  • Loading branch information
alvinhochun authored and jss2a98aj committed Dec 7, 2024
1 parent 5ec8177 commit 770a2aa
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions platform/windows/detect.py
Original file line number Diff line number Diff line change
Expand Up @@ -661,6 +661,17 @@ def get_is_ar_thin_supported(env):
return False


WINPATHSEP_RE = re.compile(r"\\([^\"'\\]|$)")


def tempfile_arg_esc_func(arg):
from SCons.Subst import quote_spaces

arg = quote_spaces(arg)
# GCC requires double Windows slashes, let's use UNIX separator
return WINPATHSEP_RE.sub(r"/\1", arg)


def configure_mingw(env: "SConsEnvironment"):
# Workaround for MinGW. See:
# https://www.scons.org/wiki/LongCmdLinesOnWin32
Expand All @@ -677,6 +688,8 @@ def configure_mingw(env: "SConsEnvironment"):
env["ARCOM_ORIG"] = env["ARCOM"]
env["ARCOM"] = "${TEMPFILE('$ARCOM_ORIG', '$ARCOMSTR')}"
env["TEMPFILESUFFIX"] = ".rsp"
if os.name == "nt":
env["TEMPFILEARGESCFUNC"] = tempfile_arg_esc_func

## Build type

Expand Down

0 comments on commit 770a2aa

Please sign in to comment.