瀏覽代碼

Updated Android toolchain to newer.
Reverted some of the hacks for CMake Android build.
Documented the work-in-progress CMake Android build path.

Lasse Öörni 12 年之前
父節點
當前提交
fa0ba1f2d8

File diff suppressed because it is too large
+ 758 - 300
Android/android.toolchain.cmake


+ 2 - 0
Docs/GettingStarted.dox

@@ -66,6 +66,8 @@ For a release build, use the "ant release" command instead of "ant debug" and fo
 
 
 By default the Android package for Urho3D is com.googlecode.urho3d. For a real application you must replace this with your own package name. The Urho3D activity subclasses the SDLActivity from org.libsdl.app package, whose name (or the JNI code from SDL library) does not have to be changed.
 By default the Android package for Urho3D is com.googlecode.urho3d. For a real application you must replace this with your own package name. The Urho3D activity subclasses the SDLActivity from org.libsdl.app package, whose name (or the JNI code from SDL library) does not have to be changed.
 
 
+There is also a CMake-based, work-in-progress method to build the Urho3D native code. To use, run cmake_android.bat or cmake_android.sh, then run make. After the native code build is finished, proceed to ant debug like above.
+
 \section Building_Ios iOS build process
 \section Building_Ios iOS build process
 
 
 Run cmake_ios.sh. This generates an Xcode project named Urho3D.xcodeproj.
 Run cmake_ios.sh. This generates an Xcode project named Urho3D.xcodeproj.

+ 4 - 0
Readme.txt

@@ -218,6 +218,10 @@ application you must replace this with your own package name. The Urho3D
 activity subclasses the SDLActivity from org.libsdl.app package, whose name
 activity subclasses the SDLActivity from org.libsdl.app package, whose name
 (or the JNI code from SDL library) does not have to be changed.
 (or the JNI code from SDL library) does not have to be changed.
 
 
+There is also a CMake-based, work-in-progress method to build the Urho3D native
+code. To use, run cmake_android.bat or cmake_android.sh, then run make. After 
+the native code build is finished, proceed to ant debug like above.
+
 
 
 iOS build process
 iOS build process
 -----------------
 -----------------

+ 1 - 1
ThirdParty/SDL/CMakeLists.txt

