2014-02-10 02:10:30 +01:00
|
|
|
import os
|
|
|
|
import sys
|
|
|
|
import string
|
|
|
|
import platform
|
|
|
|
|
|
|
|
def is_active():
|
|
|
|
return True
|
|
|
|
|
|
|
|
def get_name():
|
|
|
|
return "Android"
|
|
|
|
|
|
|
|
def can_build():
|
|
|
|
|
|
|
|
import os
|
|
|
|
if (not os.environ.has_key("ANDROID_NDK_ROOT")):
|
|
|
|
return False
|
2014-03-14 02:57:24 +01:00
|
|
|
|
2014-02-10 02:10:30 +01:00
|
|
|
return True
|
|
|
|
|
|
|
|
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"),
|
2015-03-31 19:58:52 +02:00
|
|
|
('NDK_TARGET', 'toolchain to use for the NDK',"arm-linux-androideabi-4.9"),
|
2014-05-28 08:42:33 +02:00
|
|
|
('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'),
|
2014-10-07 06:31:49 +02:00
|
|
|
('x86','Xompile for Android-x86','no')
|
2014-02-10 02:10:30 +01:00
|
|
|
|
|
|
|
]
|
|
|
|
|
|
|
|
def get_flags():
|
|
|
|
|
|
|
|
return [
|
|
|
|
('tools', 'no'),
|
|
|
|
('nedmalloc', 'no'),
|
|
|
|
('builtin_zlib', 'no'),
|
2014-04-29 02:56:43 +02:00
|
|
|
('openssl','builtin'), #use builtin openssl
|
2014-09-15 16:33:30 +02:00
|
|
|
('theora','no'), #use builtin openssl
|
|
|
|
|
2014-04-29 02:56:43 +02:00
|
|
|
]
|
2014-02-10 02:10:30 +01:00
|
|
|
|
|
|
|
|
|
|
|
def create(env):
|
|
|
|
tools = env['TOOLS']
|
|
|
|
if "mingw" in tools:
|
|
|
|
tools.remove('mingw')
|
|
|
|
if "applelink" in tools:
|
|
|
|
tools.remove("applelink")
|
|
|
|
env.Tool('gcc')
|
|
|
|
return env.Clone(tools=tools);
|
|
|
|
|
|
|
|
def configure(env):
|
|
|
|
|
2014-05-28 08:42:33 +02:00
|
|
|
if env['x86']=='yes':
|
|
|
|
env['NDK_TARGET']='x86-4.8'
|
|
|
|
|
2014-02-10 02:10:30 +01:00
|
|
|
if env['PLATFORM'] == 'win32':
|
|
|
|
import methods
|
|
|
|
env.Tool('gcc')
|
|
|
|
env['SPAWN'] = methods.win32_spawn
|
2014-10-08 08:37:04 +02:00
|
|
|
env['SHLIBSUFFIX'] = '.so'
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2014-08-02 03:10:38 +02:00
|
|
|
# env.android_source_modules.append("../libs/apk_expansion")
|
2014-04-15 03:43:44 +02:00
|
|
|
env.android_source_modules.append("../libs/google_play_services")
|
2014-08-02 03:10:38 +02:00
|
|
|
env.android_source_modules.append("../libs/downloader_library")
|
|
|
|
env.android_source_modules.append("../libs/play_licensing")
|
|
|
|
|
2014-02-10 02:10:30 +01:00
|
|
|
ndk_platform=""
|
|
|
|
|
2014-03-14 02:57:24 +01:00
|
|
|
ndk_platform="android-15"
|
2014-02-10 02:10:30 +01:00
|
|
|
|
|
|
|
print("Godot Android!!!!!")
|
|
|
|
|
|
|
|
env.Append(CPPPATH=['#platform/android'])
|
|
|
|
|
2014-05-28 08:42:33 +02:00
|
|
|
if env['x86']=='yes':
|
2014-10-07 06:31:49 +02:00
|
|
|
env.extra_suffix=".x86"
|
2014-02-10 02:10:30 +01:00
|
|
|
|
|
|
|
gcc_path=env["ANDROID_NDK_ROOT"]+"/toolchains/"+env["NDK_TARGET"]+"/prebuilt/";
|
|
|
|
|
|
|
|
import os
|
|
|
|
if (sys.platform.find("linux")==0):
|
|
|
|
if (platform.architecture()[0]=='64bit' or os.path.isdir(gcc_path+"linux-x86_64/bin")): # check was not working
|
|
|
|
gcc_path=gcc_path+"/linux-x86_64/bin"
|
|
|
|
else:
|
|
|
|
gcc_path=gcc_path+"/linux-x86/bin"
|
|
|
|
elif (sys.platform=="darwin"):
|
|
|
|
gcc_path=gcc_path+"/darwin-x86_64/bin" #this may be wrong
|
|
|
|
env['SHLINKFLAGS'][1] = '-shared'
|
|
|
|
elif (os.name=="nt"):
|
2015-03-31 19:58:52 +02:00
|
|
|
gcc_path=gcc_path+"/windows-x86_64/bin" #this may be wrong
|
2014-02-10 02:10:30 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
env['ENV']['PATH'] = gcc_path+":"+env['ENV']['PATH']
|
2014-05-28 08:42:33 +02:00
|
|
|
if env['x86']=='yes':
|
|
|
|
env['CC'] = gcc_path+'/i686-linux-android-gcc'
|
|
|
|
env['CXX'] = gcc_path+'/i686-linux-android-g++'
|
|
|
|
env['AR'] = gcc_path+"/i686-linux-android-ar"
|
|
|
|
env['RANLIB'] = gcc_path+"/i686-linux-android-ranlib"
|
|
|
|
env['AS'] = gcc_path+"/i686-linux-android-as"
|
|
|
|
else:
|
|
|
|
env['CC'] = gcc_path+'/arm-linux-androideabi-gcc'
|
|
|
|
env['CXX'] = gcc_path+'/arm-linux-androideabi-g++'
|
|
|
|
env['AR'] = gcc_path+"/arm-linux-androideabi-ar"
|
|
|
|
env['RANLIB'] = gcc_path+"/arm-linux-androideabi-ranlib"
|
|
|
|
env['AS'] = gcc_path+"/arm-linux-androideabi-as"
|
|
|
|
|
|
|
|
if env['x86']=='yes':
|
|
|
|
env['ARCH'] = 'arch-x86'
|
|
|
|
else:
|
|
|
|
env['ARCH'] = 'arch-arm'
|
2014-02-10 02:10:30 +01:00
|
|
|
|
|
|
|
import string
|
|
|
|
#include path
|
2014-05-28 08:42:33 +02:00
|
|
|
gcc_include=env["ANDROID_NDK_ROOT"]+"/platforms/"+ndk_platform+"/"+env['ARCH'] +"/usr/include"
|
|
|
|
ld_sysroot=env["ANDROID_NDK_ROOT"]+"/platforms/"+ndk_platform+"/"+env['ARCH']
|
2014-02-10 02:10:30 +01:00
|
|
|
#glue_include=env["ANDROID_NDK_ROOT"]+"/sources/android/native_app_glue"
|
2014-05-28 08:42:33 +02:00
|
|
|
ld_path=env["ANDROID_NDK_ROOT"]+"/platforms/"+ndk_platform+"/"+env['ARCH']+"/usr/lib"
|
2014-02-10 02:10:30 +01:00
|
|
|
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 ')
|
2014-10-07 06:31:49 +02:00
|
|
|
|
2014-05-28 08:42:33 +02:00
|
|
|
if env['x86']=='yes':
|
2015-01-10 21:35:26 +01:00
|
|
|
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')
|
2014-05-28 08:42:33 +02:00
|
|
|
elif env["armv6"]!="no":
|
2015-01-10 21:35:26 +01:00
|
|
|
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')
|
2014-02-10 02:10:30 +01:00
|
|
|
else:
|
2015-01-10 21:35:26 +01:00
|
|
|
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')
|
2014-02-10 02:10:30 +01:00
|
|
|
|
|
|
|
env.Append(LDPATH=[ld_path])
|
2014-03-14 02:57:24 +01:00
|
|
|
env.Append(LIBS=['OpenSLES'])
|
2014-02-10 02:10:30 +01:00
|
|
|
# env.Append(LIBS=['c','m','stdc++','log','EGL','GLESv1_CM','GLESv2','OpenSLES','supc++','android'])
|
|
|
|
if (env["ndk_platform"]!="2.2"):
|
|
|
|
env.Append(LIBS=['EGL','OpenSLES','android'])
|
|
|
|
env.Append(LIBS=['c','m','stdc++','log','GLESv1_CM','GLESv2', 'z'])
|
|
|
|
|
|
|
|
env["LINKFLAGS"]= string.split(" -g --sysroot="+ld_sysroot+" -Wl,--no-undefined -Wl,-z,noexecstack ")
|
|
|
|
env.Append(LINKFLAGS=["-Wl,-soname,libgodot_android.so"])
|
|
|
|
|
|
|
|
if (env["target"]=="release"):
|
|
|
|
|
|
|
|
env.Append(CCFLAGS=['-O2', '-ffast-math','-fomit-frame-pointer'])
|
|
|
|
|
|
|
|
elif (env["target"]=="release_debug"):
|
|
|
|
|
|
|
|
env.Append(CCFLAGS=['-O2', '-ffast-math','-DDEBUG_ENABLED'])
|
|
|
|
|
|
|
|
elif (env["target"]=="debug"):
|
|
|
|
|
|
|
|
env.Append(CCFLAGS=['-D_DEBUG', '-g1', '-Wall', '-O0', '-DDEBUG_ENABLED'])
|
|
|
|
env.Append(CPPFLAGS=['-DDEBUG_MEMORY_ALLOC'])
|
|
|
|
|
2014-05-28 08:42:33 +02:00
|
|
|
if env["armv6"] == "no" and env['x86'] != 'yes':
|
2014-02-10 02:10:30 +01:00
|
|
|
env['neon_enabled']=True
|
2014-10-07 06:31:49 +02:00
|
|
|
|
2014-02-10 02:10:30 +01:00
|
|
|
env.Append(CPPFLAGS=['-DANDROID_ENABLED', '-DUNIX_ENABLED', '-DNO_FCNTL','-DMPC_FIXED_POINT'])
|
|
|
|
# env.Append(CPPFLAGS=['-DANDROID_ENABLED', '-DUNIX_ENABLED','-DMPC_FIXED_POINT'])
|
2014-10-07 06:31:49 +02:00
|
|
|
|
2014-02-10 02:10:30 +01:00
|
|
|
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(LIBS=["gnustl_static","supc++"])
|
|
|
|
env.Append(CPPPATH=[env["ANDROID_NDK_ROOT"]+"/sources/cpufeatures"])
|
|
|
|
|
|
|
|
#env.Append(CCFLAGS=["-I"+env["ANDROID_NDK_ROOT"]+"/sources/cxx-stl/stlport/stlport"])
|
|
|
|
#env.Append(CCFLAGS=["-I"+env["ANDROID_NDK_ROOT"]+"/sources/cxx-stl/gnu-libstdc++/libs/armeabi/include"])
|
|
|
|
#env.Append(LINKFLAGS=[env["ANDROID_NDK_ROOT"]+"/sources/cxx-stl/gnu-libstdc++/libs/armeabi/libstdc++.a"])
|
|
|
|
else:
|
|
|
|
|
|
|
|
env.Append(CPPPATH=[env["ANDROID_NDK_ROOT"]+"/sources/cxx-stl/gabi++/include"])
|
|
|
|
env.Append(CPPPATH=[env["ANDROID_NDK_ROOT"]+"/sources/cpufeatures"])
|
2014-05-28 08:42:33 +02:00
|
|
|
if env['x86']=='yes':
|
|
|
|
env.Append(LIBPATH=[env["ANDROID_NDK_ROOT"]+"/sources/cxx-stl/gabi++/libs/x86"])
|
|
|
|
else:
|
|
|
|
env.Append(LIBPATH=[env["ANDROID_NDK_ROOT"]+"/sources/cxx-stl/gabi++/libs/armeabi"])
|
2014-02-10 02:10:30 +01:00
|
|
|
env.Append(LIBS=['gabi++_static'])
|
|
|
|
env.Append(CCFLAGS=["-fno-exceptions",'-DNO_SAFE_CAST'])
|
|
|
|
|
|
|
|
import methods
|
|
|
|
env.Append( BUILDERS = { 'GLSL120' : env.Builder(action = methods.build_legacygl_headers, suffix = 'glsl.h',src_suffix = '.glsl') } )
|
|
|
|
env.Append( BUILDERS = { 'GLSL' : env.Builder(action = methods.build_glsl_headers, suffix = 'glsl.h',src_suffix = '.glsl') } )
|
|
|
|
env.Append( BUILDERS = { 'GLSL120GLES' : env.Builder(action = methods.build_gles2_headers, suffix = 'glsl.h',src_suffix = '.glsl') } )
|