Skip to content

Commit

Permalink
Build BlastEm for macOS
Browse files Browse the repository at this point in the history
  • Loading branch information
joeyparrish committed Oct 4, 2024
1 parent 0051d90 commit 935aafe
Show file tree
Hide file tree
Showing 3 changed files with 157 additions and 25 deletions.
60 changes: 58 additions & 2 deletions .github/workflows/build-emulators.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@ on:
ref:
description: "The ref to build."
required: false
type: string
for-release:
description: "True if we should upload artifacts for a release."
default: false
type: boolean
workflow_call: # Allows for another workflow to call this one.
inputs:
ref:
Expand Down Expand Up @@ -84,7 +89,7 @@ jobs:
if: inputs.for-release
with:
name: blastem-linux
path: blastem64-0.6.2-kinetoscope
path: blastem-0.6.2-kinetoscope
retention-days: 1

build-blastem-windows:
Expand Down Expand Up @@ -145,5 +150,56 @@ jobs:
if: inputs.for-release
with:
name: blastem-windows
path: blastem64-0.6.2-kinetoscope
path: blastem-0.6.2-kinetoscope
retention-days: 1

build-blastem-macos:
name: Build BlastEm for macOS
runs-on: macos-13 # x86-64 explicitly, since BlastEm won't build on arm64
steps:
- name: Checkout BlastEm
uses: actions/checkout@v4
with:
repository: libretro/blastem
ref: 277e4a62668597d4f59cadda1cbafb844f981d45
path: .

- name: Checkout Kinetoscope
uses: actions/checkout@v4
with:
repository: ${{ github.repository }}
ref: ${{ inputs.ref || github.ref }}
path: kinetoscope

- name: Apply patch
run: patch -p1 -i kinetoscope/emulator-patches/blastem-0.6.2.patch

- name: Install deps for portable build
run: |
wget -O glew-2.1.0.tgz https://sourceforge.net/projects/glew/files/glew/2.1.0/glew-2.1.0.tgz/download
tar xf glew-2.1.0.tgz
ln -s glew-2.1.0 glew
wget -O SDL2-2.30.3.tar.gz https://github.com/libsdl-org/SDL/releases/download/release-2.30.3/SDL2-2.30.3.tar.gz
tar xf SDL2-2.30.3.tar.gz
ln -s SDL2-2.30.3 sdl
wget -O curl-8.8.0.tar.gz https://github.com/curl/curl/releases/download/curl-8_8_0/curl-8.8.0.tar.gz
tar xf curl-8.8.0.tar.gz
ln -s curl-8.8.0 curl
- name: Setup ccache
uses: hendrikmuhs/[email protected]
with:
create-symlink: true

- name: Build portable binaries
run: OS=Darwin ./build_release

- name: Upload blastem binaries
uses: actions/upload-artifact@v4
if: inputs.for-release
with:
name: blastem-macos
path: blastem-0.6.2-kinetoscope
retention-days: 1
11 changes: 9 additions & 2 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -185,18 +185,24 @@ jobs:
mv kinetoscope-hardware kinetoscope-$VERSION-hardware
zip -r9 kinetoscope-$VERSION-hardware.zip kinetoscope-$VERSION-hardware/
# Prep emulator binaries.
# Prep emulator binaries for Linux.
echo "This build of BlastEm supports Kinetoscope emulation." >> kinetoscope-blastem-0.6.2-linux-x64/README.kinetoscope.txt
chmod 755 kinetoscope-blastem-0.6.2-linux-x64/blastem
mv kinetoscope-blastem-0.6.2-linux-x64 kinetoscope-$VERSION-blastem-0.6.2-linux-x64
zip -r9 kinetoscope-$VERSION-blastem-0.6.2-linux-x64.zip kinetoscope-$VERSION-blastem-0.6.2-linux-x64/
# Prep emulator binaries.
# Prep emulator binaries for Windows.
echo "This build of BlastEm supports Kinetoscope emulation." >> kinetoscope-blastem-0.6.2-windows-x64/README.kinetoscope.txt
chmod 755 kinetoscope-blastem-0.6.2-windows-x64/blastem.exe
mv kinetoscope-blastem-0.6.2-windows-x64 kinetoscope-$VERSION-blastem-0.6.2-windows-x64
zip -r9 kinetoscope-$VERSION-blastem-0.6.2-windows-x64.zip kinetoscope-$VERSION-blastem-0.6.2-windows-x64/
# Prep emulator binaries for macOS.
echo "This build of BlastEm supports Kinetoscope emulation." >> kinetoscope-blastem-0.6.2-macos-x64/README.kinetoscope.txt
chmod 755 kinetoscope-blastem-0.6.2-macos-x64/blastem
mv kinetoscope-blastem-0.6.2-macos-x64 kinetoscope-$VERSION-blastem-0.6.2-macos-x64
zip -r9 kinetoscope-$VERSION-blastem-0.6.2-macos-x64.zip kinetoscope-$VERSION-blastem-0.6.2-macos-x64/
- name: Create release
uses: softprops/action-gh-release@v2
with:
Expand All @@ -214,3 +220,4 @@ jobs:
kinetoscope-*-hardware.zip
kinetoscope-*-blastem-0.6.2-linux-x64.zip
kinetoscope-*-blastem-0.6.2-windows-x64.zip
kinetoscope-*-blastem-0.6.2-macos-x64.zip
111 changes: 90 additions & 21 deletions emulator-patches/blastem-0.6.2.patch
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
commit 3dfebd407a96288ca68e494e93c01fa9b8ec0015
commit 36b12183ca89f7909a381a5984bacf16ab98d43a
Author: Joey Parrish <[email protected]>
Date: Wed Mar 27 07:39:28 2024 -0700

