Skip to content

Commit cd00b2c

Browse files
author
jcm
committed
Make macOS SDL build portable, build script runnable locally
1 parent f392e4f commit cd00b2c

File tree

4 files changed

+23
-6
lines changed

4 files changed

+23
-6
lines changed

.gitignore

+3-1
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,6 @@ out/
99
obj-amd64/
1010
obj-arm64/
1111
out-amd64/
12-
out-arm64/
12+
out-arm64/
13+
thirdparty/SDL/SDL
14+
thirdparty/SDL/libSDL2-2.0.0.dylib

ruby/GNUmakefile

+6-2
Original file line numberDiff line numberDiff line change
@@ -62,14 +62,17 @@ endif
6262

6363
ifeq ($(platform),macos)
6464
ruby.flags := $(flags.objcpp)
65+
ifeq ($(sdl2),true)
66+
ruby.flags += -I ../thirdparty/SDL/SDL/include/
67+
endif
6568
else
6669
ruby.flags := $(flags.cpp)
6770
endif
6871

6972
ruby.flags += $(foreach c,$(subst .,_,$(call strupper,$(ruby))),-D$c)
7073
ifeq ($(pkg_config),)
7174
# TODO: add SDL2 cflags
72-
else
75+
else ifeq ($(wildcard $(macsdl)),)
7376
ruby.flags += $(if $(findstring input.sdl,$(ruby)),$(shell $(pkg_config) sdl2 --cflags))
7477
ruby.flags += $(if $(findstring audio.sdl,$(ruby)),$(shell $(pkg_config) sdl2 --cflags))
7578
endif
@@ -98,7 +101,7 @@ ifeq ($(platform),windows)
98101
ruby.options += $(if $(findstring input.sdl,$(ruby)),$(shell $(pkg_config) sdl2 --libs --static))
99102
ruby.options += $(if $(findstring audio.sdl,$(ruby)),$(shell $(pkg_config) sdl2 --libs --static))
100103
endif
101-
else
104+
else ifeq ($(wildcard $(macsdl)),)
102105
ruby.options += $(if $(findstring input.sdl,$(ruby)),$(shell $(pkg_config) sdl2 --libs))
103106
ruby.options += $(if $(findstring audio.sdl,$(ruby)),$(shell $(pkg_config) sdl2 --libs))
104107
endif
@@ -114,6 +117,7 @@ endif
114117
ifeq ($(platform),macos)
115118
ruby.options += -framework IOKit
116119
ruby.options += $(if $(findstring audio.openal,$(ruby)),-framework OpenAL)
120+
ruby.options += -L../thirdparty/SDL/ -lSDL2-2.0.0
117121
endif
118122

119123
ifeq ($(platform),linux)

ruby/input/sdl.cpp

+4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1+
#if defined(PLATFORM_MACOS)
2+
#include "SDL.h"
3+
#else
14
#include <SDL2/SDL.h>
5+
#endif
26

37
#if defined(PLATFORM_WINDOWS)
48
#include "shared/rawinput.cpp"

thirdparty/SDL/build-sdl.sh

+10-3
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,18 @@ fi
99
git -C SDL reset --hard "$(cat HEAD)"
1010
mkdir -p SDL/build
1111
pushd SDL/build
12-
sudo xcode-select -s /Applications/Xcode.app/Contents/Developer
12+
13+
if [ -n "${GITHUB_ACTIONS+1}" ]; then
14+
sudo xcode-select -s /Applications/Xcode.app/Contents/Developer
15+
echo "Set Xcode version in order to target macOS 10.11 when building SDL."
16+
fi
1317
cmake .. "-DCMAKE_OSX_ARCHITECTURES=arm64;x86_64" \
1418
-DCMAKE_OSX_DEPLOYMENT_TARGET=10.11
1519
cmake --build .
16-
sudo cmake --install .
17-
sudo xcode-select -s /Applications/Xcode_14.2.app/Contents/Developer
20+
21+
if [ -n "${GITHUB_ACTIONS+1}" ]; then
22+
sudo xcode-select -s /Applications/Xcode_14.2.app/Contents/Developer
23+
echo "Set Xcode to 14.2 to continue build."
24+
fi
1825
popd
1926
cp SDL/build/libSDL2-2.0.0.dylib .

0 commit comments

Comments
 (0)