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

Add a SCons option to control whether Godot is built as a console or GUI application on Windows #1341

Closed
Calinou opened this issue Aug 9, 2020 · 3 comments · Fixed by godotengine/godot#41164 or godotengine/godot#41332

Comments

@Calinou
Copy link
Member

Calinou commented Aug 9, 2020

Describe the project you are working on:

The Godot editor 🙂

Describe the problem or limitation you are having in your project:

When compiling Godot for Windows with the debug or release_debug target, it's compiled as a console application (even though it spawns a window on top of that). This means it's able to print to standard output/error. This also allows redirecting its output to a file.

However, when compiling Godot for Windows with the release target, it's compiled as a GUI application. This makes it impossible to see its standard output or error since no console window is visible. Even when running the executable from a command prompt, nothing will be printed. This makes it effectively impossible to redirect its output to a file.

This is a Windows limitation. Running the program in WINE may be able to overcome this limitation, but running WINE on Windows is usually impractical and requires a fair amount of setup.

Describe the feature / enhancement and how it helps to overcome the problem or limitation:

Add a windows_build_mode=console|gui SCons option that overrides the build mode regardless of the target used. (Feel free to suggest a better name for this option.)

This could help resolve godotengine/godot#24701 while making godotengine/godot#28922 significantly easier to troubleshoot.

Describe how your proposal will work, with code, pseudocode, mockups, and/or diagrams:

This can probably be done with some well-placed #ifdefs in the Windows platform code.

If this enhancement will not be used often, can it be worked around with a few lines of script?:

This needs to be decided at build-time, so no.

Is there a reason why this should be core and not an add-on in the asset library?:

This needs to be decided at build-time, so this can't be changed by an add-on.


See also #1342.

@bruvzg
Copy link
Member

bruvzg commented Aug 9, 2020

Some things to test:

  • Is it possible to redirect stdout (or stderr) from the GUI app to file/pipe with the godot > target / godot | target commands?
  • Is it possible to manually attach to the parent process console (print only when it's started from console). Quick search gives something like this:
if (AttachConsole(ATTACH_PARENT_PROCESS)) {
    freopen("CONOUT$", "w", stdout);
    freopen("CONOUT$", "w", stderr);
}

@bruvzg
Copy link
Member

bruvzg commented Aug 10, 2020

Some things to test:

  • Redirection works with GUI apps.
  • AttachConsole also works, it's non-blocking and won't play nicely with two-panels file managers, but running app with start /wait /b godot should fix it too (and probably by adding freopen("CONIN$", "r", stdin);).

@Xrayez
Copy link
Contributor

Xrayez commented Aug 16, 2020

I think going for compile-time option could've been a solution too. See godotengine/godot#41307, so the scons tests=yes could automatically enable proposed windows_build_mode=console for those builds.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
4 participants