Browse Source

Fix Raspberry-PI build.

- Add RASPI define to reduce the number vertex uniforms (total uniforms must not exceed 136).
- Exclude GCC fastmath compiler option in order to pass a check in the latest AngelScript library version.
- Remove unsupported GCC attribute to suppress the warnings when building Assimp library.
Yao Wei Tjong 姚伟忠 12 years ago
parent
commit
50556078d6

+ 0 - 0
Bin/CoreData/Shaders/HLSL/CopyFrameBuffer.hlsl → Bin/CoreData/Shaders/HLSL/CopyFramebuffer.hlsl


+ 19 - 16
Source/CMake/Modules/Urho3D-CMake-magic.cmake

@@ -205,27 +205,30 @@ else ()
             # For now just reference it to suppress "unused variable" warning
             # For now just reference it to suppress "unused variable" warning
         endif ()
         endif ()
     elseif (NOT IOS)
     elseif (NOT IOS)
-        set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -ffast-math")
-        set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-invalid-offsetof -ffast-math")
+        set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-invalid-offsetof")
         if (RASPI)
         if (RASPI)
             add_definitions (-DRASPI)
             add_definitions (-DRASPI)
             set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -pipe -mcpu=arm1176jzf-s -mfpu=vfp -mfloat-abi=hard -Wno-psabi")
             set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -pipe -mcpu=arm1176jzf-s -mfpu=vfp -mfloat-abi=hard -Wno-psabi")
             set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pipe -mcpu=arm1176jzf-s -mfpu=vfp -mfloat-abi=hard -Wno-psabi")
             set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pipe -mcpu=arm1176jzf-s -mfpu=vfp -mfloat-abi=hard -Wno-psabi")
-        elseif (ENABLE_64BIT)
-            set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -m64")
-            set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -m64")
         else ()
         else ()
-            set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -m32")
-            set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -m32")
-            if (ENABLE_SSE)
-                if (NOT WIN32)
-                    set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -msse")
-                    set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -msse")
-                else ()
-                    message (STATUS "Using SSE2 instead of SSE because SSE fails on some Windows ports of GCC")
-                    message (STATUS "Disable SSE with the CMake option -DENABLE_SSE=0 if this is not desired")
-                    set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -msse2")
-                    set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -msse2")
+            set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -ffast-math")
+            set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -ffast-math")
+            if (ENABLE_64BIT)
+                set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -m64")
+                set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -m64")
+            else ()
+                set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -m32")
+                set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -m32")
+                if (ENABLE_SSE)
+                    if (NOT WIN32)
+                        set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -msse")
+                        set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -msse")
+                    else ()
+                        message (STATUS "Using SSE2 instead of SSE because SSE fails on some Windows ports of GCC")
+                        message (STATUS "Disable SSE with the CMake option -DENABLE_SSE=0 if this is not desired")
+                        set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -msse2")
+                        set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -msse2")
+                    endif ()
                 endif ()
                 endif ()
             endif ()
             endif ()
         endif ()
         endif ()

+ 7 - 16
Source/Engine/CMakeLists.txt

@@ -26,22 +26,13 @@ set (TARGET_NAME Urho3D)
 # Define generated source files
 # Define generated source files
 execute_process (COMMAND git describe --always WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} RESULT_VARIABLE GIT_EXIT_CODE OUTPUT_QUIET ERROR_QUIET)
 execute_process (COMMAND git describe --always WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} RESULT_VARIABLE GIT_EXIT_CODE OUTPUT_QUIET ERROR_QUIET)
 if (GIT_EXIT_CODE EQUAL 0)
 if (GIT_EXIT_CODE EQUAL 0)
