Skip to content

Commit

Permalink
build: add macOS SDL to thirdparty, add .dylib to bundle
Browse files Browse the repository at this point in the history
  • Loading branch information
jcm committed Dec 14, 2023
1 parent ed3083d commit 5aab6b6
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 7 deletions.
17 changes: 14 additions & 3 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -87,20 +87,31 @@ 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:
cache-name: moltenvk
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
Expand All @@ -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 }}
Expand Down
4 changes: 0 additions & 4 deletions ares/GNUmakefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions desktop-ui/GNUmakefile
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ ifneq ($(filter $(arch),x86 amd64),)
endif
endif

ifeq ($(platform),macos)
ares.dylibs :=
endif

libco.path := ../libco
include $(libco.path)/GNUmakefile

Expand Down
5 changes: 5 additions & 0 deletions ruby/GNUmakefile
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
1 change: 1 addition & 0 deletions thirdparty/SDL/HEAD
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
15ead9a40d09a1eb9972215cceac2bf29c9b77f6
17 changes: 17 additions & 0 deletions thirdparty/SDL/build-sdl.sh
Original file line number Diff line number Diff line change
@@ -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 .

0 comments on commit 5aab6b6

Please sign in to comment.