Browse Source

compile on arm arch with opengles2

proller 9 years ago
parent
commit
0dc85f14a9

+ 2 - 1
CMake/Modules/CheckCompilerToolchain.cmake

@@ -92,12 +92,13 @@ else ()
     endif ()
     # Android arm64 compiler only emits __aarch64__ while iOS arm64 emits __aarch64__, __arm64__, and __arm__; for armv7a all emit __arm__
     check_native_define ("__(arm|aarch64)__" ARM)
+    check_native_define ("__aarch64__" ARM64)
     # For completeness sake as currently we do not support PowerPC (yet)
     check_native_define ("__(ppc|PPC|powerpc|POWERPC)(64)*__" POWERPC)
     # Check if the target arm platform is currently supported
     if (ARM AND NOT ANDROID AND NOT RPI AND NOT IOS AND NOT TVOS)
         # TODO: check the uname of the host system for the telltale sign of RPI, just in case this is a native build on the device itself
-        message (FATAL_ERROR "Unsupported arm target architecture")
+        message (STATUS "Unsupported arm target architecture")
     endif ()
     # GCC/Clang and all their derivatives should understand this command line option to get the compiler version
     if (NOT DEFINED COMPILER_VERSION)

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

@@ -599,6 +599,15 @@ else ()
             endif ()
             set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${RPI_CFLAGS}")
             set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${RPI_CFLAGS}")
+        elseif (ARM)
+            set (ARM_CFLAGS "${ARM_CFLAGS} -pipe")
+            if (NOT ARM64)
+                set (ARM_CFLAGS "${ARM_CFLAGS} -mfloat-abi=hard -Wno-psabi")    # We only support armhf distros, so turn on hard-float by default
+                # todo: fix asm in as for arm
+                add_definitions (-DAS_MAX_PORTABILITY)
+            endif ()
+            set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${ARM_CFLAGS}")
+            set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${ARM_CFLAGS}")
         else ()
             if (URHO3D_SSE AND NOT XCODE AND NOT WEB)
                 # This may influence the effective SSE level when URHO3D_SSE is on as well
@@ -1549,9 +1558,12 @@ macro (define_dependency_libs TARGET)
 
         # Graphics
         if (URHO3D_OPENGL)
+            if(VIDEO_OPENGLES)
+                CheckOpenGLES()
+            endif()
             if (WIN32)
                 list (APPEND LIBS opengl32)
-            elseif (ANDROID)
+            elseif (ANDROID OR HAVE_VIDEO_OPENGLES)
                 list (APPEND LIBS GLESv1_CM GLESv2)
             elseif (NOT APPLE AND NOT RPI)
                 list (APPEND LIBS GL)

+ 11 - 1
Source/ThirdParty/AngelScript/source/as_config.h

@@ -846,7 +846,7 @@
 			#define THISCALL_PASS_OBJECT_POINTER_ON_THE_STACK
 			#define AS_X86
 			#undef AS_NO_THISCALL_FUNCTOR_METHOD
-		#elif defined(__LP64__) && !defined(__arm64__)
+		#elif defined(__LP64__) && !defined(__arm64__) && !defined(__aarch64__) && !defined(__ARM_ARCH)
 			#define AS_X64_GCC
 			#undef AS_NO_THISCALL_FUNCTOR_METHOD
 			#define HAS_128_BIT_PRIMITIVES
@@ -856,6 +856,16 @@
 			// STDCALL is not available on 64bit Linux
 			#undef STDCALL
 			#define STDCALL
+		#elif (defined(__arm64__) || defined(__aarch64__))
+			// AngelScript currently doesn't support native calling
+			// for 64bit ARM processors so it's necessary to turn on
+			// portability mode
+			#define AS_MAX_PORTABILITY
+
+			// STDCALL is not available on ARM
+			#undef STDCALL
+			#define STDCALL
+
 		#elif (defined(__ARMEL__) || defined(__arm__)) && !(defined(__ARM_ARCH_4__) || defined(__ARM_ARCH_4T__))
 			#define AS_ARM
 

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

@@ -52,7 +52,7 @@
 
 #if defined(_MSC_VER)
 #include <float.h>
-#elif !defined(ANDROID) && !defined(IOS) && !defined(RPI) && !defined(__EMSCRIPTEN__)
+#elif !defined(ANDROID) && !defined(IOS) && !defined(__ARM_ARCH) && !defined(__EMSCRIPTEN__)
 // From http://stereopsis.com/FPU.html
 
 #define FPU_CW_PREC_MASK        0x0300