-    # On Windows determine whether we can execute sh to see which version of the command to use
-    # Visual Studio will not use sh
-    if (NOT MSVC AND CMAKE_HOST_WIN32)
-        execute_process (COMMAND sh --version RESULT_VARIABLE SH_EXIT_CODE OUTPUT_QUIET ERROR_QUIET)
-    endif ()
-    if (MSVC OR (CMAKE_HOST_WIN32 AND NOT SH_EXIT_CODE EQUAL 0))
-        add_custom_command (OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/gitversion.h
-            COMMAND for /F %%v in ('git describe --always --dirty') do echo const char* revision="%%v"\; >${CMAKE_CURRENT_BINARY_DIR}/gitversion.h DEPENDS ${STATIC_LIBRARY_TARGETS}
-            WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
-            COMMENT "Generating GIT revision number (tag + last commit SHA-1)")
-    else ()
-        add_custom_command (OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/gitversion.h
-            COMMAND for v in `git describe --always --dirty`\; do echo 'const char* revision="'$$v'"\;' >${CMAKE_CURRENT_BINARY_DIR}/gitversion.h\; break\; done DEPENDS ${STATIC_LIBRARY_TARGETS}
-            WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
-            COMMENT "Generating GIT revision number (tag + last commit SHA-1)")
-    endif ()
+    add_custom_command (OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/gitversion.h
+        COMMAND ${CMAKE_COMMAND} -E echo_append const char* revision=\\\" >${CMAKE_CURRENT_BINARY_DIR}/gitversion.h
+        COMMAND git describe --always --dirty |tr -d '\\\n' >>${CMAKE_CURRENT_BINARY_DIR}/gitversion.h
+        COMMAND ${CMAKE_COMMAND} -E echo \\\""\;" >>${CMAKE_CURRENT_BINARY_DIR}/gitversion.h
+        DEPENDS ${STATIC_LIBRARY_TARGETS}
+        WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
+        COMMENT "Generating GIT revision number (tag + last commit SHA-1)")
 else ()
 else ()
     # No GIT command line tool or not a GIT repository, generate a dummy version file
     # No GIT command line tool or not a GIT repository, generate a dummy version file
     file (WRITE ${CMAKE_CURRENT_BINARY_DIR}/gitversion.h "const char* revision=\"Unversioned\";")
     file (WRITE ${CMAKE_CURRENT_BINARY_DIR}/gitversion.h "const char* revision=\"Unversioned\";")

+ 5 - 0
Source/Engine/Graphics/OpenGL/OGLShaderVariation.cpp

@@ -126,6 +126,11 @@ bool ShaderVariation::Create()
         #endif
         #endif
     }
     }
     
     
+    #ifdef RASPI
+    if (type_ == VS)
+        shaderCode += "#define RASPI\n";
+    #endif
+
     shaderCode += originalShaderCode;
     shaderCode += originalShaderCode;
     
     
     const char* shaderCStr = shaderCode.CString();
     const char* shaderCStr = shaderCode.CString();

+ 4 - 1
Source/ThirdParty/Assimp/include/assimp/Compiler/pushpack1.h

@@ -18,6 +18,9 @@
 //
 //
 // ===============================================================================
 // ===============================================================================
 
 
+// Modified by Yao Wei Tjong for Urho3D
+// Suppress 'gcc_struct' is being ignored warnings when compiling for Raspberry-PI
+
 #ifdef AI_PUSHPACK_IS_DEFINED
 #ifdef AI_PUSHPACK_IS_DEFINED
 #	error poppack1.h must be included after pushpack1.h
 #	error poppack1.h must be included after pushpack1.h
 #endif
 #endif
@@ -26,7 +29,7 @@
 #	pragma pack(push,1)
 #	pragma pack(push,1)
 #	define PACK_STRUCT
 #	define PACK_STRUCT
 #elif defined( __GNUC__ )
 #elif defined( __GNUC__ )
-#	if defined(__clang__)
+#	if defined(__clang__) || defined(RASPI)
 #		define PACK_STRUCT	__attribute__((__packed__))
 #		define PACK_STRUCT	__attribute__((__packed__))
 #	else
 #	else
 #		define PACK_STRUCT	__attribute__((gcc_struct, __packed__))
 #		define PACK_STRUCT	__attribute__((gcc_struct, __packed__))