From df91ebe513896b62f7113b462394d8a893fa8728 Mon Sep 17 00:00:00 2001 From: Florent Castelli Date: Thu, 2 Feb 2017 03:16:11 +0100 Subject: [PATCH 1/3] macOS: Make deploy-mac.py script idempotent Running the same script twice would update the imports, copy them in the bundle on the first run, and remove them on the second run, resulting in a broken package. --- Tools/deploy-mac.py | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/Tools/deploy-mac.py b/Tools/deploy-mac.py index 80976d3f9a..328ad625cd 100755 --- a/Tools/deploy-mac.py +++ b/Tools/deploy-mac.py @@ -139,23 +139,12 @@ if __name__ == '__main__': installNameTool = args.install_name_tool verbose = args.verbose - try: - shutil.rmtree(os.path.join(args.bundle, 'Contents/Frameworks/')) - except OSError as e: - if e.errno != errno.ENOENT: - raise - for executable in os.listdir(os.path.join(args.bundle, 'Contents/MacOS')): if executable.endswith('.dSYM'): continue fullPath = os.path.join(args.bundle, 'Contents/MacOS/', executable) updateMachO(fullPath, splitPath(os.path.join(args.bundle, 'Contents/MacOS')), splitPath(args.root)) if args.qt_plugins: - try: - shutil.rmtree(os.path.join(args.bundle, 'Contents/PlugIns/')) - except OSError as e: - if e.errno != errno.ENOENT: - raise makedirs(os.path.join(args.bundle, 'Contents/PlugIns')) makedirs(os.path.join(args.bundle, 'Contents/Resources')) with open(os.path.join(args.bundle, 'Contents/Resources/qt.conf'), 'w') as conf: From 0f9a6697fbd968004e007cba09c1349202c37531 Mon Sep 17 00:00:00 2001 From: Florent Castelli Date: Thu, 2 Feb 2017 03:39:39 +0100 Subject: [PATCH 2/3] DolphinWX: Update how localization files are installed On macOS, we want them copied in the bundle directly, otherwise we will install them later in the system folder. Obviously not working for Windows, but that's not any different from before! --- CMakeLists.txt | 3 -- Source/Core/DolphinWX/CMakeLists.txt | 76 +++++++++++++--------------- 2 files changed, 34 insertions(+), 45 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 4e34b34398..4b40cce4e8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1002,9 +1002,6 @@ add_subdirectory(Source) ######################################## # Install shared data files # -if(NOT APPLE) - install(DIRECTORY Data/Sys/ DESTINATION ${datadir}/sys PATTERN) -endif() if(NOT ${CMAKE_SYSTEM_NAME} MATCHES "Linux|FreeBSD|OpenBSD|Darwin") install(FILES Data/license.txt DESTINATION ${datadir}) endif() diff --git a/Source/Core/DolphinWX/CMakeLists.txt b/Source/Core/DolphinWX/CMakeLists.txt index 8ebdf451b7..8fe129fb99 100644 --- a/Source/Core/DolphinWX/CMakeLists.txt +++ b/Source/Core/DolphinWX/CMakeLists.txt @@ -114,16 +114,44 @@ endif() set(DOLPHIN_EXE ${DOLPHIN_EXE_BASE}) -find_package(Gettext) -if(GETTEXT_MSGMERGE_EXECUTABLE AND GETTEXT_MSGFMT_EXECUTABLE AND wxWidgets_FOUND) - file(GLOB LINGUAS ${CMAKE_SOURCE_DIR}/Languages/po/*.po) - add_custom_target(translations ALL) - GETTEXT_CREATE_TRANSLATIONS(${CMAKE_SOURCE_DIR}/Languages/po/dolphin-emu.pot ${LINGUAS}) -endif() if(wxWidgets_FOUND) add_executable(${DOLPHIN_EXE} ${SRCS} ${GUI_SRCS}) target_link_libraries(${DOLPHIN_EXE} ${LIBS} ${WXLIBS}) + + # Handle localization + find_package(Gettext) + if(GETTEXT_MSGMERGE_EXECUTABLE AND GETTEXT_MSGFMT_EXECUTABLE) + set(pot_file "${CMAKE_SOURCE_DIR}/Languages/po/dolphin-emu.pot") + file(GLOB LINGUAS ${CMAKE_SOURCE_DIR}/Languages/po/*.po) + + target_sources(${DOLPHIN_EXE} PRIVATE ${pot_file} ${LINGUAS}) + source_group("Localization" FILES ${LINGUAS}) + source_group("Localization\\\\Generated" FILES ${pot_file}) + + foreach(po ${LINGUAS}) + get_filename_component(lang ${po} NAME_WE) + set(mo_dir ${CMAKE_CURRENT_BINARY_DIR}/${lang}) + set(mo ${mo_dir}/dolphin-emu.mo) + + target_sources(${DOLPHIN_EXE} PRIVATE ${mo}) + source_group("Localization\\\\Generated" FILES ${mo}) + + if(CMAKE_SYSTEM_NAME STREQUAL "Darwin") + set_source_files_properties(${mo} PROPERTIES MACOSX_PACKAGE_LOCATION "Resources/${lang}.lproj") + else() + install(FILES ${mo} DESTINATION share/locale/${lang}/LC_MESSAGES) + endif() + + add_custom_command(OUTPUT ${mo} + COMMAND mkdir -p ${mo_dir} + COMMAND ${GETTEXT_MSGMERGE_EXECUTABLE} --quiet --update --backup=none -s ${po} ${pot_file} + COMMAND ${GETTEXT_MSGFMT_EXECUTABLE} -o ${mo} ${po} + DEPENDS ${po} + ) + endforeach() + endif() + if(APPLE) include(BundleUtilities) set(BUNDLE_PATH ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${DOLPHIN_EXE}.app) @@ -170,43 +198,7 @@ if(wxWidgets_FOUND) ) endif() - if(GETTEXT_MSGMERGE_EXECUTABLE AND GETTEXT_MSGFMT_EXECUTABLE AND wxWidgets_FOUND) - file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/copy_translations_into_bundle.cmake " - file(GLOB TRANSLATION_FILES RELATIVE ${CMAKE_CURRENT_BINARY_DIR} - ${CMAKE_CURRENT_BINARY_DIR}/*.gmo - ) - foreach(TRANSLATION_FILE \${TRANSLATION_FILES}) - string(REPLACE \".gmo\" \".lproj\" TRANSLATION_DIR - \${TRANSLATION_FILE} - ) - # It would be better to copy to the new name as a single action, - # but I can't figure out a way to let CMake do that. - file(COPY ${CMAKE_CURRENT_BINARY_DIR}/\${TRANSLATION_FILE} - DESTINATION ${BUNDLE_PATH}/Contents/Resources/\${TRANSLATION_DIR} - NO_SOURCE_PERMISSIONS - ) - file(RENAME - ${BUNDLE_PATH}/Contents/Resources/\${TRANSLATION_DIR}/\${TRANSLATION_FILE} - ${BUNDLE_PATH}/Contents/Resources/\${TRANSLATION_DIR}/dolphin-emu.mo - ) - endforeach() - ") - file(GLOB PO_FILES RELATIVE ${CMAKE_SOURCE_DIR}/Languages/po - ${CMAKE_SOURCE_DIR}/Languages/po/*.po - ) - string(REPLACE .po .gmo GMO_FILES "${PO_FILES}") - - add_custom_command(OUTPUT ${BUNDLE_PATH}/Contents/Resources/en.lproj - COMMAND ${CMAKE_COMMAND} -P copy_translations_into_bundle.cmake - DEPENDS ${GMO_FILES} - ${CMAKE_SOURCE_DIR}/Data/Sys - VERBATIM - ) - add_custom_target(CopyTranslationsIntoBundleWx ALL - DEPENDS ${BUNDLE_PATH}/Contents/Resources/en.lproj - ) - endif() # Install bundle into systemwide /Applications directory. install(DIRECTORY ${BUNDLE_PATH} DESTINATION /Applications From e9aac53cec3d683db4f109d218f41b77c24753e7 Mon Sep 17 00:00:00 2001 From: Florent Castelli Date: Thu, 2 Feb 2017 03:51:00 +0100 Subject: [PATCH 3/3] macOS: Update how resources are copied in the bundle Instead of using install() commands, we use the MACOSX_PACKAGE_LOCATION property, which will allow the files to be identified and updated individually by the build system without having to remove the entire folder and copy it each time. deploy-mac.py is now idempotent and should be working properly, so we'll call it all the time from now on. --- Source/Core/DolphinQt2/CMakeLists.txt | 50 ++++++++----------------- Source/Core/DolphinWX/CMakeLists.txt | 54 ++++++++------------------- 2 files changed, 30 insertions(+), 74 deletions(-) diff --git a/Source/Core/DolphinQt2/CMakeLists.txt b/Source/Core/DolphinQt2/CMakeLists.txt index 5505cd90c3..feb0bb0cf4 100644 --- a/Source/Core/DolphinQt2/CMakeLists.txt +++ b/Source/Core/DolphinQt2/CMakeLists.txt @@ -49,41 +49,21 @@ if(APPLE) MACOSX_BUNDLE_INFO_PLIST ${CMAKE_CURRENT_SOURCE_DIR}/Info.plist.in ) - # get rid of any old copies - file (REMOVE_RECURSE ${BUNDLE_PATH}/Contents/Resources/Sys) - if(NOT SKIP_POSTPROCESS_BUNDLE) - # Fix up the bundle after it is finished. - # There does not seem to be an easy way to run CMake commands post-build, - # so we invoke CMake again on a generated script. - file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/postprocess_bundle.cmake " - include(BundleUtilities) - message(\"Fixing up application bundle: ${BUNDLE_PATH}\") - message(\"(Note: This is only necessary to produce a redistributable binary.\") - message(\"To skip, pass -DSKIP_POSTPROCESS_BUNDLE=1 to cmake.)\") - set(BU_CHMOD_BUNDLE_ITEMS ON) - execute_process( - COMMAND ${CMAKE_SOURCE_DIR}/Tools/deploy-mac.py -p platforms/libqcocoa.dylib \"${BUNDLE_PATH}\" - RESULT_VARIABLE retcode - ) - if(NOT \${retcode} EQUAL 0) - message(FATAL_ERROR \"Error when postprocessing bundle (return code: \${retcode}).\") - endif() - file(INSTALL ${CMAKE_SOURCE_DIR}/Data/Sys - DESTINATION ${BUNDLE_PATH}/Contents/Resources - ) - ") - add_custom_command(TARGET ${DOLPHINQT2_BINARY} POST_BUILD - COMMAND ${CMAKE_COMMAND} -P postprocess_bundle.cmake - ) - else() - add_custom_command(OUTPUT ${BUNDLE_PATH}/Contents/Resources/Sys - COMMAND ln -nfs ${CMAKE_SOURCE_DIR}/Data/Sys ${BUNDLE_PATH}/Contents/Resources/Sys - VERBATIM - ) - add_custom_target(CopyDataIntoBundleQt ALL - DEPENDS ${BUNDLE_PATH}/Contents/Resources/Sys - ) - endif() + # Update library references to make the bundle portable + add_custom_command(TARGET ${DOLPHINQT2_BINARY} POST_BUILD + COMMAND echo "Fixing up application bundle: ${BUNDLE_PATH}" + COMMAND echo ${CMAKE_SOURCE_DIR}/Tools/deploy-mac.py $/../.. + ) + + # Copy resources in the bundle + file(GLOB_RECURSE resources RELATIVE "${CMAKE_SOURCE_DIR}/Data" "${CMAKE_SOURCE_DIR}/Data/Sys/*") + foreach(res ${resources}) + target_sources(${DOLPHINQT2_BINARY} PRIVATE "${CMAKE_SOURCE_DIR}/Data/${res}") + get_filename_component(resdir "${res}" DIRECTORY) + set_source_files_properties("${CMAKE_SOURCE_DIR}/Data/${res}" PROPERTIES + MACOSX_PACKAGE_LOCATION "Resources/${resdir}") + source_group("Resources" FILES "${CMAKE_SOURCE_DIR}/Data/${res}") + endforeach() else() install(TARGETS ${DOLPHINQT2_BINARY} RUNTIME DESTINATION ${bindir}) endif() diff --git a/Source/Core/DolphinWX/CMakeLists.txt b/Source/Core/DolphinWX/CMakeLists.txt index 8fe129fb99..bc37cc8eaa 100644 --- a/Source/Core/DolphinWX/CMakeLists.txt +++ b/Source/Core/DolphinWX/CMakeLists.txt @@ -153,7 +153,6 @@ if(wxWidgets_FOUND) endif() if(APPLE) - include(BundleUtilities) set(BUNDLE_PATH ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${DOLPHIN_EXE}.app) # Ask for an application bundle. @@ -162,48 +161,25 @@ if(wxWidgets_FOUND) MACOSX_BUNDLE_INFO_PLIST ${CMAKE_CURRENT_SOURCE_DIR}/Info.plist.in ) - # get rid of any old copies - file (REMOVE_RECURSE ${BUNDLE_PATH}/Contents/Resources/Sys) - if(NOT SKIP_POSTPROCESS_BUNDLE) - # Fix up the bundle after it is finished. - # There does not seem to be an easy way to run CMake commands post-build, - # so we invoke CMake again on a generated script. - file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/postprocess_bundle.cmake " - include(BundleUtilities) - message(\"Fixing up application bundle: ${BUNDLE_PATH}\") - message(\"(Note: This is only necessary to produce a redistributable binary.\") - message(\"To skip, pass -DSKIP_POSTPROCESS_BUNDLE=1 to cmake.)\") - set(BU_CHMOD_BUNDLE_ITEMS ON) - execute_process( - COMMAND ${CMAKE_SOURCE_DIR}/Tools/deploy-mac.py \"${BUNDLE_PATH}\" - RESULT_VARIABLE retcode - ) - if(NOT \${retcode} EQUAL 0) - message(FATAL_ERROR \"Error when postprocessing bundle (return code: \${retcode}).\") - endif() - file(INSTALL \"${CMAKE_SOURCE_DIR}/Data/Sys\" - DESTINATION \"${BUNDLE_PATH}/Contents/Resources\" - ) - ") - add_custom_command(TARGET ${DOLPHIN_EXE} POST_BUILD - COMMAND ${CMAKE_COMMAND} -P postprocess_bundle.cmake - ) - else() - add_custom_command(OUTPUT ${BUNDLE_PATH}/Contents/Resources/Sys - COMMAND ln -nfs ${CMAKE_SOURCE_DIR}/Data/Sys ${BUNDLE_PATH}/Contents/Resources/Sys - VERBATIM - ) - add_custom_target(CopyDataIntoBundleWx ALL - DEPENDS ${BUNDLE_PATH}/Contents/Resources/Sys - ) - endif() + # Copy resources in the bundle + file(GLOB_RECURSE resources RELATIVE "${CMAKE_SOURCE_DIR}/Data" "${CMAKE_SOURCE_DIR}/Data/Sys/*") + foreach(res ${resources}) + target_sources(${DOLPHIN_EXE} PRIVATE "${CMAKE_SOURCE_DIR}/Data/${res}") + get_filename_component(resdir "${res}" DIRECTORY) + set_source_files_properties("${CMAKE_SOURCE_DIR}/Data/${res}" PROPERTIES + MACOSX_PACKAGE_LOCATION "Resources/${resdir}") + source_group("Resources" FILES "${CMAKE_SOURCE_DIR}/Data/${res}") + endforeach() + # Update library references to make the bundle portable + add_custom_command(TARGET ${DOLPHIN_EXE} POST_BUILD + COMMAND echo "Fixing up application bundle: ${BUNDLE_PATH}" + COMMAND echo ${CMAKE_SOURCE_DIR}/Tools/deploy-mac.py $/../.. + ) # Install bundle into systemwide /Applications directory. - install(DIRECTORY ${BUNDLE_PATH} DESTINATION /Applications - USE_SOURCE_PERMISSIONS - ) + install(TARGETS ${DOLPHIN_EXE} DESTINATION /Applications) elseif(WIN32) set_target_properties(${DOLPHIN_EXE} PROPERTIES WIN32_EXECUTABLE ON