Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SCons: Fix potential Windows ANSI exception #92087

Merged
merged 1 commit into from
May 19, 2024

Conversation

Repiteo
Copy link
Contributor

@Repiteo Repiteo commented May 18, 2024

Fixes #92065

Rectified the issue by looking up the explicit values these functions expect1, which should prevent futher type errors from occuring. As far as making sure that a build progresses regardless, this adds an exception wrapper to that bit of code that caused the issue. If an exception does occur, it assumes that the Windows ANSI setup failed & explicitly disables color output. Also moved the check down slightly in the main SConstruct file so that it can output an error message via methods.print_error instead of a generic print.

A future solution could be to overhaul the color system to something closer to what colorama achieves, which has a dedicated catch/conversion for Windows specifically. I'm not wholly knowledgeable on that approach, so I didn't attempt to implement it here.

Footnotes

  1. https://learn.microsoft.com/en-us/windows/console/getstdhandle
    https://learn.microsoft.com/en-us/windows/console/getconsolemode
    https://learn.microsoft.com/en-us/windows/console/setconsolemode

@Calinou
Copy link
Member

Calinou commented May 18, 2024

Should this be applied to doc/tools/make_rst.py as well? I believe it has a similar function.

@huwpascoe
Copy link

Would it be possible to wrap those repeated paragraphs into a utility function like try_to_enable_win32_console_colors() or something?

@Repiteo
Copy link
Contributor Author

Repiteo commented May 18, 2024

Should this be applied to doc/tools/make_rst.py as well? I believe it has a similar function.

Oh shoot, good catch! I'll apply it there as well

Would it be possible to wrap those repeated paragraphs into a utility function like try_to_enable_win32_console_colors() or something?

Technically yes, but that'd require some hackery in the situations where these files aren't run in the repo root (would be very common for the GDExtension SConstruct files). Making the entire repo "smarter" in this respect would be quite a logistical hurdle, and well outside the scope of this PR.

@Repiteo Repiteo force-pushed the scons/windows-color-fix-maybe branch from a07f8ec to bea20ca Compare May 18, 2024 18:07
@Repiteo Repiteo requested a review from a team as a code owner May 18, 2024 18:07
@Repiteo Repiteo force-pushed the scons/windows-color-fix-maybe branch from bea20ca to a9810cf Compare May 18, 2024 18:14
@akien-mga akien-mga merged commit daa81bb into godotengine:master May 19, 2024
16 checks passed
@akien-mga
Copy link
Member

Thanks!

@Repiteo Repiteo deleted the scons/windows-color-fix-maybe branch May 19, 2024 13:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

SConstruct script in main branch is broken on windows
5 participants