Browse Source

Merge pull request #57512 from bruvzg/console_build

Rémi Verschelde 3 năm trước cách đây
mục cha
commit
fdbcd002f6
2 tập tin đã thay đổi với 14 bổ sung2 xóa
  1. 12 2
      platform/windows/detect.py
  2. 2 0
      platform/windows/os_windows.cpp

+ 12 - 2
platform/windows/detect.py

@@ -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
 

+ 2 - 0
platform/windows/os_windows.cpp

@@ -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;