@@ -35,7 +35,7 @@ elseif (APPLE)
     )
     )
 elseif (ANDROID)
 elseif (ANDROID)
     file (GLOB SYS_C_FILES
     file (GLOB SYS_C_FILES
-        src/audio/android/*.c src/core/android/*.cpp src/joystick/android/*.c src/loadso/dlopen/*.c src/main/android/*.cpp
+        src/audio/android/*.c src/core/android/*.cpp src/joystick/android/*.c src/loadso/dlopen/*.c
         src/thread/pthread/*.c src/timer/unix/*.c src/video/android/*.c
         src/thread/pthread/*.c src/timer/unix/*.c src/video/android/*.c
     )
     )
 else ()
 else ()

+ 1 - 4
ThirdParty/SDL/include/SDL_atomic.h

@@ -19,8 +19,6 @@
   3. This notice may not be removed or altered from any source distribution.
   3. This notice may not be removed or altered from any source distribution.
 */
 */
 
 
-// Modified by Lasse Oorni for Urho3D
-
 /**
 /**
  * \file SDL_atomic.h
  * \file SDL_atomic.h
  *
  *
@@ -140,8 +138,7 @@ void _ReadWriteBarrier(void);
 /* Platform specific optimized versions of the atomic functions,
 /* Platform specific optimized versions of the atomic functions,
  * you can disable these by defining SDL_DISABLE_ATOMIC_INLINE
  * you can disable these by defining SDL_DISABLE_ATOMIC_INLINE
  */
  */
-// Urho3D: modified check
-#ifdef SDL_ATOMIC_DISABLED
+#if defined(SDL_ATOMIC_DISABLED) && SDL_ATOMIC_DISABLED
 #define SDL_DISABLE_ATOMIC_INLINE
 #define SDL_DISABLE_ATOMIC_INLINE
 #endif
 #endif
 #ifndef SDL_DISABLE_ATOMIC_INLINE
 #ifndef SDL_DISABLE_ATOMIC_INLINE

+ 0 - 5
ThirdParty/SDL/include/SDL_config_android.h

@@ -19,8 +19,6 @@
   3. This notice may not be removed or altered from any source distribution.
   3. This notice may not be removed or altered from any source distribution.
 */
 */
 
 
-// Modified by Lasse Oorni for Urho3D
-
 #ifndef _SDL_config_android_h
 #ifndef _SDL_config_android_h
 #define _SDL_config_android_h
 #define _SDL_config_android_h
 
 
@@ -135,7 +133,4 @@
 /* Enable system power support */
 /* Enable system power support */
 #define SDL_POWER_ANDROID 1
 #define SDL_POWER_ANDROID 1
 
 
-// Urho3D: disable atomic functions
-#define SDL_ATOMIC_DISABLED
-
 #endif /* _SDL_config_android_h */
 #endif /* _SDL_config_android_h */

+ 1 - 5
ThirdParty/SDL/src/atomic/SDL_spinlock.c

@@ -18,9 +18,6 @@
      misrepresented as being the original software.
      misrepresented as being the original software.
   3. This notice may not be removed or altered from any source distribution.
   3. This notice may not be removed or altered from any source distribution.
 */
 */
-
-// Modified by Lasse Oorni for Urho3D
-
 #include "SDL_config.h"
 #include "SDL_config.h"
 
 
 #include "SDL_atomic.h"
 #include "SDL_atomic.h"
@@ -36,8 +33,7 @@
 SDL_bool
 SDL_bool
 SDL_AtomicTryLock(SDL_SpinLock *lock)
 SDL_AtomicTryLock(SDL_SpinLock *lock)
 {
 {
-// Urho3D: modified check
-#ifdef SDL_ATOMIC_DISABLED
+#if SDL_ATOMIC_DISABLED
     /* Terrible terrible damage */
     /* Terrible terrible damage */
     static SDL_mutex *_spinlock_mutex;
     static SDL_mutex *_spinlock_mutex;
 
 

+ 21 - 0
ThirdParty/SDL/src/core/android/SDL_android.cpp

@@ -25,6 +25,7 @@
 #include "SDL_stdinc.h"
 #include "SDL_stdinc.h"
 #include "SDL_assert.h"
 #include "SDL_assert.h"
 #include "SDL_log.h"
 #include "SDL_log.h"
+#include "SDL_main.h"
 
 
 #ifdef __ANDROID__
 #ifdef __ANDROID__
 
 
@@ -224,6 +225,26 @@ extern "C" void Java_org_libsdl_app_SDLActivity_onNativeAccel(
     bHasNewData = true;
     bHasNewData = true;
 }
 }
 
 
+// Start up the SDL app
+// Urho3D: added passing user files directory from SDLActivity on startup
+extern "C" void Java_org_libsdl_app_SDLActivity_nativeInit(JNIEnv* env, jclass cls, jstring filesDir)
+{
+    /* This interface could expand with ABI negotiation, calbacks, etc. */
+    SDL_Android_Init(env, cls, filesDir);
+
+    SDL_SetMainReady();
+
+    /* Run the application code! */
+    int status;
+    char *argv[2];
+    argv[0] = strdup("SDL_app");
+    argv[1] = NULL;
+    status = SDL_main(1, argv);
+
+    /* Do not issue an exit or the whole application will terminate instead of just the SDL thread */
+    //exit(status);
+}
+
 // Low memory
 // Low memory
 extern "C" void Java_org_libsdl_app_SDLActivity_nativeLowMemory(
 extern "C" void Java_org_libsdl_app_SDLActivity_nativeLowMemory(
                                     JNIEnv* env, jclass cls)
                                     JNIEnv* env, jclass cls)

+ 1 - 23
ThirdParty/SDL/src/main/android/SDL_android_main.cpp

@@ -12,29 +12,7 @@
 *******************************************************************************/
 *******************************************************************************/
 #include <jni.h>
 #include <jni.h>
 
 
-// Called before SDL_main() to initialize JNI bindings in SDL library
-// Urho3D: added passing user files directory from SDLActivity on startup
-extern "C" void SDL_Android_Init(JNIEnv* env, jclass cls, jstring filesDir);
-
-// Start up the SDL app
-// Urho3D: added passing user files directory from SDLActivity on startup
-extern "C" void Java_org_libsdl_app_SDLActivity_nativeInit(JNIEnv* env, jclass cls, jstring filesDir)
-{
-    /* This interface could expand with ABI negotiation, calbacks, etc. */
-    SDL_Android_Init(env, cls, filesDir);
-
-    SDL_SetMainReady();
-
-    /* Run the application code! */
-    int status;
-    char *argv[2];
-    argv[0] = strdup("SDL_app");
-    argv[1] = NULL;
-    status = SDL_main(1, argv);
-
-    /* Do not issue an exit or the whole application will terminate instead of just the SDL thread */
-    //exit(status);
-}
+// Urho3D: function moved to SDL_android.cpp
 
 
 #endif /* __ANDROID__ */
 #endif /* __ANDROID__ */
 
 

+ 0 - 7
Urho3D/Urho3D.cpp

@@ -39,13 +39,6 @@
 
 
 #include "DebugNew.h"
 #include "DebugNew.h"
 
 
-#ifdef ANDROID
-// Hack: when compiling with the Android toolchain, the nativeInit function may be optimized out
-// Define a function pointer to it to ensure it stays linked
-extern "C" void Java_org_libsdl_app_SDLActivity_nativeInit();
-void (*ptr)(void) = &Java_org_libsdl_app_SDLActivity_nativeInit;
-#endif
-
 using namespace Urho3D;
 using namespace Urho3D;
 
 
 class Application : public Object
 class Application : public Object

+ 1 - 1
cmake_android.bat

@@ -1,2 +1,2 @@
 @del /F CMakeCache.txt
 @del /F CMakeCache.txt
-cmake -G "Unix Makefiles" -DANDROID=1 -DCMAKE_TOOLCHAIN_FILE=Android/android.toolchain.cmake -DLIBRARY_OUTPUT_PATH_ROOT=Android -DCMAKE_BUILD_TYPE=Release
+cmake -G "Unix Makefiles" -DANDROID=1 -DCMAKE_TOOLCHAIN_FILE=Android/android.toolchain.cmake -DLIBRARY_OUTPUT_PATH_ROOT=Android

+ 3 - 0
cmake_android.sh

@@ -0,0 +1,3 @@
+rm -f CMakeCache.txt
+cmake -G "Unix Makefiles" -DANDROID=1 -DCMAKE_TOOLCHAIN_FILE=Android/android.toolchain.cmake -DLIBRARY_OUTPUT_PATH_ROOT=Android $@
+sed -i.bak 's/OpenGL/Direct3D9/g' Doxyfile

Some files were not shown because too many files changed in this diff