diff --git a/.github/workflows/ReleaseBuilds.yml b/.github/workflows/ReleaseBuilds.yml new file mode 100644 index 0000000..51d66b7 --- /dev/null +++ b/.github/workflows/ReleaseBuilds.yml @@ -0,0 +1,19 @@ +name: Make Release Builds + +on: [workflow_dispatch] + +jobs: + build-macos: + runs-on: macos-11 + timeout-minutes: 15 + steps: + - uses: actions/checkout@v3 + with: + ref: master + + - run: bash build-mac-app.sh + + - uses: actions/upload-artifact@v3 + with: + name: mac-build + path: SpaceCadetPinball-*-mac.dmg diff --git a/.gitignore b/.gitignore index d81cc3d..f83ee98 100644 --- a/.gitignore +++ b/.gitignore @@ -266,7 +266,7 @@ __pycache__/ /Export /DrMem /Doc private -# Windows local libraries +# Windows and macOS local libraries /Libs #CMake generated diff --git a/CMakeLists.txt b/CMakeLists.txt index 27b1ca0..93e5ef0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -19,6 +19,15 @@ if(MINGW) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -static") endif() +if(APPLE) + set(MACOSX_RPATH) + set(CMAKE_BUILD_WITH_INSTALL_RPATH true) + set(CMAKE_INSTALL_RPATH "@executable_path/../Frameworks") + set(CMAKE_OSX_ARCHITECTURES "arm64;x86_64") + list(APPEND SDL2_PATH "${CMAKE_CURRENT_LIST_DIR}/Libs") + list(APPEND SDL2_MIXER_PATH "${CMAKE_CURRENT_LIST_DIR}/Libs") +endif() + # SDL2main is not needed set(SDL2_BUILDING_LIBRARY ON) diff --git a/Platform/macOS/Info.plist b/Platform/macOS/Info.plist new file mode 100644 index 0000000..4c2b538 --- /dev/null +++ b/Platform/macOS/Info.plist @@ -0,0 +1,34 @@ + + + + + CFBundleDevelopmentRegion + English + CFBundleExecutable + SpaceCadetPinball + CFBundleIconFile + SpaceCadetPinball.icns + CFBundleIdentifier + com.github.k4zmu2a.spacecadetpinball + CFBundleInfoDictionaryVersion + 6.0 + CFBundleLongVersionString + + CFBundleName + SpaceCadetPinball + CFBundlePackageType + APPL + CFBundleShortVersionString + CHANGEME_SW_VERSION + CFBundleSignature + ???? + CFBundleSupportedPlatforms + + MacOSX + + CSResourcesFileMapped + + NSHighResolutionCapable + + + diff --git a/Platform/macOS/SpaceCadetPinball.icns b/Platform/macOS/SpaceCadetPinball.icns new file mode 100644 index 0000000..eb4c37d Binary files /dev/null and b/Platform/macOS/SpaceCadetPinball.icns differ diff --git a/README.md b/README.md index a6cfd8d..c93417f 100644 --- a/README.md +++ b/README.md @@ -74,6 +74,10 @@ This project is available as Flatpak on [Flathub](https://flathub.org/apps/detai ### On macOS +Install XCode (or at least Xcode Command Line Tools with `xcode-select --install`) and CMake. + +**Manual compilation:** + * **Homebrew**: Install the `SDL2`, `SDL2_mixer` homebrew packages. * **MacPorts**: Install the `libSDL2`, `libSDL2_mixer` macports packages. @@ -81,6 +85,12 @@ Compile with CMake. Ensure that `CMAKE_OSX_ARCHITECTURES` variable is set for ei Tested with: macOS Big Sur (Intel) with Xcode 13 & macOS Montery Beta (Apple Silicon) with Xcode 13. +**Automated compilation:** + +Run the `build-mac-app.sh` script from the root of the repository. The app will be available in a DMG file named `SpaceCadetPinball--mac.dmg`. + +Tested with: macOS Ventura (Apple Silicon) with Xcode Command Line Tools 14 & macOS Big Sur on GitHub Runner (Intel) with XCode 13. + ## Plans * ~~Decompile original game~~ diff --git a/build-mac-app.sh b/build-mac-app.sh new file mode 100755 index 0000000..dbd1998 --- /dev/null +++ b/build-mac-app.sh @@ -0,0 +1,60 @@ +#!/usr/bin/env bash + +set -xe + +mkdir -p Libs + +cd Libs + +sdl_version='2.28.1' +sdl_filename="SDL2-$sdl_version.dmg" +sdl_url="https://github.com/libsdl-org/SDL/releases/download/release-$sdl_version/$sdl_filename" + +sdl_mixer_version='2.7.0' +sdl_mixer_filename="SDL2_mixer-$sdl_mixer_version.dmg" +sdl_mixer_url="https://www.libsdl.org/tmp/$sdl_mixer_filename" + +mount_point="$(mktemp -d)" + +if [ ! -f "$sdl_filename" ]; then + curl -sSf -L -O "$sdl_url" +fi + +echo "2f936225c10a402cab07055e6f75de76f991945c37feb0cf6af633a96d2fb28c $sdl_filename" | shasum -a 256 -c +hdiutil attach "$sdl_filename" -mountpoint "$mount_point" -quiet +cp -a "$mount_point/SDL2.framework" . +hdiutil detach "$mount_point" + +if [ ! -f "$sdl_mixer_filename" ]; then + curl -sSf -L -O "$sdl_mixer_url" +fi + +echo "f394c714c8aefdcae0ff9d6eefeb5d42f28e56ed09fcaebb796cb672ca11279d $sdl_mixer_filename" | shasum -a 256 -c +hdiutil attach "$sdl_mixer_filename" -mountpoint "$mount_point" -quiet +cp -a "$mount_point/SDL2_mixer.framework" . +hdiutil detach "$mount_point" + +cd .. + +cmake . +cmake --build . + +sw_version='2.0.1' + +mkdir -p SpaceCadetPinball.app/Contents/MacOS +mkdir -p SpaceCadetPinball.app/Contents/Resources +mkdir -p SpaceCadetPinball.app/Contents/Frameworks + +cp -a Platform/macOS/Info.plist SpaceCadetPinball.app/Contents/ +cp -a Platform/macOS/SpaceCadetPinball.icns SpaceCadetPinball.app/Contents/Resources/ +cp -a Libs/SDL2.framework SpaceCadetPinball.app/Contents/Frameworks/ +cp -a Libs/SDL2_mixer.framework SpaceCadetPinball.app/Contents/Frameworks/ +cp -a bin/SpaceCadetPinball SpaceCadetPinball.app/Contents/MacOS/ + +sed -i '' "s/CHANGEME_SW_VERSION/$sw_version/" SpaceCadetPinball.app/Contents/Info.plist + +echo -n "APPL????" > SpaceCadetPinball.app/Contents/PkgInfo + +hdiutil create -fs HFS+ -srcfolder SpaceCadetPinball.app -volname "SpaceCadetPinball $sw_version" "SpaceCadetPinball-$sw_version-mac.dmg" + +rm -r SpaceCadetPinball.app