Browse Source

Use -g4 flag for Emscripten Debug configuration build.
[ci package]

Yao Wei Tjong 姚伟忠 11 years ago
parent
commit
c48a46303b

+ 1 - 1
.travis.yml

@@ -38,7 +38,7 @@ before_install:
   - pushd /usr/bin && sudo ln -sf python python2 && popd
 install:
   - if [ $PACKAGE_UPLOAD ]; then travis_retry brew update >/dev/null && travis_retry brew install doxygen graphviz; fi
-  - wget https://s3.amazonaws.com/mozilla-games/emscripten/releases/emsdk-portable.tar.gz && tar xfz emsdk-portable.tar.gz && rm emsdk-portable.tar.gz && cd emsdk_portable && dummy=`./emsdk update && ./emsdk install latest && ./emsdk activate latest` && source ./emsdk_env.sh && export EMSCRIPTEN_ROOT_PATH=$EMSCRIPTEN && export EMSCRIPTEN=1
+  - wget https://s3.amazonaws.com/mozilla-games/emscripten/releases/emsdk-portable.tar.gz && tar xfz emsdk-portable.tar.gz && rm emsdk-portable.tar.gz && cd emsdk_portable && sed -i.bak 's/-xvf/-xf/g' emsdk && ./emsdk update >/dev/null && ./emsdk install latest >/dev/null && ./emsdk activate latest >/dev/null && source ./emsdk_env.sh && export EMSCRIPTEN_ROOT_PATH=$EMSCRIPTEN && export EMSCRIPTEN=1
 script: rake ci
 after_success: if [ $PACKAGE_UPLOAD ]; then rake ci_package_upload; fi
 

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

@@ -738,6 +738,7 @@ macro (setup_emscripten_linker_flags LINKER_FLAGS)
         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}_DEBUG -g4)     # Preserve LLVM debug information, show line number debug comments, and generate source maps
 endmacro ()
 
 # Macro for setting up an executable target with resources to copy/package/bundle/preload

+ 2 - 0
CMakeLists.txt

@@ -110,6 +110,8 @@ elseif (APPLE)
     set (CPACK_SYSTEM_NAME OSX)
 elseif (WIN32)
     set (CPACK_GENERATOR ZIP)
+elseif (EMSCRIPTEN)
+    set (CPACK_SYSTEM_NAME HTML5)
 elseif (CPACK_SYSTEM_NAME STREQUAL Linux)
     if (RPI)
         set (CPACK_SYSTEM_NAME Raspberry-Pi)

+ 2 - 2
Source/Urho3D/Core/ProcessUtils.cpp

@@ -394,7 +394,7 @@ unsigned GetNumPhysicalCPUs()
     #endif
     #elif defined(ANDROID)
     return GetAndroidCPUCount();
-    #elif !defined(ANDROID) && !defined(RPI) && !defined(EMSCRIPTEN)
+    #elif !defined(RPI) && !defined(EMSCRIPTEN)
     struct cpu_id_t data;
     GetCPUData(&data);
     return data.num_cores;
@@ -416,7 +416,7 @@ unsigned GetNumLogicalCPUs()
     #endif
     #elif defined(ANDROID)
     return GetAndroidCPUCount();
-    #elif !defined(ANDROID) && !defined(RPI) && !defined(EMSCRIPTEN)
+    #elif !defined(RPI) && !defined(EMSCRIPTEN)
     struct cpu_id_t data;
     GetCPUData(&data);
     return data.num_logical_cpus;

+ 3 - 4
Source/Urho3D/Engine/Application.cpp

@@ -64,10 +64,11 @@ Application::Application(Context* context) :
 
 int Application::Run()
 {
-#if !defined(EMSCRIPTEN) // TODO: do we really need to do this?
+    // Emscripten-specific: C++ exceptions are turned off by default in -O1 (and above), unless '-s DISABLE_EXCEPTION_CATCHING=0' flag is set
+    // Urho3D build configuration uses -O3 (Release), -O2 (RelWithDebInfo), and -O0 (Debug)
+    // Thus, the try-catch block below should be optimised out except in Debug build configuration
     try
     {
-#endif
         Setup();
         if (exitCode_)
             return exitCode_;
@@ -99,14 +100,12 @@ int Application::Run()
         #endif
 
         return exitCode_;
-#if !defined(EMSCRIPTEN)
     }
     catch (std::bad_alloc&)
     {
         ErrorDialog(GetTypeName(), "An out-of-memory error occurred. The application will now exit.");
         return EXIT_FAILURE;
     }
-#endif
 }
 
 void Application::ErrorExit(const String& message)