Expand All @@ -21,7 +21,7 @@ index 0000000..8f39f7f
+zdis
+kinetoscope
diff --git a/Makefile b/Makefile
index 0dddc9f..56ca15e 100644
index 0dddc9f..4655371 100644
--- a/Makefile
+++ b/Makefile
@@ -23,11 +23,11 @@ ifeq ($(CPU),i686)
Expand Down Expand Up @@ -52,21 +52,40 @@ index 0dddc9f..56ca15e 100644
else

MEM:=mem.o
@@ -109,6 +116,13 @@ endif
@@ -96,10 +103,11 @@ LDFLAGS:=-lm glew/lib/libGLEW.a
endif

ifeq ($(OS),Darwin)
-SDL_INCLUDE_PATH:=Frameworks/SDL2.framework/Headers
-CFLAGS+= -mmacosx-version-min=10.10
-LDFLAGS+= -mmacosx-version-min=10.10
-FIXUP:=install_name_tool -change @rpath/SDL2.framework/Versions/A/SDL2 @executable_path/Frameworks/SDL2.framework/Versions/A/SDL2
+SDL_INCLUDE_PATH:=sdl/include
+LDFLAGS+= -Llib -lSDL2 -framework OpenGL
+# These support font_mac:
+LDFLAGS+= -framework Foundation -framework AppKit
+FIXUP:= install_name_tool -change /usr/local/lib/libSDL2-2.0.0.dylib @executable_path/lib/libSDL2.dylib
else
SDL_INCLUDE_PATH:=sdl/include
LDFLAGS+= -Wl,-rpath='$$ORIGIN/lib' -Llib -lSDL2
@@ -109,6 +117,16 @@ endif
endif #Darwin
CFLAGS+= -I$(SDL_INCLUDE_PATH)

+# Static libcurl for kinetoscope emulation
+CFLAGS+= -Icurl/include
+LDFLAGS+= curl/lib/.libs/libcurl.a
+ifeq ($(OS),Darwin)
+LDFLAGS+= -framework SystemConfiguration
+endif #Darwin
+# Pthread for kinetoscope emulation
+CFLAGS+= -pthread
+LDFLAGS+= -pthread
+
else
ifeq ($(MAKECMDGOALS),libblastem.$(SO))
LDFLAGS:=-lm
@@ -126,6 +140,12 @@ LDFLAGS+= -framework OpenGL -framework AppKit
@@ -126,6 +144,12 @@ LDFLAGS+= -framework OpenGL -framework AppKit
endif
endif

Expand All @@ -79,15 +98,15 @@ index 0dddc9f..56ca15e 100644
endif #PORTABLE
endif #Windows

@@ -221,6 +241,7 @@ endif
@@ -221,6 +245,7 @@ endif

MAINOBJS=blastem.o system.o genesis.o debug.o gdb_remote.o vdp.o $(RENDEROBJS) io.o romdb.o hash.o menu.o xband.o \
realtec.o i2c.o nor.o sega_mapper.o multi_game.o megawifi.o $(NET) serialize.o $(TERMINAL) $(CONFIGOBJS) gst.o \
+ kinetoscope/emulator-patches/kinetoscope.o \
$(M68KOBJS) $(TRANSOBJS) $(AUDIOOBJS) saves.o zip.o bindings.o jcart.o gen_player.o

LIBOBJS=libblastem.o system.o genesis.o debug.o gdb_remote.o vdp.o io.o romdb.o hash.o xband.o realtec.o \
@@ -277,6 +298,8 @@ ifeq ($(MAKECMDGOALS),libblastem.$(SO))
@@ -277,6 +302,8 @@ ifeq ($(MAKECMDGOALS),libblastem.$(SO))
CFLAGS+= -fpic -DIS_LIB
endif

Expand All @@ -96,7 +115,7 @@ index 0dddc9f..56ca15e 100644
all : $(ALL)

libblastem.$(SO) : $(LIBOBJS)
@@ -366,7 +389,7 @@ m68k.c : m68k.cpu cpu_dsl.py
@@ -366,7 +393,7 @@ m68k.c : m68k.cpu cpu_dsl.py
$(CC) $(CFLAGS) -c -o $@ $<

