From 87be261c0f339a0f76b9e7d7ccb5b41d58c34b1c Mon Sep 17 00:00:00 2001 From: Marcel Admiraal Date: Sat, 2 Dec 2023 12:39:15 +0200 Subject: [PATCH 1/4] Add vertical scrollbar to hooks PowerShell messagebox script --- misc/hooks/messagebox.ps1 | 1 + 1 file changed, 1 insertion(+) diff --git a/misc/hooks/messagebox.ps1 b/misc/hooks/messagebox.ps1 index a65cc66132..9990e99230 100644 --- a/misc/hooks/messagebox.ps1 +++ b/misc/hooks/messagebox.ps1 @@ -55,6 +55,7 @@ if ($file -ne "") { $textBox.Multiline = $true $textBox.ReadOnly = $true $textBox.Autosize = $true + $textBox.ScrollBars = [System.Windows.Forms.ScrollBars]::Vertical $textBox.Select(0, 0) $form.Controls.Add($textBox) } From 4e48dfc9701202ffdc0fd588333184d69a158da4 Mon Sep 17 00:00:00 2001 From: Marcel Admiraal Date: Sun, 29 Oct 2023 07:10:50 +0100 Subject: [PATCH 2/4] Fix Windows resource file values - Places all Windows resource file values on one line. - Removes leading empty strings from VERSION defines. --- core/version.h | 12 ++++++------ platform/windows/resource.rc | 9 ++++----- 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/core/version.h b/core/version.h index 620b35a71c..e41a69ffc0 100644 --- a/core/version.h +++ b/core/version.h @@ -16,14 +16,14 @@ // Defines the main "branch" version. // Patch versions in this branch should be forward-compatible. // Example: "1.1" -#define VERSION_BRANCH "" _MKSTR(VERSION_MAJOR) "." _MKSTR(VERSION_MINOR) +#define VERSION_BRANCH _MKSTR(VERSION_MAJOR) "." _MKSTR(VERSION_MINOR) #if VERSION_PATCH // Example: "1.1.1" -#define VERSION_NUMBER "" VERSION_BRANCH "." _MKSTR(VERSION_PATCH) +#define VERSION_NUMBER VERSION_BRANCH "." _MKSTR(VERSION_PATCH) #else // VERSION_PATCH == 0 // we don't include it in the "pretty" version number. // Example: "1.1" instead of "1.1.0" -#define VERSION_NUMBER "" VERSION_BRANCH +#define VERSION_NUMBER VERSION_BRANCH #endif // VERSION_PATCH // Version number encoded as hexadecimal int with one byte for each number. @@ -37,15 +37,15 @@ // potential module-specific features (e.g. mono). // Example: "1.1.stable.mono" #define VERSION_FULL_CONFIG \ - "" VERSION_NUMBER "." VERSION_STATUS VERSION_MODULE_CONFIG + VERSION_NUMBER "." VERSION_STATUS VERSION_MODULE_CONFIG // Similar to VERSION_FULL_CONFIG, but // also includes the (potentially custom) VERSION_BUILD description (e.g. // official, custom_build, etc.). Example: "1.1.stable.mono.official" -#define VERSION_FULL_BUILD "" VERSION_FULL_CONFIG "." VERSION_BUILD +#define VERSION_FULL_BUILD VERSION_FULL_CONFIG "." VERSION_BUILD // Same as above, but prepended with Rebel Engine's name and a cosmetic "v" for // "version". Example: "Rebel Engine v1.1.stable.mono.official" -#define VERSION_FULL_NAME "" VERSION_NAME " v" VERSION_FULL_BUILD +#define VERSION_FULL_NAME VERSION_NAME " v" VERSION_FULL_BUILD #endif // VERSION_H diff --git a/platform/windows/resource.rc b/platform/windows/resource.rc index e287553649..6f3c0e72fb 100644 --- a/platform/windows/resource.rc +++ b/platform/windows/resource.rc @@ -9,8 +9,9 @@ APP_ICON ICON "platform/windows/rebel-icon.ico" 1 VERSIONINFO FILEVERSION VERSION_MAJOR,VERSION_MINOR,VERSION_PATCH,0 PRODUCTVERSION VERSION_MAJOR,VERSION_MINOR,VERSION_PATCH,0 -FILEOS 4 -FILETYPE 1 +FILEOS 4 // VOS__WINDOWS32 = 0x00000004L +FILETYPE 1 // VFT_APP = 0x00000001L + BEGIN BLOCK "StringFileInfo" BEGIN @@ -21,9 +22,7 @@ BEGIN VALUE "FileVersion", VERSION_NUMBER VALUE "ProductName", VERSION_NAME VALUE "Licence", "MIT" - VALUE "LegalCopyright", "2022-Present, Rebel Engine contributors -2014-2022, Godot Engine contributors. -2007-2022, Juan Linietsky, Ariel Manzur." + VALUE "LegalCopyright", "\xA9 Rebel Engine contributors" VALUE "ProductVersion", VERSION_FULL_BUILD END END From ab01b0569890411590b17172fdd3d3eacbe04dd9 Mon Sep 17 00:00:00 2001 From: Marcel Admiraal Date: Sun, 29 Oct 2023 08:12:01 +0200 Subject: [PATCH 3/4] Fix ENABLE_VIRTUAL_TERMINAL_PROCESSING may not be defined - Reverts the workaround for a problem with Windows 11 Terminal closing Rebel Editor when Project Manager closed. - Reverts the incomplete change for disabling execute opening a console. --- platform/windows/os_windows.cpp | 30 +++++------------------------- platform/windows/os_windows.h | 4 ---- 2 files changed, 5 insertions(+), 29 deletions(-) diff --git a/platform/windows/os_windows.cpp b/platform/windows/os_windows.cpp index 873c54b6a5..25fe443732 100644 --- a/platform/windows/os_windows.cpp +++ b/platform/windows/os_windows.cpp @@ -2551,27 +2551,14 @@ bool OS_Windows::is_window_focused() const { return window_focused; } -bool OS_Windows::_is_win11_terminal() const { - HANDLE hStdOut = GetStdHandle(STD_OUTPUT_HANDLE); - DWORD dwMode = 0; - if (GetConsoleMode(hStdOut, &dwMode)) { - return ( - (dwMode & ENABLE_VIRTUAL_TERMINAL_PROCESSING) - == ENABLE_VIRTUAL_TERMINAL_PROCESSING - ); - } else { - return false; - } -} - void OS_Windows::set_console_visible(bool p_enabled) { if (console_visible == p_enabled) { return; } - if (!_is_win11_terminal()) { - // GetConsoleWindow is not supported by the Windows Terminal. - ShowWindow(GetConsoleWindow(), p_enabled ? SW_SHOW : SW_HIDE); + HWND console_window = GetConsoleWindow(); + if (console_window != nullptr) { + ShowWindow(console_window, p_enabled ? SW_SHOW : SW_HIDE); console_visible = p_enabled; } } @@ -3319,20 +3306,13 @@ Error OS_Windows::execute( modstr.write[i] = cmdline[i]; } - DWORD creation_flags = NORMAL_PRIORITY_CLASS & CREATE_NO_WINDOW; - if (p_path == get_executable_path() && GetConsoleWindow() != NULL - && _is_win11_terminal()) { - // Open a new terminal as a workaround for Windows Terminal bug. - creation_flags |= CREATE_NEW_CONSOLE; - } - int ret = CreateProcessW( NULL, modstr.ptrw(), NULL, NULL, - 0, - creation_flags, + FALSE, + NORMAL_PRIORITY_CLASS, NULL, NULL, si_w, diff --git a/platform/windows/os_windows.h b/platform/windows/os_windows.h index 5ac5e52c98..5f1f5b7fc4 100644 --- a/platform/windows/os_windows.h +++ b/platform/windows/os_windows.h @@ -355,14 +355,10 @@ class OS_Windows : public OS { CrashHandler crash_handler; - bool _is_win11_terminal() const; - void _drag_event(float p_x, float p_y, int idx); void _touch_event(bool p_pressed, float p_x, float p_y, int idx); - void _update_window_style(bool p_repaint = true, bool p_maximized = false); void _update_window_mouse_passthrough(); - void _set_mouse_mode_impl(MouseMode p_mode); // functions used by main to initialize/deinitialize the OS From 37c65ae1f30bc5696bad03c57663ac2175e2b798 Mon Sep 17 00:00:00 2001 From: Marcel Admiraal Date: Sat, 2 Dec 2023 12:38:48 +0200 Subject: [PATCH 4/4] Fix Windows MinGW, MSVC and respective Clang build scripts on Windows - Removes the dot from suffix added to sanitizer builds. - Adds mingw or msvc suffix to builds to indicate compiler mode. - Adds MSVC LLVM (Clang) compiler build option. - Refactors the MinGW configuration and setup. --- platform/windows/detect.py | 83 ++++++++++++++++++++------------------ 1 file changed, 43 insertions(+), 40 deletions(-) diff --git a/platform/windows/detect.py b/platform/windows/detect.py index 39eb7bae3f..7b2666a7ef 100644 --- a/platform/windows/detect.py +++ b/platform/windows/detect.py @@ -130,9 +130,7 @@ def setup_msvc_manual(env): argument (example: scons p=windows) and SCons will attempt to detect what MSVC compiler will be executed and inform you. """ ) - raise SCons.Errors.UserError( - "Bits argument should not be used when using VCINSTALLDIR" - ) + raise SystemExit("Bits argument should not be used when using VCINSTALLDIR") # Force bits arg # (Actually msys2 mingw can support 64-bit, we could detect that) @@ -159,6 +157,9 @@ def setup_msvc_manual(env): "Failed to manually detect MSVC compiler architecture version... Defaulting to 32bit executable settings (forcing bits=32). Compilation attempt will continue, but SCons can not detect for what architecture this build is compiled for. You should check your settings/compilation setup, or avoid setting VCINSTALLDIR." ) + if env["use_llvm"]: + setup_msvc_llvm(env) + def setup_msvc_auto(env): """Set up MSVC using SCons's auto-detection logic""" @@ -194,12 +195,37 @@ def setup_msvc_auto(env): if env["TARGET_ARCH"] in ("amd64", "x86_64"): env["x86_libtheora_opt_vc"] = False + if env["use_llvm"]: + setup_msvc_llvm(env) + + +def setup_msvc_llvm(env): + env["CC"] = "clang-cl" + env.extra_suffix = ".llvm" + env.extra_suffix + def setup_mingw(env): """Set up env for use with mingw""" - # Nothing to do here print("Using MinGW") + if env["bits"] == "32": + mingw_prefix = env["mingw_prefix_32"] + else: + mingw_prefix = env["mingw_prefix_64"] + + if env["use_llvm"]: + env["CC"] = mingw_prefix + "clang" + env["CXX"] = mingw_prefix + "clang++" + env["AR"] = mingw_prefix + "ar" + env["RANLIB"] = mingw_prefix + "ranlib" + env.extra_suffix = ".llvm" + env.extra_suffix + else: + env["CC"] = mingw_prefix + "gcc" + env["CXX"] = mingw_prefix + "g++" + env["AS"] = mingw_prefix + "as" + env["AR"] = mingw_prefix + "gcc-ar" + env["RANLIB"] = mingw_prefix + "gcc-ranlib" + def configure_msvc(env, manual_msvc_config): """Configure env to work with MSVC""" @@ -317,7 +343,7 @@ def configure_msvc(env, manual_msvc_config): # Sanitizers if env["use_asan"]: - env.extra_suffix += ".s" + env.extra_suffix += "s" env.Append(LINKFLAGS=["/INFERASANLIBS"]) env.Append(CCFLAGS=["/fsanitize=address"]) @@ -378,31 +404,14 @@ def configure_mingw(env): else: # default to 64-bit on Linux env["bits"] = "64" - mingw_prefix = "" - if env["bits"] == "32": if env["use_static_cpp"]: env.Append(LINKFLAGS=["-static"]) env.Append(LINKFLAGS=["-static-libgcc"]) env.Append(LINKFLAGS=["-static-libstdc++"]) - mingw_prefix = env["mingw_prefix_32"] else: if env["use_static_cpp"]: env.Append(LINKFLAGS=["-static"]) - mingw_prefix = env["mingw_prefix_64"] - - if env["use_llvm"]: - env["CC"] = mingw_prefix + "clang" - env["CXX"] = mingw_prefix + "clang++" - env["AS"] = mingw_prefix + "as" - env["AR"] = mingw_prefix + "ar" - env["RANLIB"] = mingw_prefix + "ranlib" - else: - env["CC"] = mingw_prefix + "gcc" - env["CXX"] = mingw_prefix + "g++" - env["AS"] = mingw_prefix + "as" - env["AR"] = mingw_prefix + "gcc-ar" - env["RANLIB"] = mingw_prefix + "gcc-ranlib" env["x86_libtheora_opt_gcc"] = True @@ -488,23 +497,17 @@ def configure(env): ] = os.environ # this makes build less repeatable, but simplifies some things env["ENV"]["TMP"] = os.environ["TMP"] - # First figure out which compiler, version, and target arch we're using - if os.getenv("VCINSTALLDIR") and not env["use_mingw"]: - # Manual setup of MSVC - setup_msvc_manual(env) - env.msvc = True - manual_msvc_config = True - elif env.get("MSVC_VERSION", "") and not env["use_mingw"]: - setup_msvc_auto(env) - env.msvc = True - manual_msvc_config = False - else: + if env["use_mingw"]: setup_mingw(env) - env.msvc = False - - # Now set compiler/linker flags - if env.msvc: - configure_msvc(env, manual_msvc_config) - - else: # MinGW configure_mingw(env) + env.msvc = False + env.extra_suffix = ".mingw" + env.extra_suffix + else: + if os.getenv("VCINSTALLDIR"): + setup_msvc_manual(env) + configure_msvc(env, True) + else: + setup_msvc_auto(env) + configure_msvc(env, False) + env.msvc = True + env.extra_suffix = ".msvc" + env.extra_suffix