Skip to content

Commit

Permalink
Merge pull request schismtracker#342 from mrpapersonic/feature/flac
Browse files Browse the repository at this point in the history
FLAC loading support
  • Loading branch information
jangler authored Dec 7, 2022
2 parents 7c10f28 + cd2c880 commit e86df4f
Show file tree
Hide file tree
Showing 5 changed files with 424 additions and 23 deletions.
70 changes: 50 additions & 20 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
include:
- { sys: mingw32, env: i686, win: win32 }
- { sys: mingw64, env: x86_64, win: win64 }
name: ${{ matrix.win }}
name: build-${{ matrix.win }}
defaults:
run:
shell: msys2 {0}
Expand All @@ -36,11 +36,11 @@ jobs:
with:
msystem: ${{ matrix.sys }}
update: true
install: git mingw-w64-${{ matrix.env }}-toolchain libtool autoconf automake make mingw-w64-${{ matrix.env }}-SDL2 zip dos2unix
install: git mingw-w64-${{ matrix.env }}-toolchain mingw-w64-${{ matrix.env }}-flac libtool autoconf automake make mingw-w64-${{ matrix.env }}-SDL2 zip dos2unix

- name: 'Get current date'
id: date
run: echo "::set-output name=date::$(date +%Y%m%d)"
run: echo "date=$(date +%Y%m%d)" >> $GITHUB_OUTPUT

- name: 'Build package'
run: |
Expand All @@ -51,15 +51,15 @@ jobs:
make
strip -g schismtracker.exe
cp schismtracker.exe ..
cd ..
if [ ${{ matrix.win }} == "win32" ]
then
cp /mingw32/bin/SDL2.dll ..
cp /mingw32/bin/libgcc_s_dw2-1.dll ..
cp /mingw32/bin/libwinpthread-1.dll ..
else
cp /mingw64/bin/SDL2.dll ..
cp /mingw32/bin/libgcc_s_dw2-1.dll .
cp /mingw32/bin/libwinpthread-1.dll .
fi
cd ..
cp /${{ matrix.sys }}/bin/SDL2.dll .
cp /${{ matrix.sys }}/bin/libFLAC.dll .
cp /${{ matrix.sys }}/bin/libogg-0.dll .
cp docs/configuration.md .
unix2dos COPYING README.md configuration.md
Expand All @@ -71,6 +71,8 @@ jobs:
path: |
schismtracker.exe
SDL2.dll
libFLAC.dll
libogg-0.dll
libgcc_s_dw2-1.dll
libwinpthread-1.dll
COPYING
Expand All @@ -85,6 +87,8 @@ jobs:
path: |
schismtracker.exe
SDL2.dll
libFLAC.dll
libogg-0.dll
COPYING
README.md
configuration.md
Expand All @@ -97,7 +101,7 @@ jobs:
steps:
- name: 'Get current date'
id: date
run: echo "::set-output name=date::$(date +%Y%m%d)"
run: echo "date=$(date +%Y%m%d)" >> $GITHUB_OUTPUT

- name: 'chown SDK directory'
id: chown
Expand All @@ -122,46 +126,72 @@ jobs:
- name: 'Install dependencies'
run: |
brew install automake zip
brew install automake zip cmake
- name: 'Checkout'
uses: actions/checkout@v3

