2022-04-11 23:18:06 +02:00

112 lines
3.5 KiB
Diff

diff --git a/platform/windows/os_windows.cpp b/platform/windows/os_windows.cpp
index 8b28cbf1f23d6574aac41a3676fea64ddf786fc4..0124d4ac9652df9ba682ab8cc18b4008461d74cf 100644
--- a/platform/windows/os_windows.cpp
+++ b/platform/windows/os_windows.cpp
@@ -53,6 +53,11 @@
#include <regstr.h>
#include <shlobj.h>
+#ifdef LIVEPP_PATH
+#include "API/LPP_API.h"
+extern HMODULE livePP;
+#endif
+
static const WORD MAX_CONSOLE_LINES = 1500;
extern "C" {
@@ -3371,6 +3376,9 @@ void OS_Windows::run() {
process_events(); // get rid of pending events
if (Main::iteration())
break;
+#ifdef LIVEPP_PATH
+ lpp::lppSyncPoint(livePP);
+#endif
};
main_loop->finish();
diff --git a/platform/windows/detect.py b/platform/windows/detect.py
index e4facad816b7584fe38dc760356310e0a3937288..2d9da3df65cd3a0b0882ace984002320ebf6c3fc 100644
--- a/platform/windows/detect.py
+++ b/platform/windows/detect.py
@@ -44,7 +44,7 @@ def can_build():
def get_opts():
- from SCons.Variables import BoolVariable, EnumVariable
+ from SCons.Variables import BoolVariable, EnumVariable, PathVariable
mingw32 = ""
mingw64 = ""
@@ -72,6 +72,7 @@ def get_opts():
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),
+ PathVariable("livepp", "Path to the Live++ installation", "", PathVariable.PathAccept),
]
@@ -296,6 +297,18 @@ def configure_msvc(env, manual_msvc_config):
env.AppendUnique(LINKFLAGS=["/STACK:" + str(STACK_SIZE)])
+ # Check if LIVEPP_PATH is set and add #define. Perform
+ # some sanity checks.
+ if env.get("livepp"):
+ if env["target"] == "release_debug" or env["target"] == "debug":
+ print("Found Live++ at %s" % env.get("livepp"))
+ env.AppendUnique(CPPDEFINES=["LIVEPP_PATH=%s" % env.get("livepp")])
+ env.AppendUnique(CPPPATH=[env.get("livepp")])
+ env.AppendUnique(LINKFLAGS=["/FUNCTIONPADMIN"])
+ else:
+ print("Live++ can only be used with targets 'debug' and 'release_debug'")
+ else:
+ print("No Live++ specified.")
def configure_mingw(env):
# Workaround for MinGW. See:
diff --git a/platform/windows/godot_windows.cpp b/platform/windows/godot_windows.cpp
index d7d9e4eace00a696abbb47cb9632f40e183a4ec4..e362320e51c725cd01f292887bd93442752c1c48 100644
--- a/platform/windows/godot_windows.cpp
+++ b/platform/windows/godot_windows.cpp
@@ -34,6 +34,11 @@
#include <locale.h>
#include <stdio.h>
+#ifdef LIVEPP_PATH
+#include "API/LPP_API.h"
+HMODULE livePP;
+#endif
+
// For export templates, add a section; the exporter will patch it to enclose
// the data appended to the executable (bundled PCK)
#ifndef TOOLS_ENABLED
@@ -136,6 +141,16 @@ char *wc_to_utf8(const wchar_t *wc) {
}
__declspec(dllexport) int widechar_main(int argc, wchar_t **argv) {
+#ifdef LIVEPP_PATH
+#define _MKSTR_L(x) _STR_L(x)
+#define _STR_L(x) L#x
+ livePP = lpp::lppLoadAndRegister(_MKSTR_L(LIVEPP_PATH), "Godot");
+ lpp::lppEnableAllCallingModulesSync(livePP);
+ lpp::lppInstallExceptionHandler(livePP);
+#undef _MKSTR_L
+#undef _STR_L
+#endif
+
OS_Windows os(NULL);
setlocale(LC_CTYPE, "");
@@ -170,6 +185,11 @@ __declspec(dllexport) int widechar_main(int argc, wchar_t **argv) {
}
delete[] argv_utf8;
+#ifdef LIVEPP_PATH
+ lpp::lppShutdown(livePP);
+ ::FreeLibrary(livePP);
+#endif
+
return os.get_exit_code();
};