2014-02-10 01:10:30 +00:00
|
|
|
import os
|
|
|
|
import sys
|
|
|
|
import string
|
|
|
|
import platform
|
|
|
|
|
2016-10-30 18:05:14 +00:00
|
|
|
|
2014-02-10 01:10:30 +00:00
|
|
|
def is_active():
|
2016-10-30 17:44:57 +00:00
|
|
|
return True
|
2016-04-02 18:26:12 +00:00
|
|
|
|
2016-10-30 18:05:14 +00:00
|
|
|
|
2014-02-10 01:10:30 +00:00
|
|
|
def get_name():
|
2016-10-30 17:44:57 +00:00
|
|
|
return "Android"
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2016-10-30 18:05:14 +00:00
|
|
|
|
2014-02-10 01:10:30 +00:00
|
|
|
def can_build():
|
|
|
|
|
2016-10-30 17:44:57 +00:00
|
|
|
import os
|
|
|
|
if (not os.environ.has_key("ANDROID_NDK_ROOT")):
|
|
|
|
return False
|
2014-03-14 01:57:24 +00:00
|
|
|
|
2016-10-30 17:44:57 +00:00
|
|
|
return True
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2016-10-30 18:05:14 +00:00
|
|
|
|
2014-02-10 01:10:30 +00:00
|
|
|
def get_opts():
|
|
|
|
|
2016-10-30 17:44:57 +00:00
|
|
|
return [
|
|
|
|
('ANDROID_NDK_ROOT', 'the path to Android NDK', os.environ.get("ANDROID_NDK_ROOT", 0)),
|
2016-10-30 17:57:40 +00:00
|
|
|
('NDK_TARGET', 'toolchain to use for the NDK', os.environ.get("NDK_TARGET", "arm-linux-androideabi-4.9")),
|
|
|
|
('NDK_TARGET_X86', 'toolchain to use for the NDK x86', os.environ.get("NDK_TARGET_X86", "x86-4.9")),
|
|
|
|
('ndk_platform', 'compile for platform: (android-<api> , example: android-14)', "android-14"),
|
|
|
|
('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")
|
2016-10-30 17:44:57 +00:00
|
|
|
]
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2016-03-20 09:22:48 +00:00
|
|
|
|
2014-02-10 01:10:30 +00:00
|
|
|
def get_flags():
|
|
|
|
|
2016-10-30 17:44:57 +00:00
|
|
|
return [
|
|
|
|
('tools', 'no'),
|
2016-10-30 17:57:40 +00:00
|
|
|
('openssl', 'builtin'), # use builtin openssl
|
2016-10-30 17:44:57 +00:00
|
|
|
]
|
2014-02-10 01:10:30 +00:00
|
|
|
|
|
|
|
|
|
|
|
def create(env):
|
2016-10-30 17:44:57 +00:00
|
|
|
tools = env['TOOLS']
|
|
|
|
if "mingw" in tools:
|
|
|
|
tools.remove('mingw')
|
|
|
|
if "applelink" in tools:
|
|
|
|
tools.remove("applelink")
|
|
|
|
env.Tool('gcc')
|
2016-10-31 23:24:30 +00:00
|
|
|
return env.Clone(tools=tools)
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2016-10-30 18:05:14 +00:00
|
|
|
|
2014-02-10 01:10:30 +00:00
|
|
|
def configure(env):
|
|
|
|
|
2016-10-30 17:44:57 +00:00
|
|
|
# Workaround for MinGW. See:
|
|
|
|
# http://www.scons.org/wiki/LongCmdLinesOnWin32
|
|
|
|
import os
|
2016-10-30 17:57:40 +00:00
|
|
|
if (os.name == "nt"):
|
2016-10-30 17:44:57 +00:00
|
|
|
|
|
|
|
import subprocess
|
|
|
|
|
2016-10-30 17:57:40 +00:00
|
|
|
def mySubProcess(cmdline, env):
|
|
|
|
# print "SPAWNED : " + cmdline
|
2016-10-30 17:44:57 +00:00
|
|
|
startupinfo = subprocess.STARTUPINFO()
|
|
|
|
startupinfo.dwFlags |= subprocess.STARTF_USESHOWWINDOW
|
|
|
|
proc = subprocess.Popen(cmdline, stdin=subprocess.PIPE, stdout=subprocess.PIPE,
|
2016-10-30 17:57:40 +00:00
|
|
|
stderr=subprocess.PIPE, startupinfo=startupinfo, shell=False, env=env)
|
2016-10-30 17:44:57 +00:00
|
|
|
data, err = proc.communicate()
|
|
|
|
rv = proc.wait()
|
|
|
|
if rv:
|
|
|
|
print "====="
|
|
|
|
print err
|
|
|
|
print "====="
|
|
|
|
return rv
|
|
|
|
|
|
|
|
def mySpawn(sh, escape, cmd, args, env):
|
|
|
|
|
|
|
|
newargs = ' '.join(args[1:])
|
|
|
|
cmdline = cmd + " " + newargs
|
|
|
|
|
2016-10-30 17:57:40 +00:00
|
|
|
rv = 0
|
|
|
|
if len(cmdline) > 32000 and cmd.endswith("ar"):
|
2016-10-30 17:44:57 +00:00
|
|
|
cmdline = cmd + " " + args[1] + " " + args[2] + " "
|
2016-10-30 17:57:40 +00:00
|
|
|
for i in range(3, len(args)):
|
|
|
|
rv = mySubProcess(cmdline + args[i], env)
|
|
|
|
if rv:
|
2016-10-30 17:44:57 +00:00
|
|
|
break
|
|
|
|
else:
|
2016-10-30 17:57:40 +00:00
|
|
|
rv = mySubProcess(cmdline, env)
|
2016-10-30 17:44:57 +00:00
|
|
|
|
|
|
|
return rv
|
|
|
|
|
|
|
|
env['SPAWN'] = mySpawn
|
|
|
|
|
2016-10-30 17:57:40 +00:00
|
|
|
ndk_platform = env['ndk_platform']
|
2016-10-30 17:44:57 +00:00
|
|
|
|
2016-10-30 17:57:40 +00:00
|
|
|
if env['android_arch'] not in ['armv7', 'armv6', 'x86']:
|
|
|
|
env['android_arch'] = 'armv7'
|
2016-10-30 17:44:57 +00:00
|
|
|
|
2016-10-30 17:57:40 +00:00
|
|
|
if env['android_arch'] == 'x86':
|
|
|
|
env['NDK_TARGET'] = env['NDK_TARGET_X86']
|
|
|
|
env["x86_libtheora_opt_gcc"] = True
|
2016-10-30 17:44:57 +00:00
|
|
|
|
|
|
|
if env['PLATFORM'] == 'win32':
|
|
|
|
env.Tool('gcc')
|
|
|
|
env['SHLIBSUFFIX'] = '.so'
|
|
|
|
|
2016-10-30 17:57:40 +00:00
|
|
|
neon_text = ""
|
|
|
|
if env["android_arch"] == "armv7" and env['android_neon'] == 'yes':
|
|
|
|
neon_text = " (with neon)"
|
|
|
|
print("Godot Android!!!!! (" + env['android_arch'] + ")" + neon_text)
|
2016-10-30 17:44:57 +00:00
|
|
|
|
|
|
|
env.Append(CPPPATH=['#platform/android'])
|
|
|
|
|
2016-10-30 17:57:40 +00:00
|
|
|
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
|
2016-10-30 17:44:57 +00:00
|
|
|
else:
|
2016-10-30 17:57:40 +00:00
|
|
|
env.extra_suffix = ".armv7" + env.extra_suffix
|
2016-10-30 17:44:57 +00:00
|
|
|
|
2016-10-31 23:24:30 +00:00
|
|
|
gcc_path = env["ANDROID_NDK_ROOT"] + "/toolchains/" + env["NDK_TARGET"] + "/prebuilt/"
|
2016-10-30 17:44:57 +00:00
|
|
|
|
|
|
|
if (sys.platform.startswith("linux")):
|
|
|
|
if (platform.machine().endswith('64')):
|
2016-10-30 17:57:40 +00:00
|
|
|
gcc_path = gcc_path + "/linux-x86_64/bin"
|
2016-10-30 17:44:57 +00:00
|
|
|
else:
|
2016-10-30 17:57:40 +00:00
|
|
|
gcc_path = gcc_path + "/linux-x86/bin"
|
2016-10-30 17:44:57 +00:00
|
|
|
elif (sys.platform.startswith("darwin")):
|
2016-10-30 17:57:40 +00:00
|
|
|
gcc_path = gcc_path + "/darwin-x86_64/bin"
|
2016-10-30 17:44:57 +00:00
|
|
|
env['SHLINKFLAGS'][1] = '-shared'
|
|
|
|
env['SHLIBSUFFIX'] = '.so'
|
|
|
|
elif (sys.platform.startswith('win')):
|
|
|
|
if (platform.machine().endswith('64')):
|
2016-10-30 17:57:40 +00:00
|
|
|
gcc_path = gcc_path + "/windows-x86_64/bin"
|
2016-10-30 17:44:57 +00:00
|
|
|
else:
|
2016-10-30 17:57:40 +00:00
|
|
|
gcc_path = gcc_path + "/windows-x86/bin"
|
|
|
|
|
|
|
|
env['ENV']['PATH'] = gcc_path + ":" + env['ENV']['PATH']
|
|
|
|
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"
|
|
|
|
env['RANLIB'] = gcc_path + "/i686-linux-android-ranlib"
|
|
|
|
env['AS'] = gcc_path + "/i686-linux-android-as"
|
2016-10-30 17:44:57 +00:00
|
|
|
else:
|
2016-10-30 17:57:40 +00:00
|
|
|
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"
|
2016-10-30 17:44:57 +00:00
|
|
|
|
2016-10-30 17:57:40 +00:00
|
|
|
if env['android_arch'] == 'x86':
|
2016-10-30 17:44:57 +00:00
|
|
|
env['ARCH'] = 'arch-x86'
|
|
|
|
else:
|
|
|
|
env['ARCH'] = 'arch-arm'
|
|
|
|
|
|
|
|
import string
|
2016-10-30 17:57:40 +00:00
|
|
|
# include path
|
|
|
|
gcc_include = env["ANDROID_NDK_ROOT"] + "/platforms/" + ndk_platform + "/" + env['ARCH'] + "/usr/include"
|
|
|
|
ld_sysroot = env["ANDROID_NDK_ROOT"] + "/platforms/" + ndk_platform + "/" + env['ARCH']
|
|
|
|
# glue_include=env["ANDROID_NDK_ROOT"]+"/sources/android/native_app_glue"
|
|
|
|
ld_path = env["ANDROID_NDK_ROOT"] + "/platforms/" + ndk_platform + "/" + env['ARCH'] + "/usr/lib"
|
2016-10-30 17:44:57 +00:00
|
|
|
env.Append(CPPPATH=[gcc_include])
|
2014-02-10 01:10:30 +00:00
|
|
|
# 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 04:31:49 +00:00
|
|
|
|
2016-10-30 17:57:40 +00:00
|
|
|
env['neon_enabled'] = False
|
|
|
|
if env['android_arch'] == 'x86':
|
2016-10-30 17:44:57 +00:00
|
|
|
env.Append(CCFLAGS=string.split('-DNO_STATVFS -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'))
|
2016-10-30 17:57:40 +00:00
|
|
|
elif env["android_arch"] == "armv6":
|
2016-10-30 17:44:57 +00:00
|
|
|
env.Append(CCFLAGS=string.split('-DNO_STATVFS -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'))
|
2016-10-30 17:57:40 +00:00
|
|
|
elif env["android_arch"] == "armv7":
|
2016-10-30 17:44:57 +00:00
|
|
|
env.Append(CCFLAGS=string.split('-DNO_STATVFS -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'))
|
2016-10-30 17:57:40 +00:00
|
|
|
if env['android_neon'] == 'yes':
|
|
|
|
env['neon_enabled'] = True
|
|
|
|
env.Append(CCFLAGS=['-mfpu=neon', '-D__ARM_NEON__'])
|
2016-10-30 17:44:57 +00:00
|
|
|
else:
|
|
|
|
env.Append(CCFLAGS=['-mfpu=vfpv3-d16'])
|
|
|
|
|
|
|
|
env.Append(LDPATH=[ld_path])
|
|
|
|
env.Append(LIBS=['OpenSLES'])
|
2016-09-10 15:31:01 +00:00
|
|
|
# env.Append(LIBS=['c','m','stdc++','log','EGL','GLESv1_CM','GLESv2','OpenSLES','supc++','android'])
|
2016-10-30 17:57:40 +00:00
|
|
|
env.Append(LIBS=['EGL', 'OpenSLES', 'android'])
|
|
|
|
env.Append(LIBS=['c', 'm', 'stdc++', 'log', 'GLESv1_CM', 'GLESv2', 'z'])
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2016-10-30 17:57:40 +00:00
|
|
|
env["LINKFLAGS"] = string.split(" -g --sysroot=" + ld_sysroot + " -Wl,--no-undefined -Wl,-z,noexecstack ")
|
2016-10-30 17:44:57 +00:00
|
|
|
env.Append(LINKFLAGS=["-Wl,-soname,libgodot_android.so"])
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2016-10-30 17:57:40 +00:00
|
|
|
if (env["target"] == "release"):
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2016-10-30 17:57:40 +00:00
|
|
|
env.Append(CCFLAGS=['-O2', '-ffast-math', '-fomit-frame-pointer'])
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2016-10-30 17:57:40 +00:00
|
|
|
elif (env["target"] == "release_debug"):
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2016-10-30 17:57:40 +00:00
|
|
|
env.Append(CCFLAGS=['-O2', '-ffast-math', '-DDEBUG_ENABLED'])
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2016-10-30 17:57:40 +00:00
|
|
|
elif (env["target"] == "debug"):
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2016-10-30 17:44:57 +00:00
|
|
|
env.Append(CCFLAGS=['-D_DEBUG', '-g1', '-Wall', '-O0', '-DDEBUG_ENABLED'])
|
|
|
|
env.Append(CPPFLAGS=['-DDEBUG_MEMORY_ALLOC'])
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2016-10-30 17:57:40 +00:00
|
|
|
env.Append(CPPFLAGS=['-DANDROID_ENABLED', '-DUNIX_ENABLED', '-DNO_FCNTL', '-DMPC_FIXED_POINT'])
|
2014-02-10 01:10:30 +00:00
|
|
|
# env.Append(CPPFLAGS=['-DANDROID_ENABLED', '-DUNIX_ENABLED','-DMPC_FIXED_POINT'])
|
2014-10-07 04:31:49 +00:00
|
|
|
|
2016-10-30 17:44:57 +00:00
|
|
|
# TODO: Move that to opus module's config
|
|
|
|
if("module_opus_enabled" in env and env["module_opus_enabled"] != "no"):
|
2016-10-30 17:57:40 +00:00
|
|
|
if (env["android_arch"] == "armv6" or env["android_arch"] == "armv7"):
|
2016-10-30 17:44:57 +00:00
|
|
|
env.Append(CFLAGS=["-DOPUS_ARM_OPT"])
|
2016-10-30 17:57:40 +00:00
|
|
|
env.opus_fixed_point = "yes"
|
|
|
|
|
|
|
|
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.9/include"])
|
|
|
|
if env['android_arch'] == 'x86':
|
|
|
|
env.Append(CPPPATH=[env["ANDROID_NDK_ROOT"] + "/sources/cxx-stl/gnu-libstdc++/4.9/libs/x86/include"])
|
|
|
|
env.Append(LIBPATH=[env["ANDROID_NDK_ROOT"] + "/sources/cxx-stl/gnu-libstdc++/4.9/libs/x86"])
|
|
|
|
elif env['android_arch'] == 'armv6':
|
|
|
|
env.Append(CPPPATH=[env["ANDROID_NDK_ROOT"] + "/sources/cxx-stl/gnu-libstdc++/4.9/libs/armeabi/include"])
|
|
|
|
env.Append(LIBPATH=[env["ANDROID_NDK_ROOT"] + "/sources/cxx-stl/gnu-libstdc++/4.9/libs/armeabi"])
|
|
|
|
elif env["android_arch"] == "armv7":
|
|
|
|
env.Append(CPPPATH=[env["ANDROID_NDK_ROOT"] + "/sources/cxx-stl/gnu-libstdc++/4.9/libs/armeabi-v7a/include"])
|
|
|
|
env.Append(LIBPATH=[env["ANDROID_NDK_ROOT"] + "/sources/cxx-stl/gnu-libstdc++/4.9/libs/armeabi-v7a"])
|
|
|
|
|
|
|
|
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"])
|
2016-10-30 17:44:57 +00:00
|
|
|
else:
|
|
|
|
|
2016-10-30 17:57:40 +00:00
|
|
|
env.Append(CPPPATH=[env["ANDROID_NDK_ROOT"] + "/sources/cxx-stl/gnu-libstdc++/4.9/include"])
|
|
|
|
env.Append(CPPPATH=[env["ANDROID_NDK_ROOT"] + "/sources/cpufeatures"])
|
|
|
|
if env['android_arch'] == 'x86':
|
|
|
|
env.Append(LIBPATH=[env["ANDROID_NDK_ROOT"] + "/sources/cxx-stl/gnu-libstdc++/4.9/libs/x86"])
|
|
|
|
elif env["android_arch"] == "armv6":
|
|
|
|
env.Append(LIBPATH=[env["ANDROID_NDK_ROOT"] + "/sources/cxx-stl/gnu-libstdc++/4.9/libs/armeabi"])
|
|
|
|
elif env["android_arch"] == "armv7":
|
|
|
|
env.Append(LIBPATH=[env["ANDROID_NDK_ROOT"] + "/sources/cxx-stl/gnu-libstdc++/4.9/libs/armeabi-v7a"])
|
2016-10-30 17:44:57 +00:00
|
|
|
env.Append(LIBS=['gnustl_static'])
|
2016-10-30 17:57:40 +00:00
|
|
|
env.Append(CCFLAGS=["-fno-exceptions", '-DNO_SAFE_CAST'])
|
2016-10-30 17:44:57 +00:00
|
|
|
|
|
|
|
import methods
|
2016-10-30 17:57:40 +00:00
|
|
|
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')})
|
2016-10-30 17:44:57 +00:00
|
|
|
|
|
|
|
env.use_windows_spawn_fix()
|