Skip to content

Commit

Permalink
[GitHub Actions]: port to SDL2
Browse files Browse the repository at this point in the history
  • Loading branch information
mrpapersonic committed Jun 21, 2022
1 parent 7be04b0 commit b35c438
Show file tree
Hide file tree
Showing 2 changed files with 120 additions and 19 deletions.
33 changes: 14 additions & 19 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ jobs:
with:
msystem: ${{ matrix.sys }}
update: true
install: mingw-w64-${{ matrix.env }}-toolchain libtool autoconf automake make mingw-w64-${{ matrix.env }}-SDL zip dos2unix
install: mingw-w64-${{ matrix.env }}-toolchain libtool autoconf automake make mingw-w64-${{ matrix.env }}-SDL2 zip dos2unix

- name: 'Get current date'
id: date
Expand All @@ -53,11 +53,11 @@ jobs:
cp schismtracker.exe ..
if [ ${{ matrix.win }} == "win32" ]
then
cp /mingw32/bin/SDL.dll ..
cp /mingw32/bin/SDL2.dll ..
cp /mingw32/bin/libgcc_s_dw2-1.dll ..
cp /mingw32/bin/libwinpthread-1.dll ..
else
cp /mingw64/bin/SDL.dll ..
cp /mingw64/bin/SDL2.dll ..
fi
cd ..
cp docs/configuration.md .
Expand All @@ -70,7 +70,7 @@ jobs:
name: schismtracker-${{ steps.date.outputs.date }}-${{ matrix.win }}
path: |
schismtracker.exe
SDL.dll
SDL2.dll
libgcc_s_dw2-1.dll
libwinpthread-1.dll
COPYING
Expand All @@ -84,7 +84,7 @@ jobs:
name: schismtracker-${{ steps.date.outputs.date }}-${{ matrix.win }}
path: |
schismtracker.exe
SDL.dll
SDL2.dll
COPYING
README.md
configuration.md
Expand Down Expand Up @@ -127,19 +127,14 @@ jobs:
- name: 'Checkout'
uses: actions/checkout@v3

- name: 'Checkout SDL 1.2'
uses: actions/checkout@v3
with:
repository: libsdl-org/SDL-1.2
path: sdl
- name: 'Download SDL2 sources'
run: |
curl https://www.libsdl.org/release/SDL2-2.0.22.tar.gz | tar xvf -
- name: 'Build SDL 1.2'
- name: 'Build SDL2'
run: |
cd sdl
wget -O 'build-scripts/clang-fat.sh' 'https://raw.githubusercontent.com/libsdl-org/SDL/0c7c4bfcf920cfc5d66b0a7054a53904c668ef8f/build-scripts/clang-fat.sh'
sed -i.bak 's/10.6/10.9/g' build-scripts/clang-fat.sh
sed -i.bak 's/1060/1090/g' build-scripts/clang-fat.sh
./configure CC="sh build-scripts/clang-fat.sh"
cd SDL2-2.0.22
./configure CC="sh ../scripts/build-uni.sh"
make
sudo make install
rm -rf arm64 x64
Expand All @@ -165,8 +160,8 @@ jobs:
mkdir MacOS
cd MacOS
cp ../../../../../schismtracker .
cp /usr/local/lib/libSDL-1.2.0.dylib .
install_name_tool -change /usr/local/lib/libSDL-1.2.0.dylib @executable_path/libSDL-1.2.0.dylib schismtracker
cp /usr/local/lib/libSDL2.dylib ../Resources
install_name_tool -change /usr/local/lib/libSDL2.dylib @executable_path/../Resources/libSDL2.dylib schismtracker
cd ../../../../..
cp -r sys/macosx/Schism_Tracker.app Schism\ Tracker.app
cp docs/configuration.md .
Expand All @@ -185,7 +180,7 @@ jobs:
- name: 'Install dependencies'
run: |
sudo apt-get update
sudo apt-get install --fix-missing build-essential automake autoconf autoconf-archive libx11-dev libxext-dev libxv-dev libxxf86vm-dev libsdl1.2-dev libasound2-dev git libtool zip
sudo apt-get install --fix-missing build-essential automake autoconf autoconf-archive libx11-dev libxext-dev libxv-dev libxxf86vm-dev libsdl2-dev libasound2-dev git libtool zip
- name: 'Checkout'
uses: actions/checkout@v2
Expand Down
106 changes: 106 additions & 0 deletions scripts/build-uni.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
#!/bin/sh
#
# Build Universal binaries on Mac OS X, thanks Ryan!
#
# Usage: ./configure CC="sh clang-fat.sh" && make && rm -rf arm64 x64

DEVELOPER="`xcode-select -print-path`/Platforms/MacOSX.platform/Developer"

# Intel 64-bit compiler flags (10.6 runtime compatibility)
CLANG_COMPILE_X64="clang -arch x86_64 -mmacosx-version-min=10.6 \
-DMAC_OS_X_VERSION_MIN_REQUIRED=1060 \
-I/usr/local/include \
-isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX10.9.sdk"

CLANG_LINK_X64="-mmacosx-version-min=10.6"

# ARM 64-bit compiler flags (11.0 runtime compatibility)
CLANG_COMPILE_ARM64="clang -arch arm64 -mmacosx-version-min=11.0 \
-I/usr/local/include \
-isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX11.sdk"

CLANG_LINK_ARM64="-mmacosx-version-min=11.0"


# Output both Intel and ARM object files
args="$*"
compile=yes
link=yes
while test x$1 != x; do
case $1 in
--version) exec clang $1;;
-v) exec clang $1;;
-V) exec clang $1;;
-print-prog-name=*) exec clang $1;;
-print-search-dirs) exec clang $1;;
-E) CLANG_COMPILE_X64="$CLANG_COMPILE_X64 -E"
CLANG_COMPILE_ARM64="$CLANG_COMPILE_ARM64 -E"
compile=no; link=no;;
-c) link=no;;
-o) output=$2;;
*.c|*.cc|*.cpp|*.S|*.m|*.mm) source=$1;;
esac
shift
done
if test x$link = xyes; then
CLANG_COMPILE_X64="$CLANG_COMPILE_X64 $CLANG_LINK_X64"
CLANG_COMPILE_ARM64="$CLANG_COMPILE_ARM64 $CLANG_LINK_ARM64"
fi
if test x"$output" = x; then
if test x$link = xyes; then
output=a.out
elif test x$compile = xyes; then
output=`echo $source | sed -e 's|.*/||' -e 's|\(.*\)\.[^\.]*|\1|'`.o
fi
fi

# Compile Intel 64-bit
if test x"$output" != x; then
dir=x64/`dirname $output`
if test -d $dir; then
:
else
mkdir -p $dir
fi
fi
set -- $args
while test x$1 != x; do
if test -f "x64/$1" && test "$1" != "$output"; then
x64_args="$x64_args x64/$1"
else
x64_args="$x64_args $1"
fi
shift
done
$CLANG_COMPILE_X64 $x64_args || exit $?
if test x"$output" != x; then
cp $output x64/$output
fi

# Compile ARM 64-bit
if test x"$output" != x; then
dir=arm64/`dirname $output`
if test -d $dir; then
:
else
mkdir -p $dir
fi
fi
set -- $args
while test x$1 != x; do
if test -f "arm64/$1" && test "$1" != "$output"; then
arm64_args="$arm64_args arm64/$1"
else
arm64_args="$arm64_args $1"
fi
shift
done
$CLANG_COMPILE_ARM64 $arm64_args || exit $?
if test x"$output" != x; then
cp $output arm64/$output
fi


if test x"$output" != x; then
lipo -create -o $output arm64/$output x64/$output
fi

0 comments on commit b35c438

Please sign in to comment.