Browse Source

Add initial support for 64-bit Android ABIs.

Yao Wei Tjong 姚伟忠 11 years ago
parent
commit
eda52984ac
5 changed files with 24 additions and 18 deletions
  1. 2 2
      Docs/GettingStarted.dox
  2. 9 12
      Rakefile
  3. 5 2
      Readme.txt
  4. 4 0
      Source/CMake/Modules/Urho3D-CMake-common.cmake
  5. 4 2
      Source/CMakeLists.txt

+ 2 - 2
Docs/GettingStarted.dox

@@ -81,7 +81,7 @@ 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.
 
 
-Note that the native code is built by default for armeabi-v7a ABI. To make your program compatible also with old Android devices, build also an armeabi version by executing the CMake batch file again with the parameter -DANDROID_ABI=armeabi added, then execute make again in the build directory.
+Note that the native code is built by default for armeabi-v7a ABI. To make your program compatible also with old Android devices, build also an armeabi version by executing the CMake batch file again with the build option "-DANDROID_ABI=armeabi" added, then execute make again in the build directory. Similarly, the native code can be built using 64-bit ABI by changing the value of this build option. See \ref Build_Options "Build options" for all the possible values.
 
 
 You can also build and deploy using Eclipse IDE with ADT plugin. To do that, after setting the ANDROID_NDK environment variable then run cmake_eclipse.sh. Import "Existing Android Code into Workspace" from the CMake generated Eclipse's project found in the android-Build directory. Switch Eclipse IDE to use Java Perspective. Update project properties to choose the desired Android API target and that's it. Just choose "Run" to let ADT automatically build and deploy the application to Android (virtual) device.
 You can also build and deploy using Eclipse IDE with ADT plugin. To do that, after setting the ANDROID_NDK environment variable then run cmake_eclipse.sh. Import "Existing Android Code into Workspace" from the CMake generated Eclipse's project found in the android-Build directory. Switch Eclipse IDE to use Java Perspective. Update project properties to choose the desired Android API target and that's it. Just choose "Run" to let ADT automatically build and deploy the application to Android (virtual) device.
 
 
@@ -175,7 +175,7 @@ A number of build options can be defined explicitly when invoking the above cmak
 |CMAKE_BUILD_TYPE     |*|Specify CMake build configuration to be generated (Makefile generator only), possible values are Release (\*default), Debug, and RelWithDebInfo|
 |CMAKE_BUILD_TYPE     |*|Specify CMake build configuration to be generated (Makefile generator only), possible values are Release (\*default), Debug, and RelWithDebInfo|
 |CMAKE_OSX_DEPLOYMENT_TARGET|-|Specify Mac OS X deployment target (OSX build only); default to current running OS X if not specified|
 |CMAKE_OSX_DEPLOYMENT_TARGET|-|Specify Mac OS X deployment target (OSX build only); default to current running OS X if not specified|
 |IPHONEOS_DEPLOYMENT_TARGET|-|Specify iPhone OS deployment target (iOS build only); default to latest installed iOS SDK if not specified|
 |IPHONEOS_DEPLOYMENT_TARGET|-|Specify iPhone OS deployment target (iOS build only); default to latest installed iOS SDK if not specified|
-|ANDROID_ABI          |*|Specify target ABI (Android build only), possible values are armeabi-v7a (\*default) and armeabi|
+|ANDROID_ABI          |*|Specify target ABI (Android build only), possible values are armeabi, armeabi-v7a (\*default), armeabi-v7a with NEON, armeabi-v7a with VFPV3, armeabi-v6 with VFP, arm64-v8a, x86, and x86_64|
 
 
 Note that build option values specified via command line are cached by CMake. The cached values will be used by CMake in the subsequent invocation. That is, the same build options are not required to be specified again and again. Once a non-default build option value is being cached, it can only be reverted back to its default value by explicitly setting it via command line. That is, simply by NOT passing the corresponding build option would not work. One way to revert all the build options to their default values is by clearing the CMake cache by calling cmake_clean.bat or cmake_clean.sh.
 Note that build option values specified via command line are cached by CMake. The cached values will be used by CMake in the subsequent invocation. That is, the same build options are not required to be specified again and again. Once a non-default build option value is being cached, it can only be reverted back to its default value by explicitly setting it via command line. That is, simply by NOT passing the corresponding build option would not work. One way to revert all the build options to their default values is by clearing the CMake cache by calling cmake_clean.bat or cmake_clean.sh.
 
 

