diff options
Diffstat (limited to 'platform/windows')
-rw-r--r-- | platform/windows/detect.py | 24 | ||||
-rw-r--r-- | platform/windows/os_windows.cpp | 15 |
2 files changed, 29 insertions, 10 deletions
diff --git a/platform/windows/detect.py b/platform/windows/detect.py index 5607eab342..e6e1874fc0 100644 --- a/platform/windows/detect.py +++ b/platform/windows/detect.py @@ -191,7 +191,6 @@ def get_opts(): ), BoolVariable("use_mingw", "Use the Mingw compiler, even if MSVC is installed.", False), BoolVariable("use_llvm", "Use the LLVM compiler", False), - BoolVariable("use_thinlto", "Use ThinLTO", False), BoolVariable("use_static_cpp", "Link MinGW/MSVC C++ runtime libraries statically", True), BoolVariable("use_asan", "Use address sanitizer (ASAN)", False), ] @@ -449,7 +448,10 @@ def configure_msvc(env, vcvars_msvc_config): ## LTO - if env["use_lto"]: + if env["lto"] != "none": + if env["lto"] == "thin": + print("ThinLTO is only compatible with LLVM, use `use_llvm=yes` or `lto=full`.") + sys.exit(255) env.AppendUnique(CCFLAGS=["/GL"]) env.AppendUnique(ARFLAGS=["/LTCG"]) if env["progress"]: @@ -562,17 +564,19 @@ def configure_mingw(env): if try_cmd("gcc-ranlib --version", env["mingw_prefix"], env["arch"]): env["RANLIB"] = mingw_bin_prefix + "gcc-ranlib" - if env["use_lto"]: - if not env["use_llvm"] and env.GetOption("num_jobs") > 1: + if env["lto"] != "none": + if env["lto"] == "thin": + if not env["use_llvm"]: + print("ThinLTO is only compatible with LLVM, use `use_llvm=yes` or `lto=full`.") + sys.exit(255) + env.Append(CCFLAGS=["-flto=thin"]) + env.Append(LINKFLAGS=["-flto=thin"]) + elif not env["use_llvm"] and env.GetOption("num_jobs") > 1: env.Append(CCFLAGS=["-flto"]) env.Append(LINKFLAGS=["-flto=" + str(env.GetOption("num_jobs"))]) else: - if env["use_thinlto"]: - env.Append(CCFLAGS=["-flto=thin"]) - env.Append(LINKFLAGS=["-flto=thin"]) - else: - env.Append(CCFLAGS=["-flto"]) - env.Append(LINKFLAGS=["-flto"]) + env.Append(CCFLAGS=["-flto"]) + env.Append(LINKFLAGS=["-flto"]) env.Append(LINKFLAGS=["-Wl,--stack," + str(STACK_SIZE)]) diff --git a/platform/windows/os_windows.cpp b/platform/windows/os_windows.cpp index 403d53ae53..b7794bbbf8 100644 --- a/platform/windows/os_windows.cpp +++ b/platform/windows/os_windows.cpp @@ -1146,6 +1146,21 @@ OS_Windows::OS_Windows(HINSTANCE _hInstance) { DisplayServerWindows::register_windows_driver(); + // Enable ANSI escape code support on Windows 10 v1607 (Anniversary Update) and later. + // This lets the engine and projects use ANSI escape codes to color text just like on macOS and Linux. + // + // NOTE: The engine does not use ANSI escape codes to color error/warning messages; it uses Windows API calls instead. + // Therefore, error/warning messages are still colored on Windows versions older than 10. + HANDLE stdoutHandle; + stdoutHandle = GetStdHandle(STD_OUTPUT_HANDLE); + DWORD outMode = 0; + outMode |= ENABLE_VIRTUAL_TERMINAL_PROCESSING; + + if (!SetConsoleMode(stdoutHandle, outMode)) { + // Windows 8.1 or below, or Windows 10 prior to Anniversary Update. + print_verbose("Can't set the ENABLE_VIRTUAL_TERMINAL_PROCESSING Windows console mode. `print_rich()` will not work as expected."); + } + Vector<Logger *> loggers; loggers.push_back(memnew(WindowsTerminalLogger)); _set_logger(memnew(CompositeLogger(loggers))); |