From e05b033dd2825b23ca4d78c552caea52442dfd17 Mon Sep 17 00:00:00 2001 From: OatmealDome Date: Wed, 4 Dec 2024 23:25:26 -0500 Subject: [PATCH] ScmRevGen: Don't generate Info.plist files directly Some generators (like Unix Makefiles and Xcode) copy an app's Info.plist at configure time. This causes a problem when we need to generate the Info.plist at build time, like how we currently do it with ScmRevGen. Instead of generating the Info.plist directly in ScmRevGen, provide an Info.plist without any version information to CMake at configure time, have ScmRevGen generate a separate plist file with the version information at build time, and then merge the two together to create the final Info.plist. --- CMake/DolphinInjectVersionInfo.cmake | 24 ++++++++++++++++++++++++ CMake/ScmRevGen.cmake | 3 +-- CMakeLists.txt | 11 +++-------- Source/Core/DolphinQt/CMakeLists.txt | 5 ++++- Source/Core/DolphinQt/Info.plist.in | 6 ------ Source/Core/MacUpdater/CMakeLists.txt | 5 ++++- Source/Core/MacUpdater/Info.plist.in | 4 ---- Source/Core/VersionInfo.plist.in | 13 +++++++++++++ 8 files changed, 49 insertions(+), 22 deletions(-) create mode 100644 CMake/DolphinInjectVersionInfo.cmake create mode 100644 Source/Core/VersionInfo.plist.in diff --git a/CMake/DolphinInjectVersionInfo.cmake b/CMake/DolphinInjectVersionInfo.cmake new file mode 100644 index 0000000000..94d9b43873 --- /dev/null +++ b/CMake/DolphinInjectVersionInfo.cmake @@ -0,0 +1,24 @@ +function(dolphin_inject_version_info target) + set(INFO_PLIST_PATH "$/Contents/Info.plist") + add_custom_command(TARGET ${target} + POST_BUILD + + COMMAND /usr/libexec/PlistBuddy -c + "Delete :CFBundleShortVersionString" + "${INFO_PLIST_PATH}" + || true + + COMMAND /usr/libexec/PlistBuddy -c + "Delete :CFBundleLongVersionString" + "${INFO_PLIST_PATH}" + || true + + COMMAND /usr/libexec/PlistBuddy -c + "Delete :CFBundleVersion" + "${INFO_PLIST_PATH}" + || true + + COMMAND /usr/libexec/PlistBuddy -c + "Merge '${CMAKE_BINARY_DIR}/Source/Core/VersionInfo.plist'" + "${INFO_PLIST_PATH}") +endfunction() diff --git a/CMake/ScmRevGen.cmake b/CMake/ScmRevGen.cmake index 751e8b78c2..d314d044e3 100644 --- a/CMake/ScmRevGen.cmake +++ b/CMake/ScmRevGen.cmake @@ -65,6 +65,5 @@ endfunction() configure_source_file("Source/Core/Common/scmrev.h") if(APPLE) - configure_source_file("Source/Core/DolphinQt/Info.plist") - configure_source_file("Source/Core/MacUpdater/Info.plist") + configure_source_file("Source/Core/VersionInfo.plist") endif() diff --git a/CMakeLists.txt b/CMakeLists.txt index 3495e3b2b3..819ea04409 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -783,14 +783,9 @@ if (NOT EXISTS ${CMAKE_CURRENT_BINARY_DIR}/Source/Core/Common/scmrev.h) endif() if(APPLE) - file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/Source/Core/DolphinQt) - if (NOT EXISTS ${CMAKE_CURRENT_BINARY_DIR}/Source/Core/DolphinQt/Info.plist) - file(TOUCH ${CMAKE_CURRENT_BINARY_DIR}/Source/Core/DolphinQt/Info.plist) - endif() - - file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/Source/Core/MacUpdater) - if (NOT EXISTS ${CMAKE_CURRENT_BINARY_DIR}/Source/Core/MacUpdater/Info.plist) - file(TOUCH ${CMAKE_CURRENT_BINARY_DIR}/Source/Core/MacUpdater/Info.plist) + file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/Source/Core) + if (NOT EXISTS ${CMAKE_CURRENT_BINARY_DIR}/Source/Core/VersionInfo.plist) + file(TOUCH ${CMAKE_CURRENT_BINARY_DIR}/Source/Core/VersionInfo.plist) endif() endif() diff --git a/Source/Core/DolphinQt/CMakeLists.txt b/Source/Core/DolphinQt/CMakeLists.txt index 153f9eb4b5..98d4cb0e43 100644 --- a/Source/Core/DolphinQt/CMakeLists.txt +++ b/Source/Core/DolphinQt/CMakeLists.txt @@ -576,7 +576,7 @@ if(APPLE) # Ask for an application bundle. set_target_properties(dolphin-emu PROPERTIES MACOSX_BUNDLE true - MACOSX_BUNDLE_INFO_PLIST "${CMAKE_CURRENT_BINARY_DIR}/Info.plist" + MACOSX_BUNDLE_INFO_PLIST "${CMAKE_CURRENT_SOURCE_DIR}/Info.plist.in" XCODE_ATTRIBUTE_CODE_SIGN_IDENTITY "" OUTPUT_NAME DolphinQt ) @@ -613,6 +613,9 @@ if(APPLE) source_group("Resources" FILES "${CMAKE_SOURCE_DIR}/Data/${res}") endforeach() + include(DolphinInjectVersionInfo) + dolphin_inject_version_info(dolphin-emu) + # Copy MoltenVK into the bundle if(ENABLE_VULKAN) if(USE_BUNDLED_MOLTENVK) diff --git a/Source/Core/DolphinQt/Info.plist.in b/Source/Core/DolphinQt/Info.plist.in index 2a3d17291e..ddd2ed4182 100644 --- a/Source/Core/DolphinQt/Info.plist.in +++ b/Source/Core/DolphinQt/Info.plist.in @@ -39,12 +39,6 @@ English CFBundlePackageType APPL - CFBundleShortVersionString - ${DOLPHIN_WC_DESCRIBE} - CFBundleLongVersionString - ${DOLPHIN_WC_REVISION} - CFBundleVersion - ${DOLPHIN_VERSION_MAJOR}.${DOLPHIN_VERSION_MINOR} NSHumanReadableCopyright Licensed under GPL version 2 or later (GPLv2+) LSApplicationCategoryType diff --git a/Source/Core/MacUpdater/CMakeLists.txt b/Source/Core/MacUpdater/CMakeLists.txt index d72dd46cd2..79a9bfe52f 100644 --- a/Source/Core/MacUpdater/CMakeLists.txt +++ b/Source/Core/MacUpdater/CMakeLists.txt @@ -16,7 +16,7 @@ add_dependencies(MacUpdater dolphin_scmrev) set_target_properties(MacUpdater PROPERTIES MACOSX_BUNDLE true - MACOSX_BUNDLE_INFO_PLIST "${CMAKE_CURRENT_BINARY_DIR}/Info.plist" + MACOSX_BUNDLE_INFO_PLIST "${CMAKE_CURRENT_SOURCE_DIR}/Info.plist.in" OUTPUT_NAME "Dolphin Updater") target_compile_options(MacUpdater PRIVATE -x objective-c++) @@ -53,6 +53,9 @@ foreach(sb ${STORYBOARDS}) COMMENT "Compiling Storyboard ${sb}...") endforeach() +include(DolphinInjectVersionInfo) +dolphin_inject_version_info(MacUpdater) + if(NOT SKIP_POSTPROCESS_BUNDLE) # Update library references to make the bundle portable include(DolphinPostprocessBundle) diff --git a/Source/Core/MacUpdater/Info.plist.in b/Source/Core/MacUpdater/Info.plist.in index 574843c28d..22872c858f 100644 --- a/Source/Core/MacUpdater/Info.plist.in +++ b/Source/Core/MacUpdater/Info.plist.in @@ -16,10 +16,6 @@ Dolphin Updater CFBundlePackageType APPL - CFBundleShortVersionString - ${DOLPHIN_WC_DESCRIBE} - CFBundleVersion - ${DOLPHIN_VERSION_MAJOR}.${DOLPHIN_VERSION_MINOR} LSMinimumSystemVersion ${CMAKE_OSX_DEPLOYMENT_TARGET} NSHumanReadableCopyright diff --git a/Source/Core/VersionInfo.plist.in b/Source/Core/VersionInfo.plist.in new file mode 100644 index 0000000000..38043ba2de --- /dev/null +++ b/Source/Core/VersionInfo.plist.in @@ -0,0 +1,13 @@ + + + + + + CFBundleShortVersionString + ${DOLPHIN_WC_DESCRIBE} + CFBundleLongVersionString + ${DOLPHIN_WC_REVISION} + CFBundleVersion + ${DOLPHIN_VERSION_MAJOR}.${DOLPHIN_VERSION_MINOR} + +