Browse Source

Fix android build script

some fixes for android build script.
remove armv6,x86 options and add "android_arch" option for select
compiler architecture (armv7,armv6,x86)(default armv7).
add architecture suffix for output files and you can compile for several
architecture simultaneously.
example:
libgodot.android.opt.debug.armv7.so
libgodot.android.opt.debug.armv7.neon.so
libgodot.android.opt.debug.armv6.so
libgodot.android.opt.debug.x86.so
now we can enable/disable neon on armv7 with "android_neon" option
(default enable).
add "NDK_TARGET_X86" option for select toolchain to use for the NDK x86
(default x86-4.8).
change inputs model for "ndk_platform" option (default android-15).
fix armv7 ccflags.

with this patch, must put libgodot_android.so file in specific
architecture folder:

armv7 (default): <android-java>/libs/armeabi-v7a/
armv6: <android-java>/libs/armeabi/
x86: <android-java>/libs/x86/
masoud bh 10 years ago
parent
commit
867c95223d
2 changed files with 58 additions and 35 deletions
  1. 1 1
      drivers/webp/dsp/dsp.h
  2. 57 34
      platform/android/detect.py

+ 1 - 1
drivers/webp/dsp/dsp.h

@@ -29,7 +29,7 @@ extern "C" {
 #define WEBP_USE_SSE2
 #endif
 
-#if defined(__ANDROID__) && defined(__ARM_ARCH_7A__)
+#if defined(__ANDROID__) && defined(__ARM_ARCH_7A__) && defined(__ARM_NEON__)
 #define WEBP_ANDROID_NEON  // Android targets that might support NEON
 #endif
 

+ 57 - 34
platform/android/detect.py

@@ -20,15 +20,14 @@ def can_build():
 def get_opts():
 
 	return [
-	     ('ANDROID_NDK_ROOT', 'the path to Android NDK', os.environ.get("ANDROID_NDK_ROOT", 0)), 
-             ('NDK_TOOLCHAIN', 'toolchain to use for the NDK',"arm-eabi-4.4.0"), 	                      
-             #android 2.3       
-		 ('ndk_platform', 'compile for platform: (2.2,2.3)',"2.2"),
-		 ('NDK_TARGET', 'toolchain to use for the NDK',"arm-linux-androideabi-4.8"),
-		('android_stl','enable STL support in android port (for modules)','no'),
-		('armv6','compile for older phones running arm v6 (instead of v7+neon+smp)','no'),
-		 ('x86','Xompile for Android-x86','no')
-
+			('ANDROID_NDK_ROOT', 'the path to Android NDK', os.environ.get("ANDROID_NDK_ROOT", 0)),
+			('NDK_TOOLCHAIN', 'toolchain to use for the NDK',"arm-eabi-4.4.0"),
+			('NDK_TARGET', 'toolchain to use for the NDK',"arm-linux-androideabi-4.8"),
+			('NDK_TARGET_X86', 'toolchain to use for the NDK x86',"x86-4.8"),
+			('ndk_platform', 'compile for platform: (android-<api> , example: android-15)',"android-15"),
+			('android_arch', 'select compiler architecture: (armv7/armv6/x86)',"armv7"),
+			('android_neon','enable neon (armv7 only)',"yes"),
+			('android_stl','enable STL support in android port (for modules)',"no")
 	]
 
 def get_flags():
@@ -94,8 +93,13 @@ def configure(env):
 				
 		env['SPAWN'] = mySpawn
 	
-	if env['x86']=='yes':
-		env['NDK_TARGET']='x86-4.8'
+	ndk_platform=env['ndk_platform']
+
+	if env['android_arch'] not in ['armv7','armv6','x86']:
+		env['android_arch']='armv7'
+
+	if env['android_arch']=='x86':
+		env['NDK_TARGET']=env['NDK_TARGET_X86']
 
 	if env['PLATFORM'] == 'win32':
 		import methods
@@ -103,22 +107,28 @@ def configure(env):
 		#env['SPAWN'] = methods.win32_spawn
 		env['SHLIBSUFFIX'] = '.so'
 
-#	env.android_source_modules.append("../libs/apk_expansion")	
+	#env.android_source_modules.append("../libs/apk_expansion")	
 	env.android_source_modules.append("../libs/google_play_services")	
 	env.android_source_modules.append("../libs/downloader_library")	
 	env.android_source_modules.append("../libs/play_licensing")	
-	
-	ndk_platform=""
-
-	ndk_platform="android-15"
 
-	print("Godot Android!!!!!")
+	neon_text=""
+	if env["android_arch"]=="armv7" and env['android_neon']=='yes':
+		neon_text=" (with neon)"
+	print("Godot Android!!!!! ("+env['android_arch']+")"+neon_text)
 
 	env.Append(CPPPATH=['#platform/android'])
 	
-	if env['x86']=='yes':
-		env.extra_suffix=".x86"
-	
+	if env['android_arch']=='x86':
+		env.extra_suffix=".x86"+env.extra_suffix
+	elif env['android_arch']=='armv6':
+		env.extra_suffix=".armv6"+env.extra_suffix
+	elif env["android_arch"]=="armv7":
+		if env['android_neon']=='yes':
+			env.extra_suffix=".armv7.neon"+env.extra_suffix
+		else:
+			env.extra_suffix=".armv7"+env.extra_suffix
+
 	gcc_path=env["ANDROID_NDK_ROOT"]+"/toolchains/"+env["NDK_TARGET"]+"/prebuilt/";
 	
 	import os
@@ -136,7 +146,7 @@ def configure(env):
 	
 
 	env['ENV']['PATH'] = gcc_path+":"+env['ENV']['PATH']
-	if env['x86']=='yes':
+	if env['android_arch']=='x86':
 		env['CC'] = gcc_path+'/i686-linux-android-gcc'
 		env['CXX'] = gcc_path+'/i686-linux-android-g++'
 		env['AR'] = gcc_path+"/i686-linux-android-ar"
@@ -149,7 +159,7 @@ def configure(env):
 		env['RANLIB'] = gcc_path+"/arm-linux-androideabi-ranlib"
 		env['AS'] = gcc_path+"/arm-linux-androideabi-as"
 
-	if env['x86']=='yes':
+	if env['android_arch']=='x86':
 		env['ARCH'] = 'arch-x86'
 	else:
 		env['ARCH'] = 'arch-arm'
@@ -163,12 +173,18 @@ def configure(env):
 	env.Append(CPPPATH=[gcc_include])
 #	env['CCFLAGS'] = string.split('-DNO_THREADS -MMD -MP -MF -fpic -ffunction-sections -funwind-tables -fstack-protector -D__ARM_ARCH_5__ -D__ARM_ARCH_5T__ -D__ARM_ARCH_5E__ -D__ARM_ARCH_5TE__  -Wno-psabi -march=armv5te -mtune=xscale -msoft-float  -fno-exceptions -mthumb -fno-strict-aliasing -DANDROID -Wa,--noexecstack -DGLES2_ENABLED ')
 
-	if env['x86']=='yes':
+	env['neon_enabled']=False
+	if env['android_arch']=='x86':
 		env['CCFLAGS'] = string.split('-DNO_STATVFS -MMD -MP -MF -fpic -ffunction-sections -funwind-tables -fstack-protector -fvisibility=hidden -D__GLIBC__  -Wno-psabi -ftree-vectorize -funsafe-math-optimizations -fno-strict-aliasing -DANDROID -Wa,--noexecstack -DGLES2_ENABLED')
-	elif env["armv6"]!="no":
+	elif env["android_arch"]=="armv6":
 		env['CCFLAGS'] = string.split('-DNO_STATVFS -MMD -MP -MF -fpic -ffunction-sections -funwind-tables -fstack-protector -fvisibility=hidden -D__ARM_ARCH_6__ -D__GLIBC__  -Wno-psabi -march=armv6 -mfpu=vfp -mfloat-abi=softfp -funsafe-math-optimizations -fno-strict-aliasing -DANDROID -Wa,--noexecstack -DGLES2_ENABLED')
-	else:
-		env['CCFLAGS'] = string.split('-DNO_STATVFS -MMD -MP -MF -fpic -ffunction-sections -funwind-tables -fstack-protector -fvisibility=hidden -D__ARM_ARCH_7__ -D__GLIBC__  -Wno-psabi -march=armv6 -mfpu=neon -mfloat-abi=softfp -ftree-vectorize -funsafe-math-optimizations -fno-strict-aliasing -DANDROID -Wa,--noexecstack -DGLES2_ENABLED')
+	elif env["android_arch"]=="armv7":
+		env['CCFLAGS'] = string.split('-DNO_STATVFS -MMD -MP -MF -fpic -ffunction-sections -funwind-tables -fstack-protector -fvisibility=hidden -D__ARM_ARCH_7__ -D__ARM_ARCH_7A__ -D__GLIBC__  -Wno-psabi -march=armv7-a -mfloat-abi=softfp -ftree-vectorize -funsafe-math-optimizations -fno-strict-aliasing -DANDROID -Wa,--noexecstack -DGLES2_ENABLED')
+		if env['android_neon']=='yes':
+			env['neon_enabled']=True
+			env.Append(CCFLAGS=['-mfpu=neon','-D__ARM_NEON__'])
+		else:
+			env.Append(CCFLAGS=['-mfpu=vfpv3-d16'])
 
 	env.Append(LDPATH=[ld_path])
 	env.Append(LIBS=['OpenSLES'])
@@ -192,17 +208,22 @@ def configure(env):
 		env.Append(CCFLAGS=['-D_DEBUG', '-g1', '-Wall', '-O0', '-DDEBUG_ENABLED'])
 		env.Append(CPPFLAGS=['-DDEBUG_MEMORY_ALLOC'])
 
-	if env["armv6"] == "no" and env['x86'] != 'yes':
-		env['neon_enabled']=True
-
 	env.Append(CPPFLAGS=['-DANDROID_ENABLED', '-DUNIX_ENABLED', '-DNO_FCNTL','-DMPC_FIXED_POINT'])
 #	env.Append(CPPFLAGS=['-DANDROID_ENABLED', '-DUNIX_ENABLED','-DMPC_FIXED_POINT'])
 
 	if (env['android_stl']=='yes'):
 		#env.Append(CCFLAGS=[env["ANDROID_NDK_ROOT"]+"/sources/cxx-stl/system/include"])
-		env.Append(CPPPATH=[env["ANDROID_NDK_ROOT"]+"/sources/cxx-stl/gnu-libstdc++/4.4.3/include"])
-		env.Append(CPPPATH=[env["ANDROID_NDK_ROOT"]+"/sources/cxx-stl/gnu-libstdc++/4.4.3/libs/armeabi/include"])
-		env.Append(LIBPATH=[env["ANDROID_NDK_ROOT"]+"/sources/cxx-stl/gnu-libstdc++/4.4.3/libs/armeabi"])
+		env.Append(CPPPATH=[env["ANDROID_NDK_ROOT"]+"/sources/cxx-stl/gnu-libstdc++/4.8/include"])
+		if env['android_arch']=='x86':
+			env.Append(CPPPATH=[env["ANDROID_NDK_ROOT"]+"/sources/cxx-stl/gnu-libstdc++/4.8/libs/x86/include"])
+			env.Append(LIBPATH=[env["ANDROID_NDK_ROOT"]+"/sources/cxx-stl/gnu-libstdc++/4.8/libs/x86"])
+		elif env['android_arch']=='armv6':
+			env.Append(CPPPATH=[env["ANDROID_NDK_ROOT"]+"/sources/cxx-stl/gnu-libstdc++/4.8/libs/armeabi/include"])
+			env.Append(LIBPATH=[env["ANDROID_NDK_ROOT"]+"/sources/cxx-stl/gnu-libstdc++/4.8/libs/armeabi"])
+		elif env["android_arch"]=="armv7":
+			env.Append(CPPPATH=[env["ANDROID_NDK_ROOT"]+"/sources/cxx-stl/gnu-libstdc++/4.8/libs/armeabi-v7a/include"])
+			env.Append(LIBPATH=[env["ANDROID_NDK_ROOT"]+"/sources/cxx-stl/gnu-libstdc++/4.8/libs/armeabi-v7a"])
+		
 		env.Append(LIBS=["gnustl_static","supc++"])
 		env.Append(CPPPATH=[env["ANDROID_NDK_ROOT"]+"/sources/cpufeatures"])
 
@@ -213,10 +234,12 @@ def configure(env):
 
 		env.Append(CPPPATH=[env["ANDROID_NDK_ROOT"]+"/sources/cxx-stl/gabi++/include"])
 		env.Append(CPPPATH=[env["ANDROID_NDK_ROOT"]+"/sources/cpufeatures"])
-		if env['x86']=='yes':
+		if env['android_arch']=='x86':
 			env.Append(LIBPATH=[env["ANDROID_NDK_ROOT"]+"/sources/cxx-stl/gabi++/libs/x86"])
-		else:
+		elif env["android_arch"]=="armv6":
 			env.Append(LIBPATH=[env["ANDROID_NDK_ROOT"]+"/sources/cxx-stl/gabi++/libs/armeabi"])
+		elif env["android_arch"]=="armv7":
+			env.Append(LIBPATH=[env["ANDROID_NDK_ROOT"]+"/sources/cxx-stl/gabi++/libs/armeabi-v7a"])
 		env.Append(LIBS=['gabi++_static'])
 		env.Append(CCFLAGS=["-fno-exceptions",'-DNO_SAFE_CAST'])