Browse Source

Slightly improve code size and startup speed for Emscripten platform.

Yao Wei Tjong 姚伟忠 10 years ago
parent
commit
10e18da92e
2 changed files with 3 additions and 3 deletions
  1. 1 1
      CMake/Modules/Urho3D-CMake-common.cmake
  2. 2 2
      Source/Urho3D/Engine/Engine.cpp

+ 1 - 1
CMake/Modules/Urho3D-CMake-common.cmake

@@ -817,7 +817,7 @@ macro (setup_emscripten_linker_flags LINKER_FLAGS)
     else ()
         set (MEMORY_LINKER_FLAGS "-s TOTAL_MEMORY=${EMSCRIPTEN_TOTAL_MEMORY}")
     endif ()
-    set (${LINKER_FLAGS} "${${LINKER_FLAGS}} ${MEMORY_LINKER_FLAGS} -s USE_SDL=2")    # Urho3D uses SDL2 so set it here instead of in the toolchain which potentially could be reused in other projects not using SDL2
+    set (${LINKER_FLAGS} "${${LINKER_FLAGS}} ${MEMORY_LINKER_FLAGS} -s USE_SDL=2 -s NO_EXIT_RUNTIME=1")    # Urho3D uses SDL2 so set it here instead of in the toolchain which potentially could be reused in other projects not using SDL2
     set (${LINKER_FLAGS}_RELEASE "-s AGGRESSIVE_VARIABLE_ELIMINATION=1")     # Remove variables to make the -O3 regalloc easier
     if (NOT DEFINED ENV{CI})
         set (${LINKER_FLAGS}_DEBUG -g4)     # Preserve LLVM debug information, show line number debug comments, and generate source maps

+ 2 - 2
Source/Urho3D/Engine/Engine.cpp

@@ -54,7 +54,7 @@
 #include "../Core/WorkQueue.h"
 #include "../Resource/XMLFile.h"
 
-#ifdef EMSCRIPTEN
+#if defined(EMSCRIPTEN) && defined(URHO3D_TESTING)
 #include <emscripten.h>
 #endif
 
@@ -892,7 +892,7 @@ void Engine::DoExit()
         graphics->Close();
 
     exiting_ = true;
-    #ifdef EMSCRIPTEN
+    #if defined(EMSCRIPTEN) && defined(URHO3D_TESTING)
     emscripten_force_exit(EXIT_SUCCESS);    // Some how this is required to signal emrun to stop
     #endif
 }