diff options
Diffstat (limited to 'platform/android')
-rw-r--r-- | platform/android/SCsub | 6 | ||||
-rw-r--r-- | platform/android/audio_driver_jandroid.cpp | 4 | ||||
-rw-r--r-- | platform/android/detect.py | 39 | ||||
-rw-r--r-- | platform/android/export/export.cpp | 70 | ||||
-rw-r--r-- | platform/android/godot_android.cpp | 2 | ||||
-rw-r--r-- | platform/android/java_class_wrapper.cpp | 5 | ||||
-rw-r--r-- | platform/android/os_android.cpp | 2 |
7 files changed, 64 insertions, 64 deletions
diff --git a/platform/android/SCsub b/platform/android/SCsub index a65dab9668..31fee5722c 100644 --- a/platform/android/SCsub +++ b/platform/android/SCsub @@ -2,6 +2,8 @@ import shutil from compat import open_utf8 +from distutils.version import LooseVersion +from detect import get_ndk_version Import('env') @@ -169,3 +171,7 @@ if lib_arch_dir != '': 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")) + ndk_version = get_ndk_version(env["ANDROID_NDK_ROOT"]) + if ndk_version != None and LooseVersion(ndk_version) >= LooseVersion("15.0.4075724"): + stl_lib_path = str(env['ANDROID_NDK_ROOT']) + '/sources/cxx-stl/llvm-libc++/libs/' + lib_arch_dir + '/libc++_shared.so' + env_android.Command(out_dir + '/libc++_shared.so', stl_lib_path, Copy("$TARGET", "$SOURCE"))
\ No newline at end of file diff --git a/platform/android/audio_driver_jandroid.cpp b/platform/android/audio_driver_jandroid.cpp index b9f1f1eab0..46bd691290 100644 --- a/platform/android/audio_driver_jandroid.cpp +++ b/platform/android/audio_driver_jandroid.cpp @@ -82,9 +82,7 @@ Error AudioDriverAndroid::init() { int latency = GLOBAL_DEF_RST("audio/output_latency", 25); unsigned int buffer_size = next_power_of_2(latency * mix_rate / 1000); - if (OS::get_singleton()->is_stdout_verbose()) { - print_line("audio buffer size: " + itos(buffer_size)); - } + print_verbose("Audio buffer size: " + itos(buffer_size)); audioBuffer = env->CallObjectMethod(io, _init_audio, mix_rate, buffer_size); diff --git a/platform/android/detect.py b/platform/android/detect.py index ada36e2814..b22e85b2c1 100644 --- a/platform/android/detect.py +++ b/platform/android/detect.py @@ -128,7 +128,7 @@ def configure(env): env.extra_suffix = ".armv7" + env.extra_suffix elif env["android_arch"] == "arm64v8": if get_platform(env["ndk_platform"]) < 21: - print("WARNING: android_arch=arm64v8 is not supported by ndk_platform lower than andorid-21; setting ndk_platform=android-21") + print("WARNING: android_arch=arm64v8 is not supported by ndk_platform lower than android-21; setting ndk_platform=android-21") env["ndk_platform"] = "android-21" env['ARCH'] = 'arch-arm64' target_subpath = "aarch64-linux-android-4.9" @@ -204,18 +204,26 @@ def configure(env): ## Compile flags + if env['android_stl']: + env.Append(CPPFLAGS=["-isystem", env["ANDROID_NDK_ROOT"] + "/sources/cxx-stl/llvm-libc++/include"]) + env.Append(CPPFLAGS=["-isystem", env["ANDROID_NDK_ROOT"] + "/sources/cxx-stl/llvm-libc++abi/include"]) + env.Append(CXXFLAGS=['-frtti',"-std=gnu++14"]) + else: + env.Append(CXXFLAGS=['-fno-rtti', '-fno-exceptions', '-DNO_SAFE_CAST']) + ndk_version = get_ndk_version(env["ANDROID_NDK_ROOT"]) if ndk_version != None and LooseVersion(ndk_version) >= LooseVersion("15.0.4075724"): print("Using NDK unified headers") sysroot = env["ANDROID_NDK_ROOT"] + "/sysroot" - env.Append(CPPFLAGS=["-isystem", sysroot + "/usr/include"]) + env.Append(CPPFLAGS=["--sysroot="+sysroot]) env.Append(CPPFLAGS=["-isystem", sysroot + "/usr/include/" + abi_subpath]) + env.Append(CPPFLAGS=["-isystem", env["ANDROID_NDK_ROOT"] + "/sources/android/support/include"]) # For unified headers this define has to be set manually env.Append(CPPFLAGS=["-D__ANDROID_API__=" + str(get_platform(env['ndk_platform']))]) else: print("Using NDK deprecated headers") env.Append(CPPFLAGS=["-isystem", lib_sysroot + "/usr/include"]) - + env.Append(CPPFLAGS='-fpic -ffunction-sections -funwind-tables -fstack-protector-strong -fvisibility=hidden -fno-strict-aliasing'.split()) env.Append(CPPFLAGS='-DNO_STATVFS -DGLES_ENABLED'.split()) @@ -246,23 +254,24 @@ def configure(env): env.Append(CPPFLAGS=target_opts) env.Append(CPPFLAGS=common_opts) - if env['android_stl']: - env.Append(CPPPATH=[env["ANDROID_NDK_ROOT"] + "/sources/cxx-stl/gnu-libstdc++/4.9/include"]) - env.Append(CPPPATH=[env["ANDROID_NDK_ROOT"] + "/sources/cxx-stl/gnu-libstdc++/4.9/libs/" + arch_subpath + "/include"]) - env.Append(LIBPATH=[env["ANDROID_NDK_ROOT"] + "/sources/cxx-stl/gnu-libstdc++/4.9/libs/" + arch_subpath]) - env.Append(LIBS=["gnustl_static"]) - else: - env.Append(CXXFLAGS=['-fno-rtti', '-fno-exceptions', '-DNO_SAFE_CAST']) - ## Link flags - - env['LINKFLAGS'] = ['-shared', '--sysroot=' + lib_sysroot, '-Wl,--warn-shared-textrel'] + if ndk_version != None and LooseVersion(ndk_version) >= LooseVersion("15.0.4075724"): + if LooseVersion(ndk_version) >= LooseVersion("17.1.4828580"): + env.Append(LINKFLAGS=['-Wl,--exclude-libs,libgcc.a','-Wl,--exclude-libs,libatomic.a','-nostdlib++']) + env.Append(LINKFLAGS=['-shared', '--sysroot=' + lib_sysroot, '-Wl,--warn-shared-textrel']) + env.Append(LIBPATH=[env["ANDROID_NDK_ROOT"] + "/sources/cxx-stl/llvm-libc++/libs/"+arch_subpath+"/"]) + env.Append(LINKFLAGS=[env["ANDROID_NDK_ROOT"] +"/sources/cxx-stl/llvm-libc++/libs/"+arch_subpath+"/libandroid_support.a"]) + env.Append(LINKFLAGS=[env["ANDROID_NDK_ROOT"] +"/sources/cxx-stl/llvm-libc++/libs/"+arch_subpath+"/libc++_shared.so"]) + else: + env.Append(LINKFLAGS=['-shared', '--sysroot=' + lib_sysroot, '-Wl,--warn-shared-textrel']) + if mt_link: + env.Append(LINKFLAGS=['-Wl,--threads']) + if env["android_arch"] == "armv7": env.Append(LINKFLAGS='-Wl,--fix-cortex-a8'.split()) env.Append(LINKFLAGS='-Wl,--no-undefined -Wl,-z,noexecstack -Wl,-z,relro -Wl,-z,now'.split()) env.Append(LINKFLAGS='-Wl,-soname,libgodot_android.so -Wl,--gc-sections'.split()) - if mt_link: - env.Append(LINKFLAGS=['-Wl,--threads']) + env.Append(LINKFLAGS=target_opts) env.Append(LINKFLAGS=common_opts) diff --git a/platform/android/export/export.cpp b/platform/android/export/export.cpp index 9ad0219746..b76b0d5dbe 100644 --- a/platform/android/export/export.cpp +++ b/platform/android/export/export.cpp @@ -257,7 +257,6 @@ class EditorExportAndroid : public EditorExportPlatform { if (dpos == -1) continue; d = d.substr(0, dpos).strip_edges(); - //print_line("found device: "+d); ldevices.push_back(d); } @@ -345,8 +344,6 @@ class EditorExportAndroid : public EditorExportPlatform { } d.name = vendor + " " + device; - //print_line("name: "+d.name); - //print_line("description: "+d.description); } ndevices.push_back(d); @@ -671,19 +668,14 @@ class EditorExportAndroid : public EditorExportPlatform { ucstring.write[len] = 0; string_table.write[i] = ucstring.ptr(); } - - //print_line("String "+itos(i)+": "+string_table[i]); } for (uint32_t i = string_end; i < (ofs + size); i++) { stable_extra.push_back(p_manifest[i]); } - //printf("stable extra: %i\n",int(stable_extra.size())); string_table_ends = ofs + size; - //print_line("STABLE SIZE: "+itos(size)+" ACTUAL: "+itos(string_table_ends)); - } break; case CHUNK_XML_START_TAG: { @@ -714,35 +706,25 @@ class EditorExportAndroid : public EditorExportPlatform { //replace project information if (tname == "manifest" && attrname == "package") { - - print_line("FOUND package"); string_table.write[attr_value] = get_package_name(package_name); } - if (tname == "manifest" && /*nspace=="android" &&*/ attrname == "versionCode") { - - print_line("FOUND versionCode"); + if (tname == "manifest" && attrname == "versionCode") { encode_uint32(version_code, &p_manifest.write[iofs + 16]); } - if (tname == "manifest" && /*nspace=="android" &&*/ attrname == "versionName") { - - print_line("FOUND versionName"); + if (tname == "manifest" && attrname == "versionName") { if (attr_value == 0xFFFFFFFF) { WARN_PRINT("Version name in a resource, should be plaintext") } else string_table.write[attr_value] = version_name; } - if (tname == "activity" && /*nspace=="android" &&*/ attrname == "screenOrientation") { + if (tname == "activity" && attrname == "screenOrientation") { encode_uint32(orientation == 0 ? 0 : 1, &p_manifest.write[iofs + 16]); } - if (tname == "uses-feature" && /*nspace=="android" &&*/ attrname == "glEsVersion") { - print_line("version number: " + itos(decode_uint32(&p_manifest[iofs + 16]))); - } - if (tname == "supports-screens") { if (attrname == "smallScreens") { @@ -773,7 +755,6 @@ class EditorExportAndroid : public EditorExportPlatform { String tname = string_table[name]; if (tname == "manifest") { - print_line("Found manifest end"); // save manifest ending so we can restore it Vector<uint8_t> manifest_end; @@ -913,8 +894,6 @@ class EditorExportAndroid : public EditorExportPlatform { encode_uint32(string_table.size(), &ret.write[16]); //update new number of strings encode_uint32(string_data_offset - 8, &ret.write[28]); //update new string data offset - //print_line("file size: "+itos(ret.size())); - p_manifest = ret; } @@ -956,7 +935,6 @@ class EditorExportAndroid : public EditorExportPlatform { void _fix_resources(const Ref<EditorExportPreset> &p_preset, Vector<uint8_t> &p_manifest) { const int UTF8_FLAG = 0x00000100; - print_line("*******************GORRRGLE***********************"); uint32_t string_block_len = decode_uint32(&p_manifest[16]); uint32_t string_count = decode_uint32(&p_manifest[20]); @@ -1086,16 +1064,15 @@ public: virtual void get_export_options(List<ExportOption> *r_options) { - /*r_options->push_back(ExportOption(PropertyInfo(Variant::INT, "graphics/api", PROPERTY_HINT_ENUM, "OpenGL ES 2.0,OpenGL ES 3.0"), 1));*/ r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "graphics/32_bits_framebuffer"), true)); r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "one_click_deploy/clear_previous_install"), true)); - r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "custom_package/debug", PROPERTY_HINT_GLOBAL_FILE, "apk"), "")); - r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "custom_package/release", PROPERTY_HINT_GLOBAL_FILE, "apk"), "")); + r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "custom_package/debug", PROPERTY_HINT_GLOBAL_FILE, "*.apk"), "")); + r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "custom_package/release", PROPERTY_HINT_GLOBAL_FILE, "*.apk"), "")); r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "command_line/extra_args"), "")); r_options->push_back(ExportOption(PropertyInfo(Variant::INT, "version/code", PROPERTY_HINT_RANGE, "1,4096,1,or_greater"), 1)); r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "version/name"), "1.0")); - r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "package/unique_name"), "org.godotengine.$genname")); - r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "package/name"), "")); + r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "package/unique_name", PROPERTY_HINT_PLACEHOLDER_TEXT, "com.example.$genname"), "")); + r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "package/name", PROPERTY_HINT_PLACEHOLDER_TEXT, "Game Name"), "")); r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "package/signed"), true)); r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "screen/immersive_mode"), true)); r_options->push_back(ExportOption(PropertyInfo(Variant::INT, "screen/orientation", PROPERTY_HINT_ENUM, "Landscape,Portrait"), 0)); @@ -1105,10 +1082,10 @@ public: r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "screen/support_xlarge"), true)); for (int i = 0; i < sizeof(launcher_icons) / sizeof(launcher_icons[0]); ++i) { - r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, launcher_icons[i].option_id, PROPERTY_HINT_FILE, "png"), "")); + r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, launcher_icons[i].option_id, PROPERTY_HINT_FILE, "*.png"), "")); } - r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "keystore/release", PROPERTY_HINT_GLOBAL_FILE, "keystore"), "")); + r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "keystore/release", PROPERTY_HINT_GLOBAL_FILE, "*.keystore"), "")); r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "keystore/release_user"), "")); r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "keystore/release_password"), "")); r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "apk_expansion/enable"), false)); @@ -1133,8 +1110,6 @@ public: r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "user_permissions/" + itos(i)), false)); } - - //r_options->push_back( PropertyInfo( Variant::INT, "resources/pack_mode", PROPERTY_HINT_ENUM,"Copy,Single Exec.,Pack (.pck),Bundles (Optical)")); } virtual String get_name() const { @@ -1237,8 +1212,8 @@ public: err = OS::get_singleton()->execute(adb, args, true, NULL, NULL, &rv); } - print_line("Installing into device (please wait..): " + devices[p_device].name); - ep.step("Installing to Device (please wait..)..", 2); + print_line("Installing to device (please wait...): " + devices[p_device].name); + ep.step("Installing to device (please wait...)", 2); args.clear(); args.push_back("-s"); @@ -1336,12 +1311,28 @@ public: virtual bool can_export(const Ref<EditorExportPreset> &p_preset, String &r_error, bool &r_missing_templates) const { + String err; r_missing_templates = find_export_template("android_debug.apk") == String() || find_export_template("android_release.apk") == String(); + if (p_preset->get("custom_package/debug") != "") { + if (FileAccess::exists(p_preset->get("custom_package/debug"))) { + r_missing_templates = false; + } else { + err += "Custom debug package not found.\n"; + } + } + + if (p_preset->get("custom_package/release") != "") { + if (FileAccess::exists(p_preset->get("custom_package/release"))) { + r_missing_templates = false; + } else { + err += "Custom release package not found.\n"; + } + } + bool valid = !r_missing_templates; String adb = EditorSettings::get_singleton()->get("export/android/adb"); - String err; if (!FileAccess::exists(adb)) { @@ -1847,6 +1838,9 @@ public: r_features->push_back("Android"); } + virtual void resolve_platform_feature_priorities(const Ref<EditorExportPreset> &p_preset, Set<String> &p_features) { + } + EditorExportAndroid() { Ref<Image> img = memnew(Image(_android_logo)); @@ -1883,7 +1877,7 @@ void register_android_exporter() { EDITOR_DEF("export/android/jarsigner", ""); EditorSettings::get_singleton()->add_property_hint(PropertyInfo(Variant::STRING, "export/android/jarsigner", PROPERTY_HINT_GLOBAL_FILE, exe_ext)); EDITOR_DEF("export/android/debug_keystore", ""); - EditorSettings::get_singleton()->add_property_hint(PropertyInfo(Variant::STRING, "export/android/debug_keystore", PROPERTY_HINT_GLOBAL_FILE, "keystore")); + EditorSettings::get_singleton()->add_property_hint(PropertyInfo(Variant::STRING, "export/android/debug_keystore", PROPERTY_HINT_GLOBAL_FILE, "*.keystore")); EDITOR_DEF("export/android/debug_keystore_user", "androiddebugkey"); EDITOR_DEF("export/android/debug_keystore_pass", "android"); EDITOR_DEF("export/android/force_system_user", false); diff --git a/platform/android/godot_android.cpp b/platform/android/godot_android.cpp index 0e5f4fb93a..061e05f5ee 100644 --- a/platform/android/godot_android.cpp +++ b/platform/android/godot_android.cpp @@ -928,7 +928,7 @@ JNIEXPORT void JNICALL Java_org_godotengine_godot_Godot_registerMethod(JNIEnv *e jmethodID mid = env->GetMethodID(cls, mname.ascii().get_data(), cs.ascii().get_data()); if (!mid) { - print_line("FAILED GETTING METHOD ID " + mname); + print_line("RegisterMethod: Failed getting method ID: " + mname); } s->add_method(mname, mid, types, get_jni_type(retval)); diff --git a/platform/android/java_class_wrapper.cpp b/platform/android/java_class_wrapper.cpp index 446a5911e5..022ccb7d89 100644 --- a/platform/android/java_class_wrapper.cpp +++ b/platform/android/java_class_wrapper.cpp @@ -554,7 +554,6 @@ bool JavaClassWrapper::_get_type_sig(JNIEnv *env, jobject obj, uint32_t &sig, St jstring name2 = (jstring)env->CallObjectMethod(obj, Class_getName); String str_type = env->GetStringUTFChars(name2, NULL); - print_line("name: " + str_type); env->DeleteLocalRef(name2); uint32_t t = 0; @@ -1191,9 +1190,6 @@ Ref<JavaClass> JavaClassWrapper::wrap(const String &p_class) { env->DeleteLocalRef(obj); env->DeleteLocalRef(param_types); env->DeleteLocalRef(return_type); - - //args[i] = _jobject_to_variant(env, obj); - //print_line("\targ"+itos(i)+": "+Variant::get_type_name(args[i].get_type())); }; env->DeleteLocalRef(methods); @@ -1210,7 +1206,6 @@ Ref<JavaClass> JavaClassWrapper::wrap(const String &p_class) { jstring name = (jstring)env->CallObjectMethod(obj, Field_getName); String str_field = env->GetStringUTFChars(name, NULL); env->DeleteLocalRef(name); - print_line("FIELD: " + str_field); int mods = env->CallIntMethod(obj, Field_getModifiers); if ((mods & 0x8) && (mods & 0x10) && (mods & 0x1)) { //static final public! diff --git a/platform/android/os_android.cpp b/platform/android/os_android.cpp index f9eda9dff1..c8bdf98923 100644 --- a/platform/android/os_android.cpp +++ b/platform/android/os_android.cpp @@ -337,8 +337,6 @@ void OS_Android::process_event(Ref<InputEvent> p_event) { void OS_Android::process_touch(int p_what, int p_pointer, const Vector<TouchPos> &p_points) { - //print_line("ev: "+itos(p_what)+" pnt: "+itos(p_pointer)+" pointc: "+itos(p_points.size())); - switch (p_what) { case 0: { //gesture begin |