SCons: Fix MinGW tools on Windows native shells #91847
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
A reimplementation of #91734 with the intent of maintaining readability & functionality. The main thing this serves to fix is an odd quirk of running MinGW Tools on Windows in a native shell: they will very frequently fail because of the Windows-style path separators being parsed as escape characters. While I tried to circumvent this through other more roundabout means, the solution that turned out to be the most reliable by far was detecting if the os separator is Window-style; if it is, prepend the MinGW bin folder to the path. Frankly, I'm not sure why this works, but… It works!
This also solves a significant flaw found in the now-reverted #85319, where the
mingw_prefix
was prepended to everything, leading to certain tools to fail outright (RES most notably). This circumvents that problem by making the process by which these values are checked much, much more involved. It utilizes the SCons functionDetect
to see if a given tool is found, and it does this check upwards of 4 times in the following order:If the tool is found at any point, it's returned as a path. If the tool isn't found, it's returned as an empty string, evaluating to
False
in conditionals. Use of conditionals in this manner was significantly reduced, as that is largely handled on SCons' end if a given env variable either evaluates toFalse
or doesn't exist. As a result of this change,build_res_file
is no longer needed. The arch alias option is instead assigned toRCFLAGS
and the detected tool forwindres
is assigned toRC
.