feat: updated godot version

This commit is contained in:
Sara Gerretsen 2026-04-04 19:38:56 +02:00
parent 0c508b0831
commit 42b028dbb5
4694 changed files with 236470 additions and 401376 deletions

View file

@ -36,24 +36,23 @@
#include "core/config/project_settings.h"
#include "core/io/dir_access.h"
#include "core/io/file_access.h"
#include "core/io/image_loader.h"
#include "core/io/json.h"
#include "core/io/marshalls.h"
#include "core/math/random_pcg.h"
#include "core/os/os.h"
#include "core/os/shared_object.h"
#include "core/string/translation_server.h"
#include "core/version.h"
#include "editor/editor_log.h"
#include "editor/editor_node.h"
#include "editor/export/editor_export.h"
#include "editor/export/editor_export_plugin.h"
#include "editor/editor_string_names.h"
#include "editor/export/export_template_manager.h"
#include "editor/file_system/editor_paths.h"
#include "editor/import/resource_importer_texture_settings.h"
#include "editor/settings/editor_settings.h"
#include "editor/themes/editor_scale.h"
#include "main/splash.gen.h"
#include "scene/resources/image_texture.h"
#include "modules/modules_enabled.gen.h" // IWYU pragma: keep. For mono.
#include "modules/modules_enabled.gen.h" // For mono.
#include "modules/svg/image_loader_svg.h"
#ifdef MODULE_MONO_ENABLED
@ -61,16 +60,11 @@
#endif
#ifdef ANDROID_ENABLED
#include "../java_godot_wrapper.h"
#include "../os_android.h"
#include "android_editor_gradle_runner.h"
#endif
#ifndef ANDROID_ENABLED
#include "core/object/callable_mp.h"
#include "editor/editor_log.h"
#include "editor/editor_string_names.h"
#endif
static const char *ANDROID_PERMS[] = {
"ACCESS_CHECKIN_PROPERTIES",
"ACCESS_COARSE_LOCATION",
@ -293,8 +287,7 @@ static const char *APK_ASSETS_DIRECTORY = "src/main/assets";
static const char *AAB_ASSETS_DIRECTORY = "assetPackInstallTime/src/main/assets";
static const int DEFAULT_MIN_SDK_VERSION = 24; // Should match the value in 'platform/android/java/app/config.gradle#minSdk'
static const int VULKAN_MIN_SDK_VERSION = 29; // Minimum recommended sdk version for Vulkan 1.1 support. See https://developer.android.com/games/develop/vulkan/native-engine-support#recommendations
static const int DEFAULT_TARGET_SDK_VERSION = 36; // Should match the value in 'platform/android/java/app/config.gradle#targetSdk'
static const int DEFAULT_TARGET_SDK_VERSION = 35; // Should match the value in 'platform/android/java/app/config.gradle#targetSdk'
#ifndef ANDROID_ENABLED
void EditorExportPlatformAndroid::_check_for_changes_poll_thread(void *ud) {
@ -472,30 +465,24 @@ void EditorExportPlatformAndroid::_check_for_changes_poll_thread(void *ud) {
}
void EditorExportPlatformAndroid::_update_preset_status() {
bool has_runnable = EditorExport::get_singleton()->get_runnable_preset_for_platform(this).is_valid();
const int preset_count = EditorExport::get_singleton()->get_export_preset_count();
bool has_runnable = false;
for (int i = 0; i < preset_count; i++) {
const Ref<EditorExportPreset> &preset = EditorExport::get_singleton()->get_export_preset(i);
if (preset->get_platform() == this && preset->is_runnable()) {
has_runnable = true;
break;
}
}
if (has_runnable) {
has_runnable_preset.set();
_start_check_for_changes_poll_thread();
} else {
has_runnable_preset.clear();
_stop_check_for_changes_poll_thread();
}
devices_changed.set();
}
void EditorExportPlatformAndroid::_start_check_for_changes_poll_thread() {
quit_request.clear();
if (!check_for_changes_thread.is_started()) {
check_for_changes_thread.start(_check_for_changes_poll_thread, this);
}
}
void EditorExportPlatformAndroid::_stop_check_for_changes_poll_thread() {
quit_request.set();
if (check_for_changes_thread.is_started()) {
check_for_changes_thread.wait_to_finish();
}
}
#endif
String EditorExportPlatformAndroid::get_project_name(const Ref<EditorExportPreset> &p_preset, const String &p_name) const {
@ -834,12 +821,7 @@ Error EditorExportPlatformAndroid::save_apk_file(const Ref<EditorExportPreset> &
return err;
}
String dst_path;
if (ed->pd.salt.length() == 32) {
dst_path = String("assets/") + (simplified_path + ed->pd.salt).sha256_text();
} else {
dst_path = String("assets/") + simplified_path.trim_prefix("res://");
}
const String dst_path = String("assets/") + simplified_path.trim_prefix("res://");
print_verbose("Saving project files from " + simplified_path + " into " + dst_path);
store_in_apk(ed, dst_path, enc_data, _should_compress_asset(simplified_path, enc_data) ? Z_DEFLATED : 0);
@ -999,7 +981,7 @@ void EditorExportPlatformAndroid::_get_manifest_info(const Ref<EditorExportPrese
}
if (_uses_vulkan(p_preset)) {
// Optionally request vulkan hardware level 1 support.
// Require vulkan hardware level 1 support
FeatureInfo vulkan_level = {
"android.hardware.vulkan.level", // name
false, // required
@ -1007,12 +989,11 @@ void EditorExportPlatformAndroid::_get_manifest_info(const Ref<EditorExportPrese
};
r_features.append(vulkan_level);
// Require vulkan version 1.1 if fallback_to_opengl3 is disabled.
bool vulkan_1_1_required = !GLOBAL_GET("rendering/rendering_device/fallback_to_opengl3");
// Require vulkan version 1.0
FeatureInfo vulkan_version = {
"android.hardware.vulkan.version", // name
vulkan_1_1_required, // required
"0x401000" // version - Encoded value for api version 1.1
true, // required
"0x400003" // version - Encoded value for api version 1.0
};
r_features.append(vulkan_version);
}
@ -1223,7 +1204,7 @@ void EditorExportPlatformAndroid::_fix_manifest(const Ref<EditorExportPreset> &p
String package_name = p_preset->get("package/unique_name");
const int screen_orientation =
_get_android_orientation_value(DisplayServerEnums::ScreenOrientation(int(get_project_setting(p_preset, "display/window/handheld/orientation"))));
_get_android_orientation_value(DisplayServer::ScreenOrientation(int(get_project_setting(p_preset, "display/window/handheld/orientation"))));
bool screen_support_small = p_preset->get("screen/support_small");
bool screen_support_normal = p_preset->get("screen/support_normal");
@ -2082,7 +2063,7 @@ String EditorExportPlatformAndroid::get_export_option_warning(const EditorExport
int target_sdk_int = DEFAULT_TARGET_SDK_VERSION;
String min_sdk_str = p_preset->get("gradle_build/min_sdk");
int min_sdk_int = VULKAN_MIN_SDK_VERSION;
int min_sdk_int = DEFAULT_MIN_SDK_VERSION;
if (min_sdk_str.is_valid_int()) {
min_sdk_int = min_sdk_str.to_int();
}
@ -2143,7 +2124,7 @@ void EditorExportPlatformAndroid::get_export_options(List<ExportOption> *r_optio
r_options->push_back(ExportOption(PropertyInfo(Variant::INT, "gradle_build/export_format", PROPERTY_HINT_ENUM, "Export APK,Export AAB"), EXPORT_FORMAT_APK, false, true));
// Using String instead of int to default to an empty string (no override) with placeholder for instructions (see GH-62465).
// This implies doing validation that the string is a proper int.
r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "gradle_build/min_sdk", PROPERTY_HINT_PLACEHOLDER_TEXT, vformat("%d (default)", VULKAN_MIN_SDK_VERSION)), "", false, true));
r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "gradle_build/min_sdk", PROPERTY_HINT_PLACEHOLDER_TEXT, vformat("%d (default)", DEFAULT_MIN_SDK_VERSION)), "", false, true));
r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "gradle_build/target_sdk", PROPERTY_HINT_PLACEHOLDER_TEXT, vformat("%d (default)", DEFAULT_TARGET_SDK_VERSION)), "", false, true));
r_options->push_back(ExportOption(PropertyInfo(Variant::DICTIONARY, "gradle_build/custom_theme_attributes", PROPERTY_HINT_DICTIONARY_TYPE, "String;String"), Dictionary()));
@ -2392,14 +2373,14 @@ Error EditorExportPlatformAndroid::run(const Ref<EditorExportPreset> &p_preset,
String tmp_export_path = EditorPaths::get_singleton()->get_temp_dir().path_join("tmpexport." + uitos(OS::get_singleton()->get_unix_time()) + ".apk");
#define CLEANUP_AND_RETURN(m_err) \
{ \
DirAccess::remove_file_or_error(tmp_export_path); \
if (FileAccess::exists(tmp_export_path + ".idsig")) { \
#define CLEANUP_AND_RETURN(m_err) \
{ \
DirAccess::remove_file_or_error(tmp_export_path); \
if (FileAccess::exists(tmp_export_path + ".idsig")) { \
DirAccess::remove_file_or_error(tmp_export_path + ".idsig"); \
} \
return m_err; \
} \
} \
return m_err; \
} \
((void)0)
// Export to temporary APK before sending to device.
@ -3131,20 +3112,6 @@ bool EditorExportPlatformAndroid::has_valid_project_configuration(const Ref<Edit
err += "\n";
}
String min_sdk_str = p_preset->get("gradle_build/min_sdk");
int min_sdk_int = VULKAN_MIN_SDK_VERSION;
if (!min_sdk_str.is_empty()) { // Empty means no override, nothing to do.
if (min_sdk_str.is_valid_int()) {
min_sdk_int = min_sdk_str.to_int();
}
}
bool fallback_to_opengl3 = GLOBAL_GET("rendering/rendering_device/fallback_to_opengl3");
if (_uses_vulkan(p_preset) && min_sdk_int < VULKAN_MIN_SDK_VERSION && !fallback_to_opengl3) {
// Warning only, so don't override `valid`.
err += vformat(TTR("\"Min SDK\" should be greater or equal to %d for the \"%s\" renderer."), VULKAN_MIN_SDK_VERSION, current_renderer);
err += "\n";
}
String package_name = p_preset->get("package/unique_name");
if (package_name.contains("$genname") && !is_project_name_valid(p_preset)) {
// Warning only, so don't override `valid`.
@ -3577,7 +3544,7 @@ Error EditorExportPlatformAndroid::_generate_sparse_pck_metadata(const Ref<Edito
int64_t pck_start_pos = ftmp->get_position();
uint64_t file_base_ofs = 0;
uint64_t dir_base_ofs = 0;
EditorExportPlatform::_store_header(ftmp, p_preset->get_enc_pck() && p_preset->get_enc_directory(), true, file_base_ofs, dir_base_ofs, p_pack_data.salt);
EditorExportPlatform::_store_header(ftmp, p_preset->get_enc_pck() && p_preset->get_enc_directory(), true, file_base_ofs, dir_base_ofs);
// Write directory.
uint64_t dir_offset = ftmp->get_position();
@ -3784,12 +3751,6 @@ Error EditorExportPlatformAndroid::export_project_helper(const Ref<EditorExportP
} else {
user_data.pd.path = "assets.sparsepck";
user_data.pd.use_sparse_pck = true;
if (p_preset->get_enc_directory()) {
RandomPCG rng = RandomPCG(p_preset->get_seed());
for (int i = 0; i < 32; i++) {
user_data.pd.salt += String::chr(1 + rng.rand() % 254);
}
}
err = export_project_files(p_preset, p_debug, rename_and_store_file_in_gradle_project, nullptr, &user_data, copy_gradle_so);
Vector<uint8_t> enc_data;
@ -3848,7 +3809,7 @@ Error EditorExportPlatformAndroid::export_project_helper(const Ref<EditorExportP
String version_name = p_preset->get_version("version/name");
String min_sdk_version = p_preset->get("gradle_build/min_sdk");
if (!min_sdk_version.is_valid_int()) {
min_sdk_version = itos(VULKAN_MIN_SDK_VERSION);
min_sdk_version = itos(DEFAULT_MIN_SDK_VERSION);
}
String target_sdk_version = p_preset->get("gradle_build/target_sdk");
if (!target_sdk_version.is_valid_int()) {
@ -4102,11 +4063,11 @@ Error EditorExportPlatformAndroid::export_project_helper(const Ref<EditorExportP
String tmp_unaligned_path = EditorPaths::get_singleton()->get_temp_dir().path_join("tmpexport-unaligned." + uitos(OS::get_singleton()->get_unix_time()) + ".apk");
#define CLEANUP_AND_RETURN(m_err) \
{ \
#define CLEANUP_AND_RETURN(m_err) \
{ \
DirAccess::remove_file_or_error(tmp_unaligned_path); \
return m_err; \
} \
return m_err; \
} \
((void)0)
zipFile unaligned_apk = zipOpen2(tmp_unaligned_path.utf8().get_data(), APPEND_STATUS_CREATE, nullptr, &io2);
@ -4297,12 +4258,6 @@ Error EditorExportPlatformAndroid::export_project_helper(const Ref<EditorExportP
ed.apk = unaligned_apk;
ed.pd.path = "assets.sparsepck";
ed.pd.use_sparse_pck = true;
if (p_preset->get_enc_directory()) {
RandomPCG rng = RandomPCG(p_preset->get_seed());
for (int i = 0; i < 32; i++) {
ed.pd.salt += String::chr(1 + rng.rand() % 254);
}
}
err = export_project_files(p_preset, p_debug, save_apk_file, nullptr, &ed, save_apk_so);
Vector<uint8_t> enc_data;
@ -4464,6 +4419,7 @@ void EditorExportPlatformAndroid::initialize() {
devices_changed.set();
_create_editor_debug_keystore_if_needed();
_update_preset_status();
check_for_changes_thread.start(_check_for_changes_poll_thread, this);
use_scrcpy = EditorSettings::get_singleton()->get_project_metadata("android", "use_scrcpy", false);
#else // ANDROID_ENABLED
android_editor_gradle_runner = memnew(AndroidEditorGradleRunner);
@ -4473,7 +4429,10 @@ void EditorExportPlatformAndroid::initialize() {
EditorExportPlatformAndroid::~EditorExportPlatformAndroid() {
#ifndef ANDROID_ENABLED
_stop_check_for_changes_poll_thread();
quit_request.set();
if (check_for_changes_thread.is_started()) {
check_for_changes_thread.wait_to_finish();
}
#else
if (android_editor_gradle_runner) {
memdelete(android_editor_gradle_runner);