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

[Windows] Support all possible suffixes for console wrapper #90387

Merged
merged 1 commit into from
Apr 8, 2024
Merged
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
19 changes: 16 additions & 3 deletions editor/export/editor_export_platform_pc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -151,15 +151,28 @@ Error EditorExportPlatformPC::prepare_template(const Ref<EditorExportPreset> &p_
return ERR_FILE_NOT_FOUND;
}

String wrapper_template_path = template_path.get_basename() + "_console.exe";
// Matching the extensions in platform/windows/console_wrapper_windows.cpp
static const char *const wrapper_extensions[] = {
".console.exe",
"_console.exe",
" console.exe",
"console.exe",
nullptr,
};
int con_wrapper_mode = p_preset->get("debug/export_console_wrapper");
bool copy_wrapper = (con_wrapper_mode == 1 && p_debug) || (con_wrapper_mode == 2);

Ref<DirAccess> da = DirAccess::create(DirAccess::ACCESS_FILESYSTEM);
da->make_dir_recursive(p_path.get_base_dir());
Error err = da->copy(template_path, p_path, get_chmod_flags());
if (err == OK && copy_wrapper && FileAccess::exists(wrapper_template_path)) {
err = da->copy(wrapper_template_path, p_path.get_basename() + ".console.exe", get_chmod_flags());
if (err == OK && copy_wrapper) {
for (int i = 0; wrapper_extensions[i]; ++i) {
const String wrapper_path = template_path.get_basename() + wrapper_extensions[i];
if (FileAccess::exists(wrapper_path)) {
err = da->copy(wrapper_path, p_path.get_basename() + ".console.exe", get_chmod_flags());
break;
}
}
}
if (err != OK) {
add_message(EXPORT_MESSAGE_ERROR, TTR("Prepare Template"), TTR("Failed to copy export template."));
Expand Down
Loading