Browse Source

Add Emscripten support to core library

Michael Ragazzon 3 years ago
parent
commit
5af6006961
3 changed files with 14 additions and 2 deletions
  1. 3 1
      Include/RmlUi/Core/Debug.h
  2. 4 0
      Include/RmlUi/Core/Platform.h
  3. 7 1
      Source/Core/SystemInterface.cpp

+ 3 - 1
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
 
 

+ 4 - 0
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

+ 7 - 1
Source/Core/SystemInterface.cpp

@@ -33,6 +33,8 @@
 
 #ifdef RMLUI_PLATFORM_WIN32
 #include <windows.h>
+#else
+#include <stdio.h>
 #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