From 5aab6b68ec9573ce3e91224705198cd5afa57783 Mon Sep 17 00:00:00 2001 From: jcm Date: Tue, 12 Dec 2023 13:32:50 -0600 Subject: [PATCH] build: add macOS SDL to thirdparty, add .dylib to bundle --- .github/workflows/build.yml | 17 ++++++++++++++--- ares/GNUmakefile | 4 ---- desktop-ui/GNUmakefile | 4 ++++ ruby/GNUmakefile | 5 +++++ thirdparty/SDL/HEAD | 1 + thirdparty/SDL/build-sdl.sh | 17 +++++++++++++++++ 6 files changed, 41 insertions(+), 7 deletions(-) create mode 100644 thirdparty/SDL/HEAD create mode 100755 thirdparty/SDL/build-sdl.sh diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 1bfeb58d03..7c1e51b437 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -87,7 +87,7 @@ jobs: keychain-password: ${{ secrets.MACOS_KEYCHAIN_PASSWORD }} - name: Checkout source code uses: actions/checkout@v2 - - name: "macOS: recover cache" + - name: "macOS: recover MoltenVK cache" if: runner.os == 'macOS' uses: actions/cache@v3 env: @@ -95,12 +95,23 @@ jobs: with: path: thirdparty/MoltenVK/MoltenVK key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('thirdparty/MoltenVK/HEAD') }} + - name: "macOS: recover SDL cache" + if: runner.os == 'macOS' + uses: actions/cache@v3 + env: + cache-name: sdl + with: + path: thirdparty/SDL/SDL + key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('thirdparty/SDL/HEAD') }} - name: Install macOS Dependencies if: runner.os == 'macOS' run: | - brew install make ninja sdl2 + brew install make ninja cmake pip install --no-input setuptools echo "MAKE=gmake" >> $GITHUB_ENV + pushd thirdparty/SDL + ./build-SDL.sh + popd pushd thirdparty/MoltenVK ./build-moltenvk.sh popd @@ -114,7 +125,7 @@ jobs: run: ${MAKE:-make} -j4 -C desktop-ui build=optimized local=false compiler="${{ matrix.platform.compiler }}" windres="${{ matrix.platform.windres }}" - name: "macOS: Make universal app" if: runner.os == 'macOS' - run: scripts/macos-make-universal.sh build=optimized local=false sdl2=false + run: scripts/macos-make-universal.sh build=optimized local=false env: MAKEFLAGS: -j3 MACOS_CERTIFICATE_NAME: ${{ secrets.MACOS_CERTIFICATE_NAME }} diff --git a/ares/GNUmakefile b/ares/GNUmakefile index 457feff017..86e49365b9 100644 --- a/ares/GNUmakefile +++ b/ares/GNUmakefile @@ -13,10 +13,6 @@ ares.objects := ares ares-fixed-allocator $(object.path)/ares.o: $(ares.path)/ares/ares.cpp $(object.path)/ares-fixed-allocator.o: $(ares.path)/ares/memory/fixed-allocator.cpp -ifeq ($(platform),macos) - ares.dylibs := -endif - ifeq ($(vulkan),true) flags += -DVULKAN endif diff --git a/desktop-ui/GNUmakefile b/desktop-ui/GNUmakefile index cc959dd0ce..1497dcc62e 100644 --- a/desktop-ui/GNUmakefile +++ b/desktop-ui/GNUmakefile @@ -22,6 +22,10 @@ ifneq ($(filter $(arch),x86 amd64),) endif endif +ifeq ($(platform),macos) + ares.dylibs := +endif + libco.path := ../libco include $(libco.path)/GNUmakefile diff --git a/ruby/GNUmakefile b/ruby/GNUmakefile index 785622f0ef..ceb15b7523 100644 --- a/ruby/GNUmakefile +++ b/ruby/GNUmakefile @@ -21,6 +21,11 @@ ifeq ($(ruby),) ruby += audio.openal ruby += input.quartz #input.carbon ifeq ($(sdl2),true) + macsdl = ../thirdparty/SDL/libSDL2-2.0.0.dylib + ares.dylibs += $(macsdl) + ifeq ($(wildcard $(macsdl)),) + $(error Tried to compile ruby for macOS with SDL2 linked, but no SDL2 library was found. Compile it with thirdparty/SDL/build-sdl.sh, or disable SDL by compiling ares with sdl2=false) + endif ruby += input.sdl endif else ifeq ($(platform),linux) diff --git a/thirdparty/SDL/HEAD b/thirdparty/SDL/HEAD new file mode 100644 index 0000000000..eb3d44eb9e --- /dev/null +++ b/thirdparty/SDL/HEAD @@ -0,0 +1 @@ +15ead9a40d09a1eb9972215cceac2bf29c9b77f6 \ No newline at end of file diff --git a/thirdparty/SDL/build-sdl.sh b/thirdparty/SDL/build-sdl.sh new file mode 100755 index 0000000000..502e6efea1 --- /dev/null +++ b/thirdparty/SDL/build-sdl.sh @@ -0,0 +1,17 @@ +#!/bin/bash +set -euo pipefail + +if [ ! -d "SDL" ]; then + git clone https://github.com/libsdl-org/SDL.git -b SDL2 +else + git -C SDL fetch +fi +git -C SDL reset --hard "$(cat HEAD)" +mkdir -p SDL/build +pushd SDL/build +cmake .. "-DCMAKE_OSX_ARCHITECTURES=arm64;x86_64" \ + -DCMAKE_OSX_DEPLOYMENT_TARGET=10.13 #ares is currently built on Xcode 14.2, which has a minimum deploy target of 10.13 +cmake --build . +sudo cmake --install . +popd +cp SDL/build/libSDL2-2.0.0.dylib .