From 40a485326aae0017306387dcaf9532ec184dff8a Mon Sep 17 00:00:00 2001 From: Connor McLaughlin Date: Sun, 31 Jul 2022 16:40:34 +1000 Subject: [PATCH] CI: Build universal binaries for MacOS --- .github/workflows/rolling-release.yml | 8 +-- scripts/build-dependencies-mac.sh | 81 +++++++++++++++++++++----- scripts/make-universal-macos-binary.sh | 41 +++++++++++++ 3 files changed, 111 insertions(+), 19 deletions(-) create mode 100755 scripts/make-universal-macos-binary.sh diff --git a/.github/workflows/rolling-release.yml b/.github/workflows/rolling-release.yml index faed23af7..c2f759008 100644 --- a/.github/workflows/rolling-release.yml +++ b/.github/workflows/rolling-release.yml @@ -339,18 +339,14 @@ jobs: run: | mkdir build cd build - export MACOSX_DEPLOYMENT_TARGET=10.14 - cmake -DCMAKE_BUILD_TYPE=Release -DBUILD_NOGUI_FRONTEND=OFF -DBUILD_QT_FRONTEND=ON -DUSE_SDL2=ON -DCMAKE_PREFIX_PATH=$HOME/deps -DCMAKE_INTERPROCEDURAL_OPTIMIZATION=ON -G Ninja .. - cmake --build . --parallel - cd bin - codesign -s - --deep -f -v DuckStation.app + ../scripts/make-universal-macos-binary.sh .. zip -r duckstation-mac-release.zip DuckStation.app/ - name: Upload macOS .app uses: actions/upload-artifact@v1 with: name: "macos" - path: "build/bin/duckstation-mac-release.zip" + path: "build/duckstation-mac-release.zip" create-release: diff --git a/scripts/build-dependencies-mac.sh b/scripts/build-dependencies-mac.sh index aa94541d2..b332c4a47 100755 --- a/scripts/build-dependencies-mac.sh +++ b/scripts/build-dependencies-mac.sh @@ -29,20 +29,64 @@ d7bdd55e2908ded901dcc262157100af2a490bf04d31e32995f6d91d78dfdb97 qttranslations EOF curl -L \ - -O "https://libsdl.org/release/$SDL.tar.gz" \ - -O "https://github.com/KhronosGroup/MoltenVK/archive/refs/tags/v$MOLTENVK.tar.gz" \ - -O "https://curl.se/download/curl-$CURL.tar.gz" \ - -O "https://download.qt.io/official_releases/qt/${QT%.*}/$QT/submodules/qtbase-everywhere-src-$QT.tar.xz" \ - -O "https://download.qt.io/official_releases/qt/${QT%.*}/$QT/submodules/qtsvg-everywhere-src-$QT.tar.xz" \ - -O "https://download.qt.io/official_releases/qt/${QT%.*}/$QT/submodules/qttools-everywhere-src-$QT.tar.xz" \ - -O "https://download.qt.io/official_releases/qt/${QT%.*}/$QT/submodules/qttranslations-everywhere-src-$QT.tar.xz" + -O "https://libsdl.org/release/$SDL.tar.gz" \ + -O "https://github.com/KhronosGroup/MoltenVK/archive/refs/tags/v$MOLTENVK.tar.gz" \ + -O "https://curl.se/download/curl-$CURL.tar.gz" \ + -O "https://download.qt.io/official_releases/qt/${QT%.*}/$QT/submodules/qtbase-everywhere-src-$QT.tar.xz" \ + -O "https://download.qt.io/official_releases/qt/${QT%.*}/$QT/submodules/qtsvg-everywhere-src-$QT.tar.xz" \ + -O "https://download.qt.io/official_releases/qt/${QT%.*}/$QT/submodules/qttools-everywhere-src-$QT.tar.xz" \ + -O "https://download.qt.io/official_releases/qt/${QT%.*}/$QT/submodules/qttranslations-everywhere-src-$QT.tar.xz" shasum -a 256 --check SHASUMS echo "Installing SDL..." tar xf "$SDL.tar.gz" cd "$SDL" -./configure --prefix "$INSTALLDIR" --without-x + +# Patch clang wrappers to require 10.14 for x64. +patch -u build-scripts/clang-fat.sh <" + exit 1 +fi + +# no realpath... +SOURCEDIR="$1" + +echo "Build x64..." +mkdir build-x64 +cd build-x64 +export MACOSX_DEPLOYMENT_TARGET=10.14 +cmake -DCMAKE_BUILD_TYPE=Release -DBUILD_NOGUI_FRONTEND=OFF -DBUILD_QT_FRONTEND=ON -DUSE_SDL2=ON -DCMAKE_PREFIX_PATH="$DEPS" -DCMAKE_INTERPROCEDURAL_OPTIMIZATION=ON -G Ninja "../$SOURCEDIR" +cmake --build . --parallel +cd .. + +echo "Build arm64..." +mkdir build-arm64 +cd build-arm64 +export MACOSX_DEPLOYMENT_TARGET=11.00 +cmake -DCMAKE_OSX_ARCHITECTURES=arm64 -DCMAKE_BUILD_TYPE=Release -DBUILD_NOGUI_FRONTEND=OFF -DBUILD_QT_FRONTEND=ON -DUSE_SDL2=ON -DENABLE_OPENGL=OFF -DCMAKE_PREFIX_PATH="$DEPS" -DCMAKE_INTERPROCEDURAL_OPTIMIZATION=ON -G Ninja "../$SOURCEDIR" +cmake --build . --parallel +cd .. + +echo "Combine binary..." +unset MACOSX_DEPLOYMENT_TARGET +BINPATH=bin/DuckStation.app/Contents/MacOS/DuckStation +lipo -create "build-x64/$BINPATH" "build-arm64/$BINPATH" -o "build-x64/$BINPATH" + +echo "Grab app..." +mv build-x64/bin/DuckStation.app . +rm -fr build-x64 build-arm64 + +echo "Sign binary with self-signed cert..." +codesign -s - --deep -f -v DuckStation.app