From 5af60069618ed3cf6e38ef7fb137fbcadcbfd5e4 Mon Sep 17 00:00:00 2001 From: Michael Ragazzon Date: Tue, 31 May 2022 23:27:57 +0200 Subject: [PATCH] Add Emscripten support to core library --- Include/RmlUi/Core/Debug.h | 4 +++- Include/RmlUi/Core/Platform.h | 4 ++++ Source/Core/SystemInterface.cpp | 8 +++++++- 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/Include/RmlUi/Core/Debug.h b/Include/RmlUi/Core/Debug.h index 38d9c8b84..0e59079ef 100644 --- a/Include/RmlUi/Core/Debug.h +++ b/Include/RmlUi/Core/Debug.h @@ -47,7 +47,9 @@ #define RMLUI_BREAK #endif #elif defined (RMLUI_PLATFORM_MACOSX) - #define RMLUI_BREAK {__builtin_trap();} // namespace Rml + #define RMLUI_BREAK {__builtin_trap();} +#else + #define RMLUI_BREAK #endif diff --git a/Include/RmlUi/Core/Platform.h b/Include/RmlUi/Core/Platform.h index 3a0c579a8..d5dc107d2 100644 --- a/Include/RmlUi/Core/Platform.h +++ b/Include/RmlUi/Core/Platform.h @@ -36,6 +36,10 @@ #define RMLUI_PLATFORM_UNIX #define RMLUI_PLATFORM_MACOSX #define RMLUI_PLATFORM_NAME "macosx" +#elif defined __EMSCRIPTEN__ + #define RMLUI_PLATFORM_UNIX + #define RMLUI_PLATFORM_EMSCRIPTEN + #define RMLUI_PLATFORM_NAME "emscripten" #else #define RMLUI_PLATFORM_UNIX #define RMLUI_PLATFORM_LINUX diff --git a/Source/Core/SystemInterface.cpp b/Source/Core/SystemInterface.cpp index 2181f42de..4db5c54ab 100644 --- a/Source/Core/SystemInterface.cpp +++ b/Source/Core/SystemInterface.cpp @@ -33,6 +33,8 @@ #ifdef RMLUI_PLATFORM_WIN32 #include +#else +#include #endif namespace Rml { @@ -70,7 +72,11 @@ bool SystemInterface::LogMessage(Log::Type logtype, const String& message) #else bool SystemInterface::LogMessage(Log::Type /*logtype*/, const String& message) { - fprintf(stderr,"%s\n", message.c_str()); +#ifdef RMLUI_PLATFORM_EMSCRIPTEN + puts(message.c_str()); +#else + fprintf(stderr, "%s\n", message.c_str()); +#endif return true; } #endif