diff options
author | Pedro J. Estébanez <pedrojrulez@gmail.com> | 2017-07-25 12:28:31 +0200 |
---|---|---|
committer | Pedro J. Estébanez <pedrojrulez@gmail.com> | 2017-07-25 12:28:46 +0200 |
commit | f78299c81be28b923e1f16e6f14afbebe3c8eaeb (patch) | |
tree | 37536f49d526ebc66826e03ddf704acf73f5ff41 /platform/android | |
parent | 303370d03d71ad7ea194250fdfc94f7f1928fb47 (diff) |
Add support for ARMv8 (64-bit) on Android
Diffstat (limited to 'platform/android')
-rw-r--r-- | platform/android/SCsub | 2 | ||||
-rw-r--r-- | platform/android/detect.py | 28 | ||||
-rw-r--r-- | platform/android/export/export.cpp | 15 | ||||
-rw-r--r-- | platform/android/java_class_wrapper.cpp | 12 |
4 files changed, 43 insertions, 14 deletions
diff --git a/platform/android/SCsub b/platform/android/SCsub index 7fb3c876be..b124a1a5a8 100644 --- a/platform/android/SCsub +++ b/platform/android/SCsub @@ -141,6 +141,8 @@ if env['android_arch'] == 'armv6': lib_arch_dir = 'armeabi' elif env['android_arch'] == 'armv7': lib_arch_dir = 'armeabi-v7a' +elif env['android_arch'] == 'arm64v8': + lib_arch_dir = 'arm64-v8a' elif env['android_arch'] == 'x86': lib_arch_dir = 'x86' else: diff --git a/platform/android/detect.py b/platform/android/detect.py index 55b7052393..437a092323 100644 --- a/platform/android/detect.py +++ b/platform/android/detect.py @@ -22,7 +22,7 @@ def get_opts(): return [ ('ANDROID_NDK_ROOT', 'Path to the Android NDK', os.environ.get("ANDROID_NDK_ROOT", 0)), ('ndk_platform', 'Target platform (android-<api>, e.g. "android-18")', "android-18"), - ('android_arch', 'Target architecture (armv7/armv6/x86)', "armv7"), + ('android_arch', 'Target architecture (armv7/armv6/arm64v8/x86)', "armv7"), ('android_neon', 'Enable NEON support (armv7 only)', "yes"), ('android_stl', 'Enable Android STL support (for modules)', "no") ] @@ -89,7 +89,7 @@ def configure(env): ## Architecture - if env['android_arch'] not in ['armv7', 'armv6', 'x86']: + if env['android_arch'] not in ['armv7', 'armv6', 'arm64v8', 'x86']: env['android_arch'] = 'armv7' neon_text = "" @@ -99,18 +99,21 @@ def configure(env): can_vectorize = True if env['android_arch'] == 'x86': + env['ARCH'] = 'arch-x86' env.extra_suffix = ".x86" + env.extra_suffix target_subpath = "x86-4.9" abi_subpath = "i686-linux-android" arch_subpath = "x86" env["x86_libtheora_opt_gcc"] = True elif env['android_arch'] == 'armv6': + env['ARCH'] = 'arch-arm' env.extra_suffix = ".armv6" + env.extra_suffix target_subpath = "arm-linux-androideabi-4.9" abi_subpath = "arm-linux-androideabi" arch_subpath = "armeabi" can_vectorize = False elif env["android_arch"] == "armv7": + env['ARCH'] = 'arch-arm' target_subpath = "arm-linux-androideabi-4.9" abi_subpath = "arm-linux-androideabi" arch_subpath = "armeabi-v7a" @@ -118,6 +121,12 @@ def configure(env): env.extra_suffix = ".armv7.neon" + env.extra_suffix else: env.extra_suffix = ".armv7" + env.extra_suffix + elif env["android_arch"] == "arm64v8": + env['ARCH'] = 'arch-arm64' + target_subpath = "aarch64-linux-android-4.9" + abi_subpath = "aarch64-linux-android" + arch_subpath = "arm64-v8a" + env.extra_suffix = ".armv8" + env.extra_suffix ## Build type @@ -149,6 +158,8 @@ def configure(env): elif (sys.platform.startswith('win')): if (platform.machine().endswith('64')): host_subpath = "windows-x86_64" + if env["android_arch"] == "arm64v8": + mt_link = False else: mt_link = False host_subpath = "windows" @@ -166,11 +177,6 @@ def configure(env): env['RANLIB'] = tools_path + "/ranlib" env['AS'] = tools_path + "/as" - if env['android_arch'] == 'x86': - env['ARCH'] = 'arch-x86' - else: - env['ARCH'] = 'arch-arm' - sysroot = env["ANDROID_NDK_ROOT"] + "/platforms/" + env['ndk_platform'] + "/" + env['ARCH'] common_opts = ['-fno-integrated-as', '-gcc-toolchain', gcc_toolchain_path] @@ -199,6 +205,11 @@ def configure(env): else: env.Append(CPPFLAGS=['-mfpu=vfpv3-d16']) + elif env["android_arch"] == "arm64v8": + target_opts = ['-target', 'aarch64-none-linux-android'] + env.Append(CPPFLAGS=['-D__ARM_ARCH_8A__']) + env.Append(CPPFLAGS=['-mfix-cortex-a53-835769']) + env.Append(CPPFLAGS=target_opts) env.Append(CPPFLAGS=common_opts) @@ -213,7 +224,8 @@ def configure(env): ## Link flags env['LINKFLAGS'] = ['-shared', '--sysroot=' + sysroot, '-Wl,--warn-shared-textrel'] - env.Append(LINKFLAGS=string.split('-Wl,--fix-cortex-a8')) + if env["android_arch"] == "armv7": + env.Append(LINKFLAGS=string.split('-Wl,--fix-cortex-a8')) env.Append(LINKFLAGS=string.split('-Wl,--no-undefined -Wl,-z,noexecstack -Wl,-z,relro -Wl,-z,now')) env.Append(LINKFLAGS=string.split('-Wl,-soname,libgodot_android.so -Wl,--gc-sections')) if mt_link: diff --git a/platform/android/export/export.cpp b/platform/android/export/export.cpp index 97f239c4da..aa6b7e6c6d 100644 --- a/platform/android/export/export.cpp +++ b/platform/android/export/export.cpp @@ -219,6 +219,7 @@ class EditorExportPlatformAndroid : public EditorExportPlatform { bool use_32_fb; bool immersive; bool export_arm; + bool export_arm64; bool export_x86; String apk_expansion_salt; String apk_expansion_pkey; @@ -319,6 +320,8 @@ bool EditorExportPlatformAndroid::_set(const StringName& p_name, const Variant& _signed=p_value; else if (n=="architecture/arm") export_arm=p_value; + else if (n=="architecture/arm64") + export_arm64=p_value; else if (n=="architecture/x86") export_x86=p_value; else if (n=="screen/use_32_bits_view") @@ -392,6 +395,8 @@ bool EditorExportPlatformAndroid::_get(const StringName& p_name,Variant &r_ret) r_ret=_signed; else if (n=="architecture/arm") r_ret=export_arm; + else if (n=="architecture/arm64") + r_ret=export_arm64; else if (n=="architecture/x86") r_ret=export_x86; else if (n=="screen/use_32_bits_view") @@ -1164,6 +1169,10 @@ Error EditorExportPlatformAndroid::export_project(const String& p_path, bool p_d skip=true; } + if (file.match("lib/arm64*/libgodot_android.so") && !export_arm64) { + skip = true; + } + if (file.begins_with("META-INF") && _signed) { skip=true; } @@ -1801,6 +1810,7 @@ EditorExportPlatformAndroid::EditorExportPlatformAndroid() { immersive=true; export_arm=true; + export_arm64=false; export_x86=false; @@ -3162,6 +3172,7 @@ public: bool export_x86 = p_preset->get("architecture/x86"); bool export_arm = p_preset->get("architecture/arm"); + bool export_arm64 = p_preset->get("architecture/arm64"); bool use_32_fb = p_preset->get("screen/use_32_bits_view"); bool immersive = p_preset->get("screen/immersive_mode"); @@ -3253,6 +3264,10 @@ public: skip = true; } + if (file.match("lib/arm64*/libgodot_android.so") && !export_arm64) { + skip = true; + } + if (file.begins_with("META-INF") && _signed) { skip = true; } diff --git a/platform/android/java_class_wrapper.cpp b/platform/android/java_class_wrapper.cpp index 56a27fa0e0..52ff9cd562 100644 --- a/platform/android/java_class_wrapper.cpp +++ b/platform/android/java_class_wrapper.cpp @@ -190,7 +190,7 @@ bool JavaClass::_call_method(JavaObject *p_instance, const StringName &p_method, argv[i].i = *p_args[i]; } break; case ARG_TYPE_LONG: { - argv[i].j = *p_args[i]; + argv[i].j = (int64_t)*p_args[i]; } break; case ARG_TYPE_FLOAT: { argv[i].f = *p_args[i]; @@ -350,7 +350,7 @@ bool JavaClass::_call_method(JavaObject *p_instance, const StringName &p_method, Array arr = *p_args[i]; jlongArray a = env->NewLongArray(arr.size()); for (int j = 0; j < arr.size(); j++) { - jlong val = arr[j]; + jlong val = (int64_t)arr[j]; env->SetLongArrayRegion(a, j, 1, &val); } argv[i].l = a; @@ -460,9 +460,9 @@ bool JavaClass::_call_method(JavaObject *p_instance, const StringName &p_method, case ARG_TYPE_LONG: { if (method->_static) { - ret = env->CallStaticLongMethodA(_class, method->method, argv); + ret = (int64_t)env->CallStaticLongMethodA(_class, method->method, argv); } else { - ret = env->CallLongMethodA(p_instance->instance, method->method, argv); + ret = (int64_t)env->CallLongMethodA(p_instance->instance, method->method, argv); } } break; @@ -680,7 +680,7 @@ bool JavaClass::_convert_object_to_variant(JNIEnv *env, jobject obj, Variant &va } break; case ARG_TYPE_LONG | ARG_NUMBER_CLASS_BIT: { - var = env->CallLongMethod(obj, JavaClassWrapper::singleton->Long_longValue); + var = (int64_t)env->CallLongMethod(obj, JavaClassWrapper::singleton->Long_longValue); return true; } break; @@ -802,7 +802,7 @@ bool JavaClass::_convert_object_to_variant(JNIEnv *env, jobject obj, Variant &va jlong val; env->GetLongArrayRegion((jlongArray)arr, 0, 1, &val); - ret.push_back(val); + ret.push_back((int64_t)val); } var = ret; |