+ 9 - 12
Rakefile

@@ -51,7 +51,7 @@ task :scaffolding do
   end
   end
 end
 end
 
 
-# Usage: rake android [intent=.SampleLauncher] [package=com.github.urho3d] [success_indicator='Initialized engine'] [payload='input tap 10 200'] [timeout=30] [api=19] [avd=test] [retries=60] [retry_interval=10]
+# Usage: rake android [intent=.SampleLauncher] [package=com.github.urho3d] [success_indicator='Initialized engine'] [payload='input tap 10 200'] [timeout=30] [api=19] [abi=armeabi-v7a] [avd=test] [retries=60] [retry_interval=10]
 desc 'Test run already installed APK in Android (virtual) device, default to Urho3D Samples APK if no parameter is given'
 desc 'Test run already installed APK in Android (virtual) device, default to Urho3D Samples APK if no parameter is given'
 task :android do
 task :android do
   intent = ENV['intent'] || '.SampleLauncher'
   intent = ENV['intent'] || '.SampleLauncher'
@@ -60,10 +60,11 @@ task :android do
   payload = ENV['payload'] || (intent == '.SampleLauncher' ? 'input tap 10 200' : '')
   payload = ENV['payload'] || (intent == '.SampleLauncher' ? 'input tap 10 200' : '')
   timeout = ENV['timeout'] || 30
   timeout = ENV['timeout'] || 30
   api = ENV['api'] || 19
   api = ENV['api'] || 19
+  abi = ENV['abi'] || 'armeabi-v7a'
   avd = ENV['avd'] || 'test'
   avd = ENV['avd'] || 'test'
   retries = ENV['retries'] || 60 # Roughly equals to 10 minutes wait with 10 seconds interval
   retries = ENV['retries'] || 60 # Roughly equals to 10 minutes wait with 10 seconds interval
   retry_interval = ENV['retry_interval'] || 10 # seconds
   retry_interval = ENV['retry_interval'] || 10 # seconds
-  android_prepare_device api, avd or abort 'Failed to prepare Android (virtual) device for test run'
+  android_prepare_device api, abi, avd or abort 'Failed to prepare Android (virtual) device for test run'
   android_wait_for_device retries, retry_interval or abort 'Failed to start Android (virtual) device'
   android_wait_for_device retries, retry_interval or abort 'Failed to start Android (virtual) device'
   android_test_run intent, package, success_indicator, payload, timeout or abort "Failed to test run #{package}/#{intent}, make sure the APK has been installed"
   android_test_run intent, package, success_indicator, payload, timeout or abort "Failed to test run #{package}/#{intent}, make sure the APK has been installed"
 end
 end
@@ -87,6 +88,7 @@ task :ci do
   # Define the build option string only when the override environment variable is given
   # Define the build option string only when the override environment variable is given
   $build_options = "-DURHO3D_64BIT=#{ENV['URHO3D_64BIT']}" if ENV['URHO3D_64BIT']
   $build_options = "-DURHO3D_64BIT=#{ENV['URHO3D_64BIT']}" if ENV['URHO3D_64BIT']
   $build_options = "#{$build_options} -DURHO3D_OPENGL=#{ENV['URHO3D_OPENGL']}" if ENV['URHO3D_OPENGL']
   $build_options = "#{$build_options} -DURHO3D_OPENGL=#{ENV['URHO3D_OPENGL']}" if ENV['URHO3D_OPENGL']
+  $build_options = "#{$build_options} -DANDROID_ABI=#{ENV['ABI']}" if ENV['ABI']
   if ENV['XCODE']
   if ENV['XCODE']
     # xctool or xcodebuild
     # xctool or xcodebuild
     xcode_ci
     xcode_ci
