From 357cb2de4aefd8151f29ac6452c0facbbc6b88e2 Mon Sep 17 00:00:00 2001 From: Dimitris Panokostas Date: Thu, 19 Dec 2024 16:38:38 +0100 Subject: [PATCH] bugfix: fix bundled plugins on MacOS (#1540) (#1541) The bundled plugins of capsimg and floppybridge, were not included in the final app bundle. Furthermore, they need to be signed with the same digital certificate, otherwise MacOS will block them from loading. --- .github/workflows/c-cpp.yml | 10 ++++++++++ cmake/macos/CMakeLists.txt | 8 ++++---- src/osdep/amiberry.cpp | 12 +++++++++++- 3 files changed, 25 insertions(+), 5 deletions(-) diff --git a/.github/workflows/c-cpp.yml b/.github/workflows/c-cpp.yml index 7735e4379..b4608e2ee 100644 --- a/.github/workflows/c-cpp.yml +++ b/.github/workflows/c-cpp.yml @@ -58,6 +58,11 @@ jobs: codesign -s "Developer ID Application: Dimitris Panokostas (5GQP72592A)" -f -o runtime,hard $file fi done + for file in build/Amiberry.app/Contents/Resources/plugins/*.dylib; do + if [ -f "$file" ]; then + codesign -s "Developer ID Application: Dimitris Panokostas (5GQP72592A)" -f -o runtime,hard $file + fi + done - name: Codesign the app run: | @@ -140,6 +145,11 @@ jobs: codesign -s "Developer ID Application: Dimitris Panokostas (5GQP72592A)" -f -o runtime,hard $file fi done + for file in build/Amiberry.app/Contents/Resources/plugins/*.dylib; do + if [ -f "$file" ]; then + codesign -s "Developer ID Application: Dimitris Panokostas (5GQP72592A)" -f -o runtime,hard $file + fi + done - name: Codesign the app run: | diff --git a/cmake/macos/CMakeLists.txt b/cmake/macos/CMakeLists.txt index 1de6697f4..983135854 100644 --- a/cmake/macos/CMakeLists.txt +++ b/cmake/macos/CMakeLists.txt @@ -21,11 +21,11 @@ add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_if_different $ - $/../Frameworks/$) + $/../Resources/plugins/$) add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_if_different $ - $/../Frameworks/$) + $/../Resources/plugins/$) # Gather all dependencies with dylibbundler add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD @@ -33,9 +33,9 @@ add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD if (NOT "${CMAKE_GENERATOR}" MATCHES "Xcode") install(FILES $ - DESTINATION $/../Frameworks/) + DESTINATION $/../Resources/plugins/) install(FILES $ - DESTINATION $/../Frameworks/) + DESTINATION $/../Resources/plugins/) # This one contains the gamecontrollersdb.txt file install(DIRECTORY ${CMAKE_SOURCE_DIR}/controllers diff --git a/src/osdep/amiberry.cpp b/src/osdep/amiberry.cpp index f70ad2116..ac9f76ce8 100644 --- a/src/osdep/amiberry.cpp +++ b/src/osdep/amiberry.cpp @@ -4006,7 +4006,17 @@ void create_missing_amiberry_folders() if (!my_existsdir(config_path.c_str())) my_mkdir(config_path.c_str()); if (!my_existsdir(plugins_dir.c_str())) - my_mkdir(plugins_dir.c_str()); + { + my_mkdir(plugins_dir.c_str()); +#ifdef __MACH__ + const std::string bundled_plugins_path = app_directory + "/Resources/plugins/"; + if (my_existsdir(bundled_plugins_path.c_str())) + { + const std::string command = "cp -r " + bundled_plugins_path + "* " + plugins_dir; + system(command.c_str()); + } +#endif + } if (!my_existsdir(controllers_path.c_str())) { my_mkdir(controllers_path.c_str());