Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Display a warning if device CPU architecture is not active in the export preset. #88611

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 26 additions & 1 deletion editor/editor_run_native.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,16 +79,21 @@ void EditorRunNative::_notification(int p_what) {
}
}

void EditorRunNative::_confirm_run_native() {
run_confirmed = true;
resume_run_native();
}

Error EditorRunNative::start_run_native(int p_id) {
if (p_id < 0) {
return OK;
}

int platform = p_id / 10000;
int idx = p_id % 10000;
resume_id = p_id;

if (!EditorNode::get_singleton()->ensure_main_scene(true)) {
resume_id = p_id;
return OK;
}

Expand All @@ -110,6 +115,22 @@ Error EditorRunNative::start_run_native(int p_id) {
return ERR_UNAVAILABLE;
}

String architecture = eep->get_device_architecture(idx);
if (!run_confirmed && !architecture.is_empty()) {
String preset_arch = "architectures/" + architecture;
bool is_arch_enabled = preset->get(preset_arch);

if (!is_arch_enabled) {
String warning_message = vformat(TTR("Warning: The CPU architecture '%s' is not active in your export preset.\n\n"), Variant(architecture));
warning_message += TTR("Run 'Remote Debug' anyway?");

run_native_confirm->set_text(warning_message);
run_native_confirm->popup_centered();
return OK;
}
}
run_confirmed = false;

emit_signal(SNAME("native_run"), preset);

int flags = 0;
Expand Down Expand Up @@ -174,5 +195,9 @@ EditorRunNative::EditorRunNative() {
add_child(result_dialog);
result_dialog->hide();

run_native_confirm = memnew(ConfirmationDialog);
add_child(run_native_confirm);
run_native_confirm->connect("confirmed", callable_mp(this, &EditorRunNative::_confirm_run_native));

set_process(true);
}
4 changes: 4 additions & 0 deletions editor/editor_run_native.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,16 @@ class EditorRunNative : public HBoxContainer {

RichTextLabel *result_dialog_log = nullptr;
AcceptDialog *result_dialog = nullptr;
ConfirmationDialog *run_native_confirm = nullptr;
bool run_confirmed = false;

MenuButton *remote_debug = nullptr;
bool first = true;

int resume_id = -1;

void _confirm_run_native();

protected:
static void _bind_methods();
void _notification(int p_what);
Expand Down
1 change: 1 addition & 0 deletions editor/export/editor_export_platform.h
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,7 @@ class EditorExportPlatform : public RefCounted {
virtual Ref<ImageTexture> get_option_icon(int p_index) const;
virtual String get_option_label(int p_device) const { return ""; }
virtual String get_option_tooltip(int p_device) const { return ""; }
virtual String get_device_architecture(int p_device) const { return ""; }

enum DebugFlags {
DEBUG_FLAG_DUMB_CLIENT = 1,
Expand Down
9 changes: 8 additions & 1 deletion platform/android/export/export_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,8 @@ void EditorExportPlatformAndroid::_check_for_changes_poll_thread(void *ud) {
} else if (p.begins_with("ro.build.version.sdk=")) {
d.api_level = p.get_slice("=", 1).to_int();
} else if (p.begins_with("ro.product.cpu.abi=")) {
d.description += "CPU: " + p.get_slice("=", 1).strip_edges() + "\n";
d.architecture = p.get_slice("=", 1).strip_edges();
d.description += "CPU: " + d.architecture + "\n";
} else if (p.begins_with("ro.product.manufacturer=")) {
d.description += "Manufacturer: " + p.get_slice("=", 1).strip_edges() + "\n";
} else if (p.begins_with("ro.board.platform=")) {
Expand Down Expand Up @@ -1992,6 +1993,12 @@ String EditorExportPlatformAndroid::get_option_tooltip(int p_index) const {
return s;
}

String EditorExportPlatformAndroid::get_device_architecture(int p_index) const {
ERR_FAIL_INDEX_V(p_index, devices.size(), "");
MutexLock lock(device_lock);
return devices[p_index].architecture;
}

Error EditorExportPlatformAndroid::run(const Ref<EditorExportPreset> &p_preset, int p_device, int p_debug_flags) {
ERR_FAIL_INDEX_V(p_device, devices.size(), ERR_INVALID_PARAMETER);

Expand Down
3 changes: 3 additions & 0 deletions platform/android/export/export_plugin.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ class EditorExportPlatformAndroid : public EditorExportPlatform {
String name;
String description;
int api_level = 0;
String architecture;
};

struct APKExportData {
Expand Down Expand Up @@ -221,6 +222,8 @@ class EditorExportPlatformAndroid : public EditorExportPlatform {

virtual String get_option_tooltip(int p_index) const override;

virtual String get_device_architecture(int p_index) const override;

virtual Error run(const Ref<EditorExportPreset> &p_preset, int p_device, int p_debug_flags) override;

virtual Ref<Texture2D> get_run_icon() const override;
Expand Down
Loading