@@ -184,9 +186,6 @@ task :ci_package_upload do
     xcode_build(ENV['IOS'], "#{platform_prefix}Build/Urho3D.xcodeproj", 'package') or abort 'Failed to make binary package'
     xcode_build(ENV['IOS'], "#{platform_prefix}Build/Urho3D.xcodeproj", 'package') or abort 'Failed to make binary package'
   else
   else
     if ENV['ANDROID']
     if ENV['ANDROID']
-      # Build Android package consisting of both armeabi-v7a and armeabi ABIs
-      system 'echo Reconfigure and rebuild Urho3D project using armeabi ABI'
-      system "SKIP_NATIVE=1 ./cmake_gcc.sh -DANDROID_ABI=armeabi && cd #{platform_prefix}Build && make -j$NUMJOBS" or abort 'Failed to reconfigure and rebuild for armeabi'
       system "cd #{platform_prefix}Build && android update project -p . -t $( android list target |grep android-$API |cut -d ' ' -f2 ) && ant debug" or abort 'Failed to make Urho3D Samples APK'
       system "cd #{platform_prefix}Build && android update project -p . -t $( android list target |grep android-$API |cut -d ' ' -f2 ) && ant debug" or abort 'Failed to make Urho3D Samples APK'
     end
     end
     system "cd #{platform_prefix}Build && make package" or abort 'Failed to make binary package'
     system "cd #{platform_prefix}Build && make package" or abort 'Failed to make binary package'
@@ -307,10 +306,8 @@ def makefile_ci
   end
   end
   system "./cmake_gcc.sh -DURHO3D_LIB_TYPE=$URHO3D_LIB_TYPE #{$build_options} -DURHO3D_LUA#{jit}=1 #{amalg} -DURHO3D_SAMPLES=1 -DURHO3D_TOOLS=1 -DURHO3D_EXTRAS=1 -DURHO3D_TESTING=#{$testing} -DCMAKE_BUILD_TYPE=#{$configuration}" or abort 'Failed to configure Urho3D library build'
   system "./cmake_gcc.sh -DURHO3D_LIB_TYPE=$URHO3D_LIB_TYPE #{$build_options} -DURHO3D_LUA#{jit}=1 #{amalg} -DURHO3D_SAMPLES=1 -DURHO3D_TOOLS=1 -DURHO3D_EXTRAS=1 -DURHO3D_TESTING=#{$testing} -DCMAKE_BUILD_TYPE=#{$configuration}" or abort 'Failed to configure Urho3D library build'
   if ENV['ANDROID']
   if ENV['ANDROID']
-    # The AVD on Travis-CI does not have enough memory for STATIC lib installation, so only prepare device for SHARED lib test run
-    android_test = !ENV['PACKAGE_UPLOAD'] && (ENV['URHO3D_LIB_TYPE'] == 'SHARED' || !ENV['CI'])
-    if android_test
-      android_prepare_device ENV['API'] or abort 'Failed to prepare Android (virtual) device for test run'
+    if ENV['AVD']
+      android_prepare_device ENV['API'], ENV['ABI'], ENV['AVD'] or abort 'Failed to prepare Android (virtual) device for test run'
     end
     end
     # LuaJIT on Android build requires tolua++ and buildvm-android tools to be built natively first
     # LuaJIT on Android build requires tolua++ and buildvm-android tools to be built natively first
     system "cd Build/ThirdParty/toluapp/src/bin && make -j$NUMJOBS" or abort 'Failed to build tolua++ tool'
     system "cd Build/ThirdParty/toluapp/src/bin && make -j$NUMJOBS" or abort 'Failed to build tolua++ tool'
@@ -342,7 +339,7 @@ def makefile_ci
   scaffolding "#{platform_prefix}Build/generated/externallib"
   scaffolding "#{platform_prefix}Build/generated/externallib"
   system "URHO3D_HOME=`pwd`; export URHO3D_HOME && cd #{platform_prefix}Build/generated/externallib && echo '\nUsing Urho3D as external library in external project' && ./cmake_gcc.sh #{$build_options} -DURHO3D_LUA#{jit}=1 -DURHO3D_TESTING=#{$testing} -DCMAKE_BUILD_TYPE=#{$configuration} && cd #{platform_prefix}Build && make -j$NUMJOBS #{test}" or abort 'Failed to configure/build/test temporary project using Urho3D as external library' 
   system "URHO3D_HOME=`pwd`; export URHO3D_HOME && cd #{platform_prefix}Build/generated/externallib && echo '\nUsing Urho3D as external library in external project' && ./cmake_gcc.sh #{$build_options} -DURHO3D_LUA#{jit}=1 -DURHO3D_TESTING=#{$testing} -DCMAKE_BUILD_TYPE=#{$configuration} && cd #{platform_prefix}Build && make -j$NUMJOBS #{test}" or abort 'Failed to configure/build/test temporary project using Urho3D as external library' 
   # Make, deploy, and test run Android APK in an Android (virtual) device
   # Make, deploy, and test run Android APK in an Android (virtual) device