@@ -102,7 +102,7 @@ static void GetCPUData(host_basic_info_data_t* data)
     infoCount = HOST_BASIC_INFO_COUNT;
     host_info(mach_host_self(), HOST_BASIC_INFO, (host_info_t)data, &infoCount);
 }
-#elif !defined(ANDROID) && !defined(RPI) && !defined(__EMSCRIPTEN__)
+#elif !defined(ANDROID) && !defined(__ARM_ARCH) && !defined(__EMSCRIPTEN__)
 
 static void GetCPUData(struct cpu_id_t* data)
 {
@@ -117,7 +117,7 @@ static void GetCPUData(struct cpu_id_t* data)
 
 void InitFPU()
 {
-#if !defined(URHO3D_LUAJIT) && !defined(ANDROID) && !defined(IOS) && !defined(RPI) && !defined(__x86_64__) && !defined(_M_AMD64) && !defined(__EMSCRIPTEN__)
+#if !defined(URHO3D_LUAJIT) && !defined(ANDROID) && !defined(IOS) && !defined(__ARM_ARCH) && !defined(__x86_64__) && !defined(_M_AMD64) && !defined(__EMSCRIPTEN__)
     // Make sure FPU is in round-to-nearest, single precision mode
     // This ensures Direct3D and OpenGL behave similarly, and all threads behave similarly
 #ifdef _MSC_VER
@@ -368,7 +368,7 @@ String GetPlatform()
 #endif
 }
 
-#if defined(ANDROID) || defined(RPI)
+#if defined(ANDROID) || defined(__ARM_ARCH)
 static unsigned GetArmCPUCount()
 {
     FILE* fp;
@@ -403,7 +403,7 @@ unsigned GetNumPhysicalCPUs()
 #else
     return data.physical_cpu;
 #endif
-#elif defined(ANDROID) || defined(RPI)
+#elif defined(ANDROID) || defined(__ARM_ARCH)
     return GetArmCPUCount();
 #elif defined(__EMSCRIPTEN__)
 #ifdef __EMSCRIPTEN_PTHREADS__
@@ -428,7 +428,7 @@ unsigned GetNumLogicalCPUs()
 #else
     return data.logical_cpu;
 #endif
-#elif defined(ANDROID) || defined (RPI)
+#elif defined(ANDROID) || defined (__ARM_ARCH)
     return GetArmCPUCount();
 #elif defined(__EMSCRIPTEN__)
 #ifdef __EMSCRIPTEN_PTHREADS__

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

@@ -93,7 +93,7 @@ Engine::Engine(Context* context) :
     timeStep_(0.0f),
     timeStepSmoothing_(2),
     minFps_(10),
-#if defined(ANDROID) || defined(IOS) || defined(RPI)
+#if defined(ANDROID) || defined(IOS) || defined(RPI) || defined(__ARM_ARCH)
     maxFps_(60),
     maxInactiveFps_(10),
     pauseMinimized_(true),

+ 1 - 1
Source/Urho3D/Graphics/GraphicsDefs.h

@@ -31,7 +31,7 @@ namespace Urho3D
 class Vector3;
 
 /// Graphics capability support level. Web platform (Emscripten) also uses OpenGL ES, but is considered a desktop platform capability-wise
-#if defined(ANDROID) || defined(IOS) || defined(RPI)
+#if defined(ANDROID) || defined(IOS) || defined(RPI) || defined(__ARM_ARCH)
 #define MOBILE_GRAPHICS
 #else
 #define DESKTOP_GRAPHICS

+ 3 - 2
Source/Urho3D/Graphics/OpenGL/OGLGraphicsImpl.h

@@ -26,7 +26,9 @@
 #include "../../Core/Timer.h"
 #include "../../Math/Color.h"
 
-#if defined(ANDROID) || defined (RPI) || defined (__EMSCRIPTEN__)
+#include <SDL/SDL.h>
+
+#if defined(ANDROID) || defined (RPI) || defined(SDL_VIDEO_OPENGL_ES2) || defined (__EMSCRIPTEN__)
 #include <GLES2/gl2.h>
 #include <GLES2/gl2ext.h>
 #elif defined(IOS)
@@ -61,7 +63,6 @@
 #define COMPRESSED_RGBA_PVRTC_2BPPV1_IMG 0x8c03
 #endif
 
-#include <SDL/SDL.h>
 
 namespace Urho3D
 {