2016-10-17 06:50:25 +00:00
|
|
|
#!/usr/bin/env python
|
|
|
|
|
2014-02-10 01:10:30 +00:00
|
|
|
import shutil
|
|
|
|
|
|
|
|
Import('env')
|
|
|
|
|
|
|
|
android_files = [
|
|
|
|
|
2016-11-02 21:26:55 +00:00
|
|
|
'os_android.cpp',
|
|
|
|
'godot_android.cpp',
|
|
|
|
'file_access_android.cpp',
|
|
|
|
'dir_access_android.cpp',
|
|
|
|
'audio_driver_opensl.cpp',
|
|
|
|
'file_access_jandroid.cpp',
|
|
|
|
'dir_access_jandroid.cpp',
|
|
|
|
'thread_jandroid.cpp',
|
|
|
|
'audio_driver_jandroid.cpp',
|
|
|
|
'ifaddrs_android.cpp',
|
|
|
|
'android_native_app_glue.c',
|
|
|
|
'java_glue.cpp',
|
|
|
|
'cpu-features.c',
|
|
|
|
'java_class_wrapper.cpp'
|
2014-02-10 01:10:30 +00:00
|
|
|
]
|
|
|
|
|
2016-11-02 21:28:28 +00:00
|
|
|
# env.Depends('#core/math/vector3.h', 'vector3_psp.h')
|
2014-02-10 01:10:30 +00:00
|
|
|
|
|
|
|
#obj = env.SharedObject('godot_android.cpp')
|
|
|
|
|
|
|
|
env_android = env.Clone()
|
|
|
|
if env['target'] == "profile":
|
2016-11-02 21:26:55 +00:00
|
|
|
env_android.Append(CPPFLAGS=['-DPROFILER_ENABLED'])
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2016-11-02 21:28:28 +00:00
|
|
|
android_objects = []
|
2014-02-10 01:10:30 +00:00
|
|
|
for x in android_files:
|
2016-11-02 21:28:28 +00:00
|
|
|
android_objects.append(env_android.SharedObject(x))
|
2014-02-10 01:10:30 +00:00
|
|
|
|
|
|
|
prog = None
|
|
|
|
|
2016-11-02 21:28:28 +00:00
|
|
|
abspath = env.Dir(".").abspath
|
2014-02-10 01:10:30 +00:00
|
|
|
|
|
|
|
|
2016-11-02 21:28:28 +00:00
|
|
|
gradle_basein = open(abspath + "/build.gradle.template", "rb")
|
|
|
|
gradle_baseout = open(abspath + "/java/build.gradle", "wb")
|
2014-03-14 01:57:24 +00:00
|
|
|
|
2016-01-08 16:36:44 +00:00
|
|
|
gradle_text = gradle_basein.read()
|
2014-03-14 01:57:24 +00:00
|
|
|
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2016-11-02 21:28:28 +00:00
|
|
|
gradle_maven_repos_text = ""
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2016-01-09 13:21:22 +00:00
|
|
|
if len(env.android_maven_repos) > 0:
|
2017-03-05 10:16:55 +00:00
|
|
|
gradle_maven_repos_text += ""
|
2016-11-02 21:26:55 +00:00
|
|
|
for x in env.android_maven_repos:
|
2017-03-05 10:16:55 +00:00
|
|
|
gradle_maven_repos_text += "\tmaven {\n"
|
2016-11-02 21:28:28 +00:00
|
|
|
gradle_maven_repos_text += "\t\t" + x + "\n"
|
2017-03-05 10:16:55 +00:00
|
|
|
gradle_maven_repos_text += "\t}\n"
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2016-11-02 21:28:28 +00:00
|
|
|
gradle_maven_dependencies_text = ""
|
2016-01-08 16:36:44 +00:00
|
|
|
|
|
|
|
for x in env.android_dependencies:
|
2016-11-02 21:28:28 +00:00
|
|
|
gradle_maven_dependencies_text += x + "\n"
|
2016-01-08 16:36:44 +00:00
|
|
|
|
2016-11-02 21:28:28 +00:00
|
|
|
gradle_java_dirs_text = ""
|
2016-01-08 16:36:44 +00:00
|
|
|
|
|
|
|
for x in env.android_java_dirs:
|
2016-11-02 21:28:28 +00:00
|
|
|
gradle_java_dirs_text += ",'" + x.replace("\\", "/") + "'"
|
2016-01-08 16:36:44 +00:00
|
|
|
|
|
|
|
|
2016-11-02 21:28:28 +00:00
|
|
|
gradle_res_dirs_text = ""
|
2016-01-08 16:36:44 +00:00
|
|
|
|
|
|
|
for x in env.android_res_dirs:
|
2016-11-02 21:28:28 +00:00
|
|
|
gradle_res_dirs_text += ",'" + x.replace("\\", "/") + "'"
|
2016-01-08 16:36:44 +00:00
|
|
|
|
2016-11-02 21:28:28 +00:00
|
|
|
gradle_aidl_dirs_text = ""
|
2016-01-08 16:36:44 +00:00
|
|
|
|
|
|
|
for x in env.android_aidl_dirs:
|
2016-11-02 21:28:28 +00:00
|
|
|
gradle_aidl_dirs_text += ",'" + x.replace("\\", "/") + "'"
|
2016-01-08 16:36:44 +00:00
|
|
|
|
2016-11-02 21:28:28 +00:00
|
|
|
gradle_jni_dirs_text = ""
|
2016-01-08 16:36:44 +00:00
|
|
|
|
|
|
|
for x in env.android_jni_dirs:
|
2016-11-02 21:28:28 +00:00
|
|
|
gradle_jni_dirs_text += ",'" + x.replace("\\", "/") + "'"
|
2016-01-08 16:36:44 +00:00
|
|
|
|
2016-11-02 21:28:28 +00:00
|
|
|
gradle_asset_dirs_text = ""
|
2016-01-08 16:36:44 +00:00
|
|
|
|
2016-11-02 21:28:28 +00:00
|
|
|
gradle_default_config_text = ""
|
2016-07-06 19:03:50 +00:00
|
|
|
|
|
|
|
for x in env.android_default_config:
|
2016-11-02 21:28:28 +00:00
|
|
|
gradle_default_config_text += x + "\n\t\t"
|
2016-07-06 19:03:50 +00:00
|
|
|
|
2016-11-02 21:28:28 +00:00
|
|
|
gradle_text = gradle_text.replace("$$GRADLE_REPOSITORY_URLS$$", gradle_maven_repos_text)
|
|
|
|
gradle_text = gradle_text.replace("$$GRADLE_DEPENDENCIES$$", gradle_maven_dependencies_text)
|
|
|
|
gradle_text = gradle_text.replace("$$GRADLE_JAVA_DIRS$$", gradle_java_dirs_text)
|
|
|
|
gradle_text = gradle_text.replace("$$GRADLE_RES_DIRS$$", gradle_res_dirs_text)
|
|
|
|
gradle_text = gradle_text.replace("$$GRADLE_ASSET_DIRS$$", gradle_asset_dirs_text)
|
|
|
|
gradle_text = gradle_text.replace("$$GRADLE_AIDL_DIRS$$", gradle_aidl_dirs_text)
|
|
|
|
gradle_text = gradle_text.replace("$$GRADLE_JNI_DIRS$$", gradle_jni_dirs_text)
|
|
|
|
gradle_text = gradle_text.replace("$$GRADLE_DEFAULT_CONFIG$$", gradle_default_config_text)
|
2016-01-08 16:36:44 +00:00
|
|
|
|
|
|
|
|
2016-11-02 21:28:28 +00:00
|
|
|
gradle_baseout.write(gradle_text)
|
2016-01-08 16:36:44 +00:00
|
|
|
gradle_baseout.close()
|
2014-02-10 01:10:30 +00:00
|
|
|
|
|
|
|
|
2016-11-02 21:28:28 +00:00
|
|
|
pp_basein = open(abspath + "/AndroidManifest.xml.template", "rb")
|
|
|
|
pp_baseout = open(abspath + "/java/AndroidManifest.xml", "wb")
|
2014-02-10 01:10:30 +00:00
|
|
|
manifest = pp_basein.read()
|
2016-11-02 21:28:28 +00:00
|
|
|
manifest = manifest.replace("$$ADD_APPLICATION_CHUNKS$$", env.android_manifest_chunk)
|
|
|
|
manifest = manifest.replace("$$ADD_PERMISSION_CHUNKS$$", env.android_permission_chunk)
|
|
|
|
manifest = manifest.replace("$$ADD_APPATTRIBUTE_CHUNKS$$", env.android_appattributes_chunk)
|
|
|
|
pp_baseout.write(manifest)
|
2014-02-10 01:10:30 +00:00
|
|
|
|
|
|
|
|
2016-11-02 21:28:28 +00:00
|
|
|
env_android.SharedLibrary("#bin/libgodot", [android_objects], SHLIBSUFFIX=env["SHLIBSUFFIX"])
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2016-06-15 13:21:18 +00:00
|
|
|
|
|
|
|
lib_arch_dir = ''
|
|
|
|
if env['android_arch'] == 'armv6':
|
2016-11-02 21:26:55 +00:00
|
|
|
lib_arch_dir = 'armeabi'
|
2016-06-15 13:21:18 +00:00
|
|
|
elif env['android_arch'] == 'armv7':
|
2016-11-02 21:26:55 +00:00
|
|
|
lib_arch_dir = 'armeabi-v7a'
|
2016-06-15 13:21:18 +00:00
|
|
|
elif env['android_arch'] == 'x86':
|
2016-11-02 21:26:55 +00:00
|
|
|
lib_arch_dir = 'x86'
|
2016-06-15 13:21:18 +00:00
|
|
|
else:
|
2016-11-02 21:26:55 +00:00
|
|
|
print 'WARN: Architecture not suitable for embedding into APK; keeping .so at \\bin'
|
2016-06-15 13:21:18 +00:00
|
|
|
|
|
|
|
if lib_arch_dir != '':
|
2016-11-02 21:26:55 +00:00
|
|
|
if env['target'] == 'release':
|
|
|
|
lib_type_dir = 'release'
|
2016-11-02 21:28:28 +00:00
|
|
|
else: # release_debug, debug
|
2016-11-02 21:26:55 +00:00
|
|
|
lib_type_dir = 'debug'
|
|
|
|
|
2016-11-02 21:28:28 +00:00
|
|
|
out_dir = '#platform/android/java/libs/' + lib_type_dir + '/' + lib_arch_dir
|
|
|
|
env_android.Command(out_dir + '/libgodot_android.so', '#bin/libgodot' + env['SHLIBSUFFIX'], Move("$TARGET", "$SOURCE"))
|