Merge pull request #57512 from bruvzg/console_build

This commit is contained in:
Rémi Verschelde 2022-02-02 23:06:36 +01:00 committed by GitHub
commit fdbcd002f6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 2 deletions

View file

@ -65,6 +65,7 @@ def get_opts():
# Vista support dropped after EOL due to GH-10243
("target_win_version", "Targeted Windows version, >= 0x0601 (Windows 7)", "0x0601"),
BoolVariable("debug_symbols", "Add debugging symbols to release/release_debug builds", True),
EnumVariable("windows_subsystem", "Windows subsystem", "gui", ("gui", "console")),
BoolVariable("separate_debug_symbols", "Create a separate file containing debugging symbols", False),
("msvc_version", "MSVC version to use. Ignored if VCINSTALLDIR is set in shell env.", None),
BoolVariable("use_mingw", "Use the Mingw compiler, even if MSVC is installed.", False),
@ -197,7 +198,12 @@ def configure_msvc(env, manual_msvc_config):
env.AppendUnique(CCFLAGS=["/bigobj"])
env.Append(LINKFLAGS=["/DEBUG"])
env.Append(LINKFLAGS=["/SUBSYSTEM:WINDOWS"])
if env["windows_subsystem"] == "gui":
env.Append(LINKFLAGS=["/SUBSYSTEM:WINDOWS"])
else:
env.Append(LINKFLAGS=["/SUBSYSTEM:CONSOLE"])
env.AppendUnique(CPPDEFINES=["WINDOWS_SUBSYSTEM_CONSOLE"])
env.Append(LINKFLAGS=["/ENTRY:mainCRTStartup"])
if env["debug_symbols"]:
@ -333,7 +339,11 @@ def configure_mingw(env):
# and are the only ones with too big objects).
env.Append(CCFLAGS=["-Wa,-mbig-obj"])
env.Append(LINKFLAGS=["-Wl,--subsystem,windows"])
if env["windows_subsystem"] == "gui":
env.Append(LINKFLAGS=["-Wl,--subsystem,windows"])
else:
env.Append(LINKFLAGS=["-Wl,--subsystem,console"])
env.AppendUnique(CPPDEFINES=["WINDOWS_SUBSYSTEM_CONSOLE"])
## Compiler configuration

View file

@ -166,7 +166,9 @@ void OS_Windows::initialize_core() {
last_button_state = 0;
restore_mouse_trails = 0;
#ifndef WINDOWS_SUBSYSTEM_CONSOLE
RedirectIOToConsole();
#endif
maximized = false;
minimized = false;