diff options
| author | Mikael Hermansson <mikael@hermansson.io> | 2024-06-12 22:26:12 +0200 |
|---|---|---|
| committer | Mikael Hermansson <mikael@hermansson.io> | 2024-06-12 22:26:41 +0200 |
| commit | 6d68362f2f7a4612a0ec4df7996b16aa2d0b0def (patch) | |
| tree | 4589479de7211e9da2bd9e3d1a8f3f2a112dffd6 /platform/macos/export | |
| parent | 475248d99df89fc29032a42f1d29ad4cef49c8b5 (diff) | |
| download | redot-engine-6d68362f2f7a4612a0ec4df7996b16aa2d0b0def.tar.gz | |
Fix issues related to code-signing for macOS exports
Diffstat (limited to 'platform/macos/export')
| -rw-r--r-- | platform/macos/export/codesign.cpp | 13 | ||||
| -rw-r--r-- | platform/macos/export/export_plugin.cpp | 24 |
2 files changed, 31 insertions, 6 deletions
diff --git a/platform/macos/export/codesign.cpp b/platform/macos/export/codesign.cpp index 082c0abea7..72d496b04d 100644 --- a/platform/macos/export/codesign.cpp +++ b/platform/macos/export/codesign.cpp @@ -312,6 +312,10 @@ bool CodeSignCodeResources::add_folder_recursive(const String &p_root, const Str info_path = path.path_join(vformat("Versions/%s/Resources/Info.plist", fmw_ver)); main_exe = path.path_join(vformat("Versions/%s", fmw_ver)); bundle = true; + } else if (da->file_exists(path.path_join("Resources/Info.plist"))) { + info_path = path.path_join("Resources/Info.plist"); + main_exe = path; + bundle = true; } else if (da->file_exists(path.path_join("Info.plist"))) { info_path = path.path_join("Info.plist"); main_exe = path; @@ -1309,7 +1313,7 @@ Error CodeSign::_codesign_file(bool p_use_hardened_runtime, bool p_force, const cr.add_rule2("^_CodeSignature", "omit", 2000, false); cr.add_rule2("^CodeResources", "omit", 2000, false); } else { - cr.add_rule1("^Resources/"); + cr.add_rule1("^Resources($|/)"); cr.add_rule1("^Resources/.*\\.lproj/", "optional", 1000); cr.add_rule1("^Resources/.*\\.lproj/locversion.plist$", "omit", 1100); cr.add_rule1("^Resources/Base\\.lproj/", "", 1010); @@ -1321,7 +1325,7 @@ Error CodeSign::_codesign_file(bool p_use_hardened_runtime, bool p_force, const cr.add_rule2("^.*"); cr.add_rule2("^Info\\.plist$", "omit", 20); cr.add_rule2("^PkgInfo$", "omit", 20); - cr.add_rule2("^Resources/", "", 20); + cr.add_rule2("^Resources($|/)", "", 20); cr.add_rule2("^Resources/.*\\.lproj/", "optional", 1000); cr.add_rule2("^Resources/.*\\.lproj/locversion.plist$", "omit", 1100); cr.add_rule2("^Resources/Base\\.lproj/", "", 1010); @@ -1540,6 +1544,11 @@ Error CodeSign::codesign(bool p_use_hardened_runtime, bool p_force, const String main_exe = p_path.path_join(vformat("Versions/%s", fmw_ver)); bundle_path = p_path.path_join(vformat("Versions/%s", fmw_ver)); bundle = true; + } else if (da->file_exists(p_path.path_join("Resources/Info.plist"))) { + info_path = p_path.path_join("Resources/Info.plist"); + main_exe = p_path; + bundle_path = p_path; + bundle = true; } else if (da->file_exists(p_path.path_join("Info.plist"))) { info_path = p_path.path_join("Info.plist"); main_exe = p_path; diff --git a/platform/macos/export/export_plugin.cpp b/platform/macos/export/export_plugin.cpp index 9c9d8fc1a4..32278ba4a1 100644 --- a/platform/macos/export/export_plugin.cpp +++ b/platform/macos/export/export_plugin.cpp @@ -1237,8 +1237,16 @@ Error EditorExportPlatformMacOS::_code_sign_directory(const Ref<EditorExportPres } if (extensions_to_sign.has(current_file.get_extension())) { - int ftype = MachO::get_filetype(current_file_path); - Error code_sign_error{ _code_sign(p_preset, current_file_path, (ftype == 2 || ftype == 5) ? p_helper_ent_path : p_ent_path, false, (ftype == 2 || ftype == 5)) }; + String ent_path = p_ent_path; + bool set_bundle_id = false; + if (FileAccess::exists(current_file_path)) { + int ftype = MachO::get_filetype(current_file_path); + if (ftype == 2 || ftype == 5) { + ent_path = p_helper_ent_path; + set_bundle_id = true; + } + } + Error code_sign_error{ _code_sign(p_preset, current_file_path, ent_path, false, set_bundle_id) }; if (code_sign_error != OK) { return code_sign_error; } @@ -1358,8 +1366,16 @@ Error EditorExportPlatformMacOS::_copy_and_sign_files(Ref<DirAccess> &dir_access err = _code_sign_directory(p_preset, p_in_app_path, p_ent_path, p_helper_ent_path, p_should_error_on_non_code_sign); } else { if (extensions_to_sign.has(p_in_app_path.get_extension())) { - int ftype = MachO::get_filetype(p_in_app_path); - err = _code_sign(p_preset, p_in_app_path, (ftype == 2 || ftype == 5) ? p_helper_ent_path : p_ent_path, false, (ftype == 2 || ftype == 5)); + String ent_path = p_ent_path; + bool set_bundle_id = false; + if (FileAccess::exists(p_in_app_path)) { + int ftype = MachO::get_filetype(p_in_app_path); + if (ftype == 2 || ftype == 5) { + ent_path = p_helper_ent_path; + set_bundle_id = true; + } + } + err = _code_sign(p_preset, p_in_app_path, ent_path, false, set_bundle_id); } if (dir_access->file_exists(p_in_app_path) && is_executable(p_in_app_path)) { // chmod with 0755 if the file is executable. |
