Skip to content

Commit 6f071a8

Browse files
committed
Export: Modify template without rcedit
1 parent 978b387 commit 6f071a8

File tree

6 files changed

+904
-112
lines changed

6 files changed

+904
-112
lines changed

editor/editor_property_name_processor.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,6 @@ EditorPropertyNameProcessor::EditorPropertyNameProcessor() {
258258
capitalize_string_remaps["ppc64"] = "ppc64";
259259
capitalize_string_remaps["pvrtc"] = "PVRTC";
260260
capitalize_string_remaps["pvs"] = "PVS";
261-
capitalize_string_remaps["rcedit"] = "rcedit";
262261
capitalize_string_remaps["rcodesign"] = "rcodesign";
263262
capitalize_string_remaps["rdo"] = "RDO";
264263
capitalize_string_remaps["rgb"] = "RGB";
@@ -312,7 +311,6 @@ EditorPropertyNameProcessor::EditorPropertyNameProcessor() {
312311
capitalize_string_remaps["webp"] = "WebP";
313312
capitalize_string_remaps["webrtc"] = "WebRTC";
314313
capitalize_string_remaps["websocket"] = "WebSocket";
315-
capitalize_string_remaps["wine"] = "wine";
316314
capitalize_string_remaps["wintab"] = "WinTab";
317315
capitalize_string_remaps["winink"] = "Windows Ink";
318316
capitalize_string_remaps["wifi"] = "Wi-Fi";

platform/windows/export/export.cpp

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -40,19 +40,12 @@ void register_windows_exporter_types() {
4040

4141
void register_windows_exporter() {
4242
// TODO: Move to editor_settings.cpp
43-
#ifndef ANDROID_ENABLED
44-
EDITOR_DEF_BASIC("export/windows/rcedit", "");
45-
EditorSettings::get_singleton()->add_property_hint(PropertyInfo(Variant::STRING, "export/windows/rcedit", PROPERTY_HINT_GLOBAL_FILE, "*.exe"));
4643
#ifdef WINDOWS_ENABLED
4744
EDITOR_DEF_BASIC("export/windows/signtool", "");
4845
EditorSettings::get_singleton()->add_property_hint(PropertyInfo(Variant::STRING, "export/windows/signtool", PROPERTY_HINT_GLOBAL_FILE, "*.exe"));
4946
#else
5047
EDITOR_DEF_BASIC("export/windows/osslsigncode", "");
5148
EditorSettings::get_singleton()->add_property_hint(PropertyInfo(Variant::STRING, "export/windows/osslsigncode", PROPERTY_HINT_GLOBAL_FILE));
52-
// On non-Windows we need WINE to run rcedit
53-
EDITOR_DEF_BASIC("export/windows/wine", "");
54-
EditorSettings::get_singleton()->add_property_hint(PropertyInfo(Variant::STRING, "export/windows/wine", PROPERTY_HINT_GLOBAL_FILE));
55-
#endif
5649
#endif
5750

5851
Ref<EditorExportPlatformWindows> platform;

platform/windows/export/export_plugin.cpp

Lines changed: 6 additions & 102 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232

3333
#include "logo_svg.gen.h"
3434
#include "run_icon_svg.gen.h"
35+
#include "template_modifier.h"
3536

3637
#include "core/config/project_settings.h"
3738
#include "core/io/image_loader.h"
@@ -188,10 +189,10 @@ Error EditorExportPlatformWindows::sign_shared_object(const Ref<EditorExportPres
188189

189190
Error EditorExportPlatformWindows::modify_template(const Ref<EditorExportPreset> &p_preset, bool p_debug, const String &p_path, BitField<EditorExportPlatform::DebugFlags> p_flags) {
190191
if (p_preset->get("application/modify_resources")) {
191-
_rcedit_add_data(p_preset, p_path, false);
192+
_add_data(p_preset, p_path, false);
192193
String wrapper_path = p_path.get_basename() + ".console.exe";
193194
if (FileAccess::exists(wrapper_path)) {
194-
_rcedit_add_data(p_preset, wrapper_path, true);
195+
_add_data(p_preset, wrapper_path, true);
195196
}
196197
}
197198
return OK;
@@ -502,32 +503,7 @@ void EditorExportPlatformWindows::get_export_options(List<ExportOption> *r_optio
502503
r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "ssh_remote_deploy/cleanup_script", PROPERTY_HINT_MULTILINE_TEXT), cleanup_script));
503504
}
504505

505-
Error EditorExportPlatformWindows::_rcedit_add_data(const Ref<EditorExportPreset> &p_preset, const String &p_path, bool p_console_icon) {
506-
String rcedit_path = EDITOR_GET("export/windows/rcedit");
507-
508-
if (rcedit_path != String() && !FileAccess::exists(rcedit_path)) {
509-
add_message(EXPORT_MESSAGE_WARNING, TTR("Resources Modification"), vformat(TTR("Could not find rcedit executable at \"%s\"."), rcedit_path));
510-
return ERR_FILE_NOT_FOUND;
511-
}
512-
513-
if (rcedit_path == String()) {
514-
rcedit_path = "rcedit"; // try to run rcedit from PATH
515-
}
516-
517-
#ifndef WINDOWS_ENABLED
518-
// On non-Windows we need WINE to run rcedit
519-
String wine_path = EDITOR_GET("export/windows/wine");
520-
521-
if (!wine_path.is_empty() && !FileAccess::exists(wine_path)) {
522-
add_message(EXPORT_MESSAGE_WARNING, TTR("Resources Modification"), vformat(TTR("Could not find wine executable at \"%s\"."), wine_path));
523-
return ERR_FILE_NOT_FOUND;
524-
}
525-
526-
if (wine_path.is_empty()) {
527-
wine_path = "wine"; // try to run wine from PATH
528-
}
529-
#endif
530-
506+
Error EditorExportPlatformWindows::_add_data(const Ref<EditorExportPreset> &p_preset, const String &p_path, bool p_console_icon) {
531507
String icon_path;
532508
if (p_preset->get("application/icon") != "") {
533509
icon_path = p_preset->get("application/icon");
@@ -545,87 +521,20 @@ Error EditorExportPlatformWindows::_rcedit_add_data(const Ref<EditorExportPreset
545521
}
546522
}
547523

548-
String tmp_icon_path = EditorPaths::get_singleton()->get_temp_dir().path_join("_rcedit.ico");
524+
String tmp_icon_path = EditorPaths::get_singleton()->get_temp_dir().path_join("_tmp.ico");
549525
if (!icon_path.is_empty()) {
550526
if (_process_icon(p_preset, icon_path, tmp_icon_path) != OK) {
551527
add_message(EXPORT_MESSAGE_WARNING, TTR("Resources Modification"), vformat(TTR("Invalid icon file \"%s\"."), icon_path));
552528
icon_path = String();
553529
}
554530
}
555531

556-
String file_version = p_preset->get_version("application/file_version", true);
557-
String product_version = p_preset->get_version("application/product_version", true);
558-
String company_name = p_preset->get("application/company_name");
559-
String product_name = p_preset->get("application/product_name");
560-
String file_description = p_preset->get("application/file_description");
561-
String copyright = p_preset->get("application/copyright");
562-
String trademarks = p_preset->get("application/trademarks");
563-
String comments = p_preset->get("application/comments");
564-
565-
List<String> args;
566-
args.push_back(p_path);
567-
if (!icon_path.is_empty()) {
568-
args.push_back("--set-icon");
569-
args.push_back(tmp_icon_path);
570-
}
571-
if (!file_version.is_empty()) {
572-
args.push_back("--set-file-version");
573-
args.push_back(file_version);
574-
}
575-
if (!product_version.is_empty()) {
576-
args.push_back("--set-product-version");
577-
args.push_back(product_version);
578-
}
579-
if (!company_name.is_empty()) {
580-
args.push_back("--set-version-string");
581-
args.push_back("CompanyName");
582-
args.push_back(company_name);
583-
}
584-
if (!product_name.is_empty()) {
585-
args.push_back("--set-version-string");
586-
args.push_back("ProductName");
587-
args.push_back(product_name);
588-
}
589-
if (!file_description.is_empty()) {
590-
args.push_back("--set-version-string");
591-
args.push_back("FileDescription");
592-
args.push_back(file_description);
593-
}
594-
if (!copyright.is_empty()) {
595-
args.push_back("--set-version-string");
596-
args.push_back("LegalCopyright");
597-
args.push_back(copyright);
598-
}
599-
if (!trademarks.is_empty()) {
600-
args.push_back("--set-version-string");
601-
args.push_back("LegalTrademarks");
602-
args.push_back(trademarks);
603-
}
604-
605-
#ifndef WINDOWS_ENABLED
606-
// On non-Windows we need WINE to run rcedit
607-
args.push_front(rcedit_path);
608-
rcedit_path = wine_path;
609-
#endif
610-
611-
String str;
612-
Error err = OS::get_singleton()->execute(rcedit_path, args, &str, nullptr, true);
532+
TemplateModifier::modify(p_preset, p_path, tmp_icon_path);
613533

614534
if (FileAccess::exists(tmp_icon_path)) {
615535
DirAccess::remove_file_or_error(tmp_icon_path);
616536
}
617537

618-
if (err != OK || str.contains("not found") || str.contains("not recognized")) {
619-
add_message(EXPORT_MESSAGE_WARNING, TTR("Resources Modification"), TTR("Could not start rcedit executable. Configure rcedit path in the Editor Settings (Export > Windows > rcedit), or disable \"Application > Modify Resources\" in the export preset."));
620-
return err;
621-
}
622-
print_line("rcedit (" + p_path + "): " + str);
623-
624-
if (str.contains("Fatal error")) {
625-
add_message(EXPORT_MESSAGE_WARNING, TTR("Resources Modification"), vformat(TTR("rcedit failed to modify executable: %s."), str));
626-
return FAILED;
627-
}
628-
629538
return OK;
630539
}
631540

@@ -823,11 +732,6 @@ bool EditorExportPlatformWindows::has_valid_export_configuration(const Ref<Edito
823732
}
824733
}
825734

826-
String rcedit_path = EDITOR_GET("export/windows/rcedit");
827-
if (p_preset->get("application/modify_resources") && rcedit_path.is_empty()) {
828-
err += TTR("The rcedit tool must be configured in the Editor Settings (Export > Windows > rcedit) to change the icon or app information data.") + "\n";
829-
}
830-
831735
if (!err.is_empty()) {
832736
r_error = err;
833737
}

platform/windows/export/export_plugin.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ class EditorExportPlatformWindows : public EditorExportPlatformPC {
6969
int menu_options = 0;
7070

7171
Error _process_icon(const Ref<EditorExportPreset> &p_preset, const String &p_src_path, const String &p_dst_path);
72-
Error _rcedit_add_data(const Ref<EditorExportPreset> &p_preset, const String &p_path, bool p_console_icon);
72+
Error _add_data(const Ref<EditorExportPreset> &p_preset, const String &p_path, bool p_console_icon);
7373
Error _code_sign(const Ref<EditorExportPreset> &p_preset, const String &p_path);
7474

7575
String _get_exe_arch(const String &p_path) const;

0 commit comments

Comments
 (0)