Android: Add support for x86_64 architecture

Like arm64v8, this is only supported by API 21 and later,
so we enforce 21 as min API for x86_64.

Part of #25030.

(cherry picked from commit 7f4ee36469)
This commit is contained in:
Rémi Verschelde 2019-01-16 11:16:00 +01:00
parent f2a42e1ae5
commit b768381998
3 changed files with 31 additions and 5 deletions

View File

@ -156,6 +156,8 @@ elif env['android_arch'] == 'arm64v8':
lib_arch_dir = 'arm64-v8a'
elif env['android_arch'] == 'x86':
lib_arch_dir = 'x86'
elif env['android_arch'] == 'x86_64':
lib_arch_dir = 'x86_64'
else:
print('WARN: Architecture not suitable for embedding into APK; keeping .so at \\bin')

View File

@ -26,7 +26,7 @@ def get_opts():
('ANDROID_NDK_ROOT', 'the path to Android NDK',
os.environ.get("ANDROID_NDK_ROOT", 0)),
('ndk_platform', 'compile for platform: (android-<api> , example: android-18)', "android-18"),
('android_arch', 'select compiler architecture: (armv7/armv6/arm64v8/x86)', "armv7"),
('android_arch', 'select compiler architecture: (armv7/armv6/arm64v8/x86/x86_64)', "armv7"),
('android_neon', 'enable neon (armv7 only)', "yes"),
('android_stl', 'enable STL support in android port (for modules)', "no")
]
@ -93,12 +93,9 @@ def configure(env):
ndk_platform = env['ndk_platform']
if env['android_arch'] not in ['armv7', 'armv6', 'arm64v8', 'x86']:
if env['android_arch'] not in ['armv7', 'armv6', 'arm64v8', 'x86', 'x86_64']:
env['android_arch'] = 'armv7'
if env['android_arch'] == 'x86':
env["x86_libtheora_opt_gcc"] = True
if env['PLATFORM'] == 'win32':
env.Tool('gcc')
env['SHLIBSUFFIX'] = '.so'
@ -116,6 +113,17 @@ def configure(env):
target_subpath = "x86-4.9"
abi_subpath = "i686-linux-android"
arch_subpath = "x86"
env["x86_libtheora_opt_gcc"] = True
elif env['android_arch'] == 'x86_64':
if get_platform(env["ndk_platform"]) < 21:
print("WARNING: android_arch=x86_64 is not supported by ndk_platform lower than android-21; setting ndk_platform=android-21")
env["ndk_platform"] = "android-21"
env['ARCH'] = 'arch-x86_64'
env.extra_suffix = ".x86_64" + env.extra_suffix
target_subpath = "x86_64-4.9"
abi_subpath = "x86_64-linux-android"
arch_subpath = "x86_64"
env["x86_libtheora_opt_gcc"] = True
elif env['android_arch'] == 'armv6':
env['ARCH'] = 'arch-arm'
env.extra_suffix = ".armv6" + env.extra_suffix
@ -209,6 +217,11 @@ def configure(env):
target_opts = ['-target', 'i686-none-linux-android']
# The NDK adds this if targeting API < 21, so we can drop it when Godot targets it at least
env.Append(CPPFLAGS=['-mstackrealign'])
elif env['android_arch'] == 'x86_64':
can_vectorize = True
target_opts = ['-target', 'x86_64-none-linux-android']
elif env["android_arch"] == "armv6":
can_vectorize = False
target_opts = ['-target', 'armv6-none-linux-androideabi']

View File

@ -219,6 +219,7 @@ class EditorExportPlatformAndroid : public EditorExportPlatform {
bool export_arm;
bool export_arm64;
bool export_x86;
bool export_x86_64;
String apk_expansion_salt;
String apk_expansion_pkey;
int orientation;
@ -319,6 +320,8 @@ bool EditorExportPlatformAndroid::_set(const StringName &p_name, const Variant &
export_arm64 = p_value;
else if (n == "architecture/x86")
export_x86 = p_value;
else if (n == "architecture/x86_64")
export_x86_64 = p_value;
else if (n == "screen/use_32_bits_view")
use_32_fb = p_value;
else if (n == "screen/immersive_mode")
@ -394,6 +397,8 @@ bool EditorExportPlatformAndroid::_get(const StringName &p_name, Variant &r_ret)
r_ret = export_arm64;
else if (n == "architecture/x86")
r_ret = export_x86;
else if (n == "architecture/x86_64")
r_ret = export_x86_64;
else if (n == "screen/use_32_bits_view")
r_ret = use_32_fb;
else if (n == "screen/immersive_mode")
@ -450,6 +455,7 @@ void EditorExportPlatformAndroid::_get_property_list(List<PropertyInfo> *p_list)
p_list->push_back(PropertyInfo(Variant::BOOL, "architecture/arm"));
p_list->push_back(PropertyInfo(Variant::BOOL, "architecture/arm64"));
p_list->push_back(PropertyInfo(Variant::BOOL, "architecture/x86"));
p_list->push_back(PropertyInfo(Variant::BOOL, "architecture/x86_64"));
p_list->push_back(PropertyInfo(Variant::BOOL, "screen/use_32_bits_view"));
p_list->push_back(PropertyInfo(Variant::BOOL, "screen/immersive_mode"));
p_list->push_back(PropertyInfo(Variant::INT, "screen/orientation", PROPERTY_HINT_ENUM, "Landscape,Portrait"));
@ -1209,6 +1215,10 @@ Error EditorExportPlatformAndroid::export_project(const String &p_path, bool p_d
skip = true;
}
if (file == "lib/x86_64/libgodot_android.so" && !export_x86_64) {
skip = true;
}
if (file.match("lib/armeabi*/libgodot_android.so") && !export_arm) {
skip = true;
}
@ -1869,6 +1879,7 @@ EditorExportPlatformAndroid::EditorExportPlatformAndroid() {
export_arm = true;
export_arm64 = false;
export_x86 = false;
export_x86_64 = false;
device_thread = Thread::create(_device_poll_thread, this);
devices_changed = true;