%.png : %.xcf
Expand All @@ -105,33 +124,70 @@ index 0dddc9f..56ca15e 100644

%.tiles : %.spec
./img2tiles.py -s $< $@
@@ -393,3 +420,4 @@ tmss.md : font.tiles

clean :
rm -rf $(ALL) trans ztestrun ztestgen *.o nuklear_ui/*.o zlib/*.o
+ rm -f kinetoscope/emulator-patches/kinetoscope.o
diff --git a/build_release b/build_release
index f5faa10..a2aa4c4 100755
index f5faa10..5d12fba 100755
--- a/build_release
+++ b/build_release
@@ -24,6 +24,21 @@ if [ $OS = "Linux" ]; then
@@ -6,24 +6,48 @@ if [ -z "$OS" ]; then
OS=`uname -s`
fi

-if [ $OS = "Linux" ]; then
+if [ $OS = "Linux" -o $OS = "Darwin" ]; then
cd sdl
./configure
make all
cd ..
rm -rf lib
mkdir lib
- cp sdl/build/.libs/libSDL2-*.so.*.*.* lib
- sdl=`ls lib`
- link=`echo $sdl | sed -E 's/(so\.[0-9]*).*/\1/'`
+ if [ $OS = "Linux" ]; then
+ cp sdl/build/.libs/libSDL2-*.so.*.*.* lib
+ sdl=`ls lib`
+ link=`echo $sdl | sed -E 's/(so\.[0-9]*).*/\1/'`
+ link2="libSDL2.so"
+ else
+ cp sdl/build/.libs/libSDL2-*.*.*.dylib lib
+ sdl=`ls lib`
+ link=`echo $sdl | sed -E 's/(-[0-9]*).*(\.dylib)/\1\2/'`
+ link2="libSDL2.dylib"
+ fi
cd lib
ln -s "$sdl" "$link"
- ln -s "$sdl" libSDL2.so
+ ln -s "$sdl" "$link2"
cd ..
cd glew
make all
cd ..
fi
+
+if [ $OS = "Win64" ]; then
+ HOST_FLAG=--host=x86_64-w64-mingw32
+ HOST_FLAG=--host=x86_64-w64-mingw32
+else
+ HOST_FLAG=""
+ HOST_FLAG=""
+fi
+
+cd curl
+./configure \
+ --enable-static --disable-shared --without-ssl \
+ --without-libpsl --without-zstd --without-brotli \
+ --disable-ldap $HOST_FLAG
+ --without-libidn2 --without-librtmp \
+ --without-zlib --without-nghttp2 --disable-ldap $HOST_FLAG
+make -C lib
+cd ..
+
echo "Path is: $PATH"
if [ $OS = "Win64" ]; then
make PORTABLE=1 OS=Windows CPU=x86_64 clean all
@@ -32,10 +47,8 @@ else
@@ -32,33 +56,16 @@ else
make PORTABLE=1 clean all
SDLDLLPATH=sdl/i686-w64-mingw32/bin
fi
Expand All @@ -142,20 +198,33 @@ index f5faa10..a2aa4c4 100755
txt=".txt"
else
binaries="dis zdis vgmplay blastem termhelper"
@@ -44,11 +57,9 @@ else
else
binaries="$binaries lib"
fi
- if [ $OS = "Darwin" ]; then
- binaries="$binaries Frameworks"
- else
- binaries="$binaries lib"
- fi
- verstr=`./blastem -v`
+ binaries="$binaries lib"
txt=""
fi
-binaries="$binaries menu.bin tmss.md"
-ver=`echo $verstr | awk '/blastem/ { gsub(/\r/, "", $2); print $2 }'`
-if [ $OS = "Windows" ]; then
- suffix='-win32'
-elif [ $OS = "Win64" ]; then
- suffix='-win64'
-elif [ $OS = "Darwin" ]; then
- suffix='-osx'
-else
- suffix=`file ./blastem | sed -E 's/^[^:]*: [^ ]* ([0-9]*)-bit .*/\1/'`
-fi
-dir="blastem${suffix}-${ver}"
+ver="0.6.2-kinetoscope"
if [ $OS = "Windows" ]; then
suffix='-win32'
elif [ $OS = "Win64" ]; then
@@ -66,11 +77,7 @@ cp -r $binaries shaders images default.cfg rom.db gamecontrollerdb.txt systems.c
+dir="blastem-${ver}"
echo $dir
rm -rf "$dir"
mkdir "$dir"
@@ -66,11 +73,7 @@ cp -r $binaries shaders images default.cfg rom.db gamecontrollerdb.txt systems.c
for file in README COPYING CHANGELOG; do
cp "$file" "$dir"/"$file$txt"
done
Expand Down

0 comments on commit 935aafe

Please sign in to comment.