godot icon indicating copy to clipboard operation
godot copied to clipboard

SCons: Fix MinGW tools on Windows native shells

Open Repiteo opened this issue 1 year ago • 3 comments

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 function Detect to see if a given tool is found, and it does this check upwards of 4 times in the following order:

  • Check in mingw_prefix bin folder with arch prefix
  • Check in mingw_prefix bin folder with no prefix
  • Check on path with arch prefix
  • Check on path with no prefix

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 to False or doesn't exist. As a result of this change, build_res_file is no longer needed. The arch alias option is instead assigned to RCFLAGS and the detected tool for windres is assigned to RC.

Repiteo avatar May 11 '24 20:05 Repiteo

cc @TokageItLab. I wanna be 100% sure this can't cause #91710 again.

Repiteo avatar May 11 '24 20:05 Repiteo

Would be good to assess whether that may fix #40286 fully - or whether that specific older issue was still reproducible in the first place.

akien-mga avatar May 11 '24 21:05 akien-mga

The order of operations changes in this PR should make it impossible to pull something from the wrong path, if it exists on the mingw_prefix bin path in the first place.

Repiteo avatar May 14 '24 19:05 Repiteo

Superseded by #98105

Repiteo avatar Oct 11 '24 21:10 Repiteo