-  if android_test
+  if ENV['AVD']
     system "cd #{platform_prefix}Build && android update project -p . -t $( android list target |grep android-$API |cut -d ' ' -f2 ) && ant debug" or abort 'Failed to make Urho3D Samples APK'
     system "cd #{platform_prefix}Build && android update project -p . -t $( android list target |grep android-$API |cut -d ' ' -f2 ) && ant debug" or abort 'Failed to make Urho3D Samples APK'
     android_wait_for_device # We either success or die trying, killed by Travis-CI due 10 minutes no-output timeout which is perfect for this case
     android_wait_for_device # We either success or die trying, killed by Travis-CI due 10 minutes no-output timeout which is perfect for this case
     system "cd #{platform_prefix}Build && ant installd" or abort 'Failed to deploy Urho3D Samples APK'
     system "cd #{platform_prefix}Build && ant installd" or abort 'Failed to deploy Urho3D Samples APK'
@@ -350,12 +347,12 @@ def makefile_ci
   end
   end
 end
 end
 
 
-def android_prepare_device api, name = 'test'
+def android_prepare_device api, abi = 'armeabi-v7a', name = 'test'
   system 'if ! ps |grep -cq adb; then adb start-server; fi'
   system 'if ! ps |grep -cq adb; then adb start-server; fi'
   if `adb devices |tail -n +2 |head -1`.chomp.empty?
   if `adb devices |tail -n +2 |head -1`.chomp.empty?
     # Don't have any (virtual) device attached, try to attach the named device (create the named device as AVD if necessary)
     # Don't have any (virtual) device attached, try to attach the named device (create the named device as AVD if necessary)
     if !system "android list avd |grep -cq 'Name: #{name}$'"
     if !system "android list avd |grep -cq 'Name: #{name}$'"
-      system "echo 'no' |android create avd -n #{name} -t android-#{api}" or abort "Failed to create '#{name}' Android virtual device"
+      system "echo 'no' |android create avd -n #{name} -t android-#{api} --abi #{abi}" or abort "Failed to create '#{name}' Android virtual device"
     end
     end
     system "if [ $CI ]; then export OPTS='-no-skin -no-audio -no-window -no-boot-anim -gpu off'; else export OPTS='-gpu on'; fi; emulator -avd #{name} $OPTS &"
     system "if [ $CI ]; then export OPTS='-no-skin -no-audio -no-window -no-boot-anim -gpu off'; else export OPTS='-gpu on'; fi; emulator -avd #{name} $OPTS &"
   end
   end

+ 5 - 2
Readme.txt

@@ -286,7 +286,8 @@ activity subclasses the SDLActivity from org.libsdl.app package, whose name
 Note that the native code is built by default for armeabi-v7a ABI. To make your
 Note that the native code is built by default for armeabi-v7a ABI. To make your
 program compatible also with old Android devices, build also an armeabi version
 program compatible also with old Android devices, build also an armeabi version
 by executing the CMake batch file again with the parameter -DANDROID_ABI=armeabi
 by executing the CMake batch file again with the parameter -DANDROID_ABI=armeabi
-added, then execute make again in the build directory.
+added, then execute make again in the build directory. See "Build options" for
+all the possible values
 
 
 You can also build and deploy using Eclipse IDE with ADT plugin. To do that,
 You can also build and deploy using Eclipse IDE with ADT plugin. To do that,
 after setting the ANDROID_NDK environment variable then run cmake_eclipse.sh.
 after setting the ANDROID_NDK environment variable then run cmake_eclipse.sh.
@@ -496,7 +497,9 @@ cmake_xxxx batch files or shell scripts.
 |IPHONEOS_            |-|Specify iPhone OS deployment target (iOS build only); |
 |IPHONEOS_            |-|Specify iPhone OS deployment target (iOS build only); |
 | DEPLOYMENT_TARGET   | | default to latest installed iOS SDK if not specified |
 | DEPLOYMENT_TARGET   | | default to latest installed iOS SDK if not specified |
 |ANDROID_ABI          |*|Specify target ABI (Android build only), possible     |
 |ANDROID_ABI          |*|Specify target ABI (Android build only), possible     |
-|                     | | values are armeabi-v7a (*default) and armeabi        |
+|                     | | values are armeabi, armeabi-v7a (*default),          |
+|                     | | armeabi-v7a with NEON, armeabi-v7a with VFPV3,       |
+|                     | | armeabi-v6 with VFP, arm64-v8a, x86, and x86_64      |
 |---------------------|-|------------------------------------------------------|
 |---------------------|-|------------------------------------------------------|
 
 
 Note that build option values specified via command line are cached by CMake.
 Note that build option values specified via command line are cached by CMake.

+ 4 - 0
Source/CMake/Modules/Urho3D-CMake-common.cmake

@@ -94,6 +94,10 @@ if (ANDROID)
     set (ANDROID_ABI armeabi-v7a CACHE STRING "Specify ABI for native code (Android build only), possible values are armeabi-v7a (default) and armeabi")
     set (ANDROID_ABI armeabi-v7a CACHE STRING "Specify ABI for native code (Android build only), possible values are armeabi-v7a (default) and armeabi")
 else ()
 else ()
     unset (ANDROID_ABI CACHE)
     unset (ANDROID_ABI CACHE)
+    if (ANDROID_ABI)
+        # Just reference it to suppress "unused variable" CMake warning on non-Android project
+        # Due to the design of cmake_gcc.sh currently, the script can be used to configure/generate Android project and other non-Android projects in one go
+    endif ()
 endif ()
 endif ()
 
 
 # Set the build type if not explicitly set, for single-configuration generator only
 # Set the build type if not explicitly set, for single-configuration generator only

+ 4 - 2
Source/CMakeLists.txt

@@ -122,7 +122,9 @@ if (URHO3D_64BIT)
 endif ()
 endif ()
 set (CPACK_SYSTEM_NAME ${CPACK_SYSTEM_NAME}-${URHO3D_LIB_TYPE})
 set (CPACK_SYSTEM_NAME ${CPACK_SYSTEM_NAME}-${URHO3D_LIB_TYPE})
 if (WIN32 AND NOT URHO3D_OPENGL)
 if (WIN32 AND NOT URHO3D_OPENGL)
-    set (CPACK_SYSTEM_NAME ${CPACK_SYSTEM_NAME}-D3D)
+    set (CPACK_SYSTEM_NAME ${CPACK_SYSTEM_NAME}-D3D)    # Stands for Direct 3D
+elseif (ANDROID AND X86)    # Take advantage of Android toolchain setting X86 variable to true for both 'x86' and 'x86_64' ABIs
+    set (CPACK_SYSTEM_NAME ${CPACK_SYSTEM_NAME}-IA)     # Stands for Intel Architecture
 endif ()
 endif ()
 if ("$ENV{RELEASE_TAG}" STREQUAL "")
 if ("$ENV{RELEASE_TAG}" STREQUAL "")
     set (CPACK_SYSTEM_NAME ${CPACK_SYSTEM_NAME}-snapshot)
     set (CPACK_SYSTEM_NAME ${CPACK_SYSTEM_NAME}-snapshot)
@@ -130,7 +132,7 @@ endif ()
 include (CPack)
 include (CPack)
 
 
 # Setup RPATH settings
 # Setup RPATH settings
-if (NOT WIN32)
+if (NOT WIN32 AND NOT ANDROID)
     # Add RPATH entries when building
     # Add RPATH entries when building
     set (CMAKE_SKIP_BUILD_RPATH FALSE)
     set (CMAKE_SKIP_BUILD_RPATH FALSE)
     # But don't set them yet in the build tree
     # But don't set them yet in the build tree