From f37981b83ff7958ec6ead0a8f6711bbf9acc7575 Mon Sep 17 00:00:00 2001 From: bruvzg <7645683+bruvzg@users.noreply.github.com> Date: Fri, 9 Jul 2021 21:24:13 +0300 Subject: [PATCH] [macOS, Mono] Automatically enable JIT entitlements for the Mono exports. --- platform/osx/export/export.cpp | 31 +++++++++++++++++++++++-------- 1 file changed, 23 insertions(+), 8 deletions(-) diff --git a/platform/osx/export/export.cpp b/platform/osx/export/export.cpp index f68ff3201251..ea34b8a24e6d 100644 --- a/platform/osx/export/export.cpp +++ b/platform/osx/export/export.cpp @@ -163,9 +163,13 @@ void EditorExportPlatformOSX::get_export_options(List *r_options) r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "codesign/replace_existing_signature"), true)); r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "codesign/entitlements/custom_file", PROPERTY_HINT_GLOBAL_FILE, "*.plist"), "")); - r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "codesign/entitlements/allow_jit_code_execution"), false)); - r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "codesign/entitlements/allow_unsigned_executable_memory"), false)); - r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "codesign/entitlements/allow_dyld_environment_variables"), false)); + if (!Engine::get_singleton()->has_singleton("GodotSharp")) { + // These entitlements are required to run managed code, and are always enabled in Mono builds. + r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "codesign/entitlements/allow_jit_code_execution"), false)); + r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "codesign/entitlements/allow_unsigned_executable_memory"), false)); + r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "codesign/entitlements/allow_dyld_environment_variables"), false)); + } + r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "codesign/entitlements/disable_library_validation"), false)); r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "codesign/entitlements/audio_input"), false)); r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "codesign/entitlements/camera"), false)); @@ -786,18 +790,29 @@ Error EditorExportPlatformOSX::export_project(const Ref &p_p ent_f->store_line(""); ent_f->store_line(""); ent_f->store_line(""); - if ((bool)p_preset->get("codesign/entitlements/allow_jit_code_execution")) { + if (Engine::get_singleton()->has_singleton("GodotSharp")) { + // These entitlements are required to run managed code, and are always enabled in Mono builds. ent_f->store_line("com.apple.security.cs.allow-jit"); ent_f->store_line(""); - } - if ((bool)p_preset->get("codesign/entitlements/allow_unsigned_executable_memory")) { ent_f->store_line("com.apple.security.cs.allow-unsigned-executable-memory"); ent_f->store_line(""); - } - if ((bool)p_preset->get("codesign/entitlements/allow_dyld_environment_variables")) { ent_f->store_line("com.apple.security.cs.allow-dyld-environment-variables"); ent_f->store_line(""); + } else { + if ((bool)p_preset->get("codesign/entitlements/allow_jit_code_execution")) { + ent_f->store_line("com.apple.security.cs.allow-jit"); + ent_f->store_line(""); + } + if ((bool)p_preset->get("codesign/entitlements/allow_unsigned_executable_memory")) { + ent_f->store_line("com.apple.security.cs.allow-unsigned-executable-memory"); + ent_f->store_line(""); + } + if ((bool)p_preset->get("codesign/entitlements/allow_dyld_environment_variables")) { + ent_f->store_line("com.apple.security.cs.allow-dyld-environment-variables"); + ent_f->store_line(""); + } } + if ((bool)p_preset->get("codesign/entitlements/disable_library_validation")) { ent_f->store_line("com.apple.security.cs.disable-library-validation"); ent_f->store_line("");