Skip to content

Commit

Permalink
bugfix: fix bundled plugins on MacOS (#1540) (#1541)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
midwan authored Dec 19, 2024
1 parent f967df0 commit 357cb2d
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 5 deletions.
10 changes: 10 additions & 0 deletions .github/workflows/c-cpp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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: |
Expand Down Expand Up @@ -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: |
Expand Down
8 changes: 4 additions & 4 deletions cmake/macos/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,21 +21,21 @@ add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD
add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_if_different
$<TARGET_FILE:capsimage>
$<TARGET_FILE_DIR:${PROJECT_NAME}>/../Frameworks/$<TARGET_FILE_NAME:capsimage>)
$<TARGET_FILE_DIR:${PROJECT_NAME}>/../Resources/plugins/$<TARGET_FILE_NAME:capsimage>)
add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_if_different
$<TARGET_FILE:floppybridge>
$<TARGET_FILE_DIR:${PROJECT_NAME}>/../Frameworks/$<TARGET_FILE_NAME:floppybridge>)
$<TARGET_FILE_DIR:${PROJECT_NAME}>/../Resources/plugins/$<TARGET_FILE_NAME:floppybridge>)

# Gather all dependencies with dylibbundler
add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD
COMMAND dylibbundler -od -b -x $<TARGET_FILE:${PROJECT_NAME}> -d $<TARGET_FILE_DIR:${PROJECT_NAME}>/../Frameworks/ -p @executable_path/../Frameworks/)

if (NOT "${CMAKE_GENERATOR}" MATCHES "Xcode")
install(FILES $<TARGET_FILE:capsimage>
DESTINATION $<TARGET_FILE_DIR:${PROJECT_NAME}>/../Frameworks/)
DESTINATION $<TARGET_FILE_DIR:${PROJECT_NAME}>/../Resources/plugins/)
install(FILES $<TARGET_FILE:floppybridge>
DESTINATION $<TARGET_FILE_DIR:${PROJECT_NAME}>/../Frameworks/)
DESTINATION $<TARGET_FILE_DIR:${PROJECT_NAME}>/../Resources/plugins/)

# This one contains the gamecontrollersdb.txt file
install(DIRECTORY ${CMAKE_SOURCE_DIR}/controllers
Expand Down
12 changes: 11 additions & 1 deletion src/osdep/amiberry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down

0 comments on commit 357cb2d

Please sign in to comment.