# Since Homebrew doesn't provide binaries for old versions, we have to compile our own:
- name: 'Download SDL2 sources'
run: |
curl https://www.libsdl.org/release/SDL2-2.24.2.tar.gz | tar xvf -
curl https://www.libsdl.org/release/SDL2-2.26.1.tar.gz | tar xvf -
- name: 'Build SDL2'
run: |
cd SDL2-2.24.2
cd SDL2-2.26.1
./configure CC="sh ../scripts/build-uni.sh"
make
sudo make install
make install
rm -rf arm64 x64
cd ..
- name: 'Download libflac and libogg sources'
run: |
curl https://ftp.osuosl.org/pub/xiph/releases/flac/flac-1.4.2.tar.xz | tar -xvf -
curl https://ftp.osuosl.org/pub/xiph/releases/ogg/libogg-1.3.5.tar.gz | tar -xvf -
- name: 'Build libflac'
run: |
cd libogg-1.3.5
mkdir build
cd build
../configure CC="sh $PWD/../../scripts/build-uni.sh" LDFLAGS="-L/usr/local/lib"
make
make install
cd ../../flac-1.4.2
mkdir build
cd build
../configure CC="sh $PWD/../../scripts/build-uni.sh" LDFLAGS="-L/usr/local/lib"
make
make install
cd ../..
- name: 'Build package'
run: |
autoreconf -i
mkdir -p build
cd build
../configure
make CFLAGS="-isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX10.9.sdk -I/Library/Developer/CommandLineTools/SDKs/MacOSX10.9.sdk/System/Library/Frameworks/Tk.framework/Versions/8.5/Headers"
make CFLAGS="-isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX10.9.sdk -I/usr/local/include -I/Library/Developer/CommandLineTools/SDKs/MacOSX10.9.sdk/System/Library/Frameworks/Tk.framework/Versions/8.5/Headers"
mkdir -p ../buildarm
cd ../buildarm
../configure
make LDFLAGS="-arch arm64 -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX11.sdk" CFLAGS="-arch arm64 -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX11.sdk -I/Library/Developer/CommandLineTools/SDKs/MacOSX11.sdk/System/Library/Frameworks/Tk.framework/Versions/8.5/Headers" OBJCFLAGS="-arch arm64 -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX11.sdk -I/Library/Developer/CommandLineTools/SDKs/MacOSX11.sdk/System/Library/Frameworks/Tk.framework/Versions/8.5/Headers"
make LDFLAGS="-arch arm64 -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX11.sdk" CFLAGS="-arch arm64 -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX11.sdk -I/usr/local/include -I/Library/Developer/CommandLineTools/SDKs/MacOSX11.sdk/System/Library/Frameworks/Tk.framework/Versions/8.5/Headers" OBJCFLAGS="-arch arm64 -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX11.sdk -I/Library/Developer/CommandLineTools/SDKs/MacOSX11.sdk/System/Library/Frameworks/Tk.framework/Versions/8.5/Headers"
cd ..
lipo -create -o schismtracker buildarm/schismtracker build/schismtracker
strip -S schismtracker
cd sys/macosx/Schism_Tracker.app/Contents/
sed -i .bak "s;<string>CFBundle.*Version.*</string>;<string>$(date +%Y%m%d)</string>;" Info.plist
rm Info.plist.bak
mkdir MacOS
cp ../../../../schismtracker MacOS
cp /usr/local/lib/libSDL2-2.0.0.dylib Resources
cp /usr/local/lib/libFLAC.12.dylib Resources
cp /usr/local/lib/libogg.0.dylib Resources
cd MacOS
cp ../../../../../schismtracker .
cp /usr/local/lib/libSDL2-2.0.0.dylib ../Resources
install_name_tool -change /usr/local/lib/libSDL2-2.0.0.dylib @executable_path/../Resources/libSDL2-2.0.0.dylib schismtracker
install_name_tool -change /usr/local/lib/libFLAC.12.dylib @executable_path/../Resources/libFLAC.12.dylib schismtracker
install_name_tool -change /usr/local/lib/libogg.0.dylib @executable_path/../Resources/libogg.0.dylib schismtracker
cd ../../../../..
cp -r sys/macosx/Schism_Tracker.app Schism\ Tracker.app
cp docs/configuration.md .
Expand All @@ -180,14 +210,14 @@ 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 libsdl2-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 libflac-dev git libtool zip
- name: 'Checkout'
uses: actions/checkout@v3

- name: 'Get current date'
id: date
run: echo "::set-output name=date::$(date +%Y%m%d)"
run: echo "date=$(date +%Y%m%d)" >> $GITHUB_OUTPUT

- name: 'autoreconf -i'
run: autoreconf -i
Expand Down
14 changes: 11 additions & 3 deletions Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,13 @@ files_macosx = \
cflags_macosx=
endif

if USE_FLAC
files_flac = \
fmt/flac.c
cflags_flac=-DUSE_FLAC
libs_flac=-lFLAC
endif

if USE_NETWORK
cflags_network=-DUSE_NETWORK
endif
Expand Down Expand Up @@ -354,7 +361,8 @@ schismtracker_SOURCES = \
$(files_stdlib) \
$(files_mmap) \
$(files_wii) \
$(files_windres)
$(files_windres) \
$(files_flac)

# have version.o rely on all files
schism/version.$(OBJEXT): $(filter-out schism/version.$(OBJEXT),$(schismtracker_OBJECTS)) $(HEADERS)
Expand All @@ -365,8 +373,8 @@ AM_CPPFLAGS = -D_USE_AUTOCONF -D_GNU_SOURCE -I$(srcdir)/include -I.
AM_CFLAGS = $(SDL_CFLAGS) $(cflags_alsa) $(cflags_oss) \
$(cflags_network) $(cflags_x11) $(cflags_fmopl) \
$(cflags_version) $(cflags_win32) $(cflags_wii) \
$(cflags_macosx)
$(cflags_macosx) $(cflags_flac)
AM_OBJCFLAGS = $(AM_CFLAGS)

schismtracker_DEPENDENCIES = $(files_windres)
schismtracker_LDADD = $(lib_asound) $(lib_win32) $(SDL_LIBS) $(LIBM)
schismtracker_LDADD = $(lib_asound) $(lib_win32) $(libs_flac) $(SDL_LIBS) $(LIBM)
13 changes: 13 additions & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,11 @@ AC_ARG_ENABLE(fortify-source,
ADD_FORTIFY=$enableval,
ADD_FORTIFY=no)

AC_ARG_WITH([flac],
[AS_HELP_STRING([--without-flac],[Build without FLAC support @<:@default=no@:>@])],
[],
[with_flac=yes])

dnl fortify needs -O; do this early so ADD_OPT can override with higher -O level
if test x$ADD_FORTIFY \!= xno; then
CFLAGS="$CFLAGS -O -D_FORTIFY_SOURCE=2"
Expand All @@ -321,6 +326,14 @@ if test x$ADD_LUDICROUS \!= xno; then
CFLAGS="$CFLAGS -Werror"
fi

AM_CONDITIONAL([USE_FLAC], false)
if test "x$with_flac" = "xyes"; then
AC_CHECK_HEADER(FLAC/stream_decoder.h, libflac_found=yes, libflac_found=no)
if test x"$libflac_found" = "xyes"; then
AM_CONDITIONAL([USE_FLAC], true)
fi
fi

dnl ... but put the warnings first, to make it possible to quiet certain
dnl warnings if necessary, while still providing most of the benefit
if test x$ADD_WARN \!= xno; then
Expand Down
Loading

0 comments on commit e86df4f

Please sign in to comment.