mirror of
https://github.com/gbdev/rgbds.git
synced 2025-11-20 10:12:06 +00:00
Properly build and link against libpng
Doing it right this time. Also bundling the newly required DLLs.
This commit is contained in:
17
.github/actions/mingw-configure.sh
vendored
17
.github/actions/mingw-configure.sh
vendored
@@ -1,17 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
|
|
||||||
source mingw-env @TRIPLE@
|
|
||||||
echo LAST IS: $last
|
|
||||||
|
|
||||||
# check if last arg is a path to configure, else use parent
|
|
||||||
for last; do true; done
|
|
||||||
if test -x "${last}/configure"; then
|
|
||||||
config_path="$last"
|
|
||||||
else
|
|
||||||
config_path=".."
|
|
||||||
fi
|
|
||||||
|
|
||||||
${config_path}/configure \
|
|
||||||
--host=@TRIPLE@ --target=@TRIPLE@ --build="$CHOST" \
|
|
||||||
--prefix=/usr/@TRIPLE@ --libdir=/usr/@TRIPLE@/lib --includedir=/usr/@TRIPLE@/include \
|
|
||||||
--enable-shared --enable-static "$@"
|
|
||||||
16
.github/actions/mingw-env.sh
vendored
16
.github/actions/mingw-env.sh
vendored
@@ -1,16 +0,0 @@
|
|||||||
#!/bin/sh
|
|
||||||
|
|
||||||
_arch=$1
|
|
||||||
|
|
||||||
default_mingw_pp_flags="-D_FORTIFY_SOURCE=2"
|
|
||||||
default_mingw_compiler_flags="$default_mingw_pp_flags -O2 -pipe -fno-plt -fexceptions --param=ssp-buffer-size=4"
|
|
||||||
default_mingw_linker_flags="-Wl,-O1,--sort-common,--as-needed -fstack-protector"
|
|
||||||
|
|
||||||
export CPPFLAGS="${MINGW_CPPFLAGS:-$default_mingw_pp_flags $CPPFLAGS}"
|
|
||||||
export CFLAGS="${MINGW_CFLAGS:-$default_mingw_compiler_flags $CFLAGS}"
|
|
||||||
export CXXFLAGS="${MINGW_CXXFLAGS:-$default_mingw_compiler_flags $CXXFLAGS}"
|
|
||||||
export LDFLAGS="${MINGW_LDFLAGS:-$default_mingw_linker_flags $LDFLAGS}"
|
|
||||||
|
|
||||||
mingw_prefix=/usr/${_arch}
|
|
||||||
export PKG_CONFIG_SYSROOT_DIR="${mingw_prefix}"
|
|
||||||
export PKG_CONFIG_LIBDIR="${mingw_prefix}/lib/pkgconfig:${mingw_prefix}/share/pkgconfig"
|
|
||||||
44
.github/actions/mingw-w64-libpng-dev.sh
vendored
44
.github/actions/mingw-w64-libpng-dev.sh
vendored
@@ -1,44 +1,34 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
|
||||||
# This script was written by ISSOtm while looking at Arch Linux's PKGBUILD for
|
|
||||||
# the corresponding package. (And its dependencies)
|
|
||||||
# https://aur.archlinux.org/packages/mingw-w64-libpng/
|
|
||||||
|
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
pngver=1.6.37
|
pngver=1.6.37
|
||||||
_apngver=$pngver
|
arch="$1"
|
||||||
_arch="$1"
|
|
||||||
|
|
||||||
|
|
||||||
## Install mingw-configure and mingw-env (both build dependencies)
|
|
||||||
|
|
||||||
install -m 755 .github/actions/mingw-env.sh /usr/bin/mingw-env
|
|
||||||
|
|
||||||
sed "s|@TRIPLE@|${_arch}|g" .github/actions/mingw-configure.sh > ${_arch}-configure
|
|
||||||
install -m 755 ${_arch}-configure /usr/bin/
|
|
||||||
|
|
||||||
|
|
||||||
## Grab sources and check them
|
## Grab sources and check them
|
||||||
|
|
||||||
wget http://downloads.sourceforge.net/sourceforge/libpng/libpng-$pngver.tar.xz
|
wget http://downloads.sourceforge.net/project/libpng/libpng16/$pngver/libpng-$pngver.tar.xz
|
||||||
wget http://downloads.sourceforge.net/project/apng/libpng/libpng16/libpng-$_apngver-apng.patch.gz
|
wget http://downloads.sourceforge.net/project/apng/libpng/libpng16/libpng-$pngver-apng.patch.gz
|
||||||
sha256sum -c .github/actions/mingw-w64-libpng-dev.sha256sums
|
sha256sum -c .github/actions/mingw-w64-libpng-dev.sha256sums
|
||||||
|
|
||||||
## Extract sources
|
## Extract sources and patch them
|
||||||
|
|
||||||
tar -xf libpng-$pngver.tar.xz
|
tar -xf libpng-$pngver.tar.xz
|
||||||
gunzip libpng-$_apngver-apng.patch.gz
|
gunzip libpng-$pngver-apng.patch.gz
|
||||||
|
|
||||||
|
# Patch in apng support
|
||||||
|
env -C libpng-$pngver patch -p0 ../libpng-$pngver-apng.patch
|
||||||
|
|
||||||
## Start building!
|
## Start building!
|
||||||
|
|
||||||
cd libpng-$pngver
|
mkdir -p build
|
||||||
# Patch in apng support
|
cd build
|
||||||
patch -p0 ../libpng-$_apngver-apng.patch
|
../libpng-$pngver/configure \
|
||||||
|
--host="$arch" --target="$arch" \
|
||||||
mkdir -p build-${_arch}
|
--prefix="/usr/$arch" \
|
||||||
cd build-${_arch}
|
--enable-shared --disable-static \
|
||||||
${_arch}-configure LDFLAGS=-static-libgcc
|
CPPFLAGS="-D_FORTIFY_SOURCE=2" \
|
||||||
make
|
CFLAGS="-O2 -pipe -fno-plt -fexceptions --param=ssp-buffer-size=4" \
|
||||||
|
LDFLAGS="-Wl,-O1,--sort-common,--as-needed -fstack-protector"
|
||||||
|
make -kj
|
||||||
make install
|
make install
|
||||||
|
|||||||
21
.github/workflows/testing.yml
vendored
21
.github/workflows/testing.yml
vendored
@@ -158,7 +158,7 @@ jobs:
|
|||||||
arch: x86-64
|
arch: x86-64
|
||||||
triplet: x86_64-w64-mingw32
|
triplet: x86_64-w64-mingw32
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-22.04
|
||||||
env:
|
env:
|
||||||
DIST_DIR: win${{ matrix.bits }}
|
DIST_DIR: win${{ matrix.bits }}
|
||||||
steps:
|
steps:
|
||||||
@@ -168,8 +168,8 @@ jobs:
|
|||||||
run: |
|
run: |
|
||||||
./.github/actions/install_deps.sh ${{ matrix.os }}
|
./.github/actions/install_deps.sh ${{ matrix.os }}
|
||||||
- name: Install MinGW
|
- name: Install MinGW
|
||||||
run: |
|
run: | # dpkg-dev is apparently required for pkg-config for cross-building
|
||||||
sudo apt-get install {gcc,g++}-mingw-w64-${{ matrix.arch }} mingw-w64-tools libz-mingw-w64-dev
|
sudo apt-get install {gcc,g++}-mingw-w64-${{ matrix.arch }}-win32 mingw-w64-tools libz-mingw-w64-dev dpkg-dev
|
||||||
- name: Install libpng dev headers for MinGW
|
- name: Install libpng dev headers for MinGW
|
||||||
run: |
|
run: |
|
||||||
sudo ./.github/actions/mingw-w64-libpng-dev.sh ${{ matrix.triplet }}
|
sudo ./.github/actions/mingw-w64-libpng-dev.sh ${{ matrix.triplet }}
|
||||||
@@ -177,17 +177,12 @@ jobs:
|
|||||||
run: |
|
run: |
|
||||||
make mingw${{ matrix.bits }} -j Q=
|
make mingw${{ matrix.bits }} -j Q=
|
||||||
- name: Package binaries
|
- name: Package binaries
|
||||||
run: |
|
run: | # DLL dependencies can be figured out using e.g. Dependency Walker
|
||||||
mkdir bins
|
mkdir bins
|
||||||
mv rgbasm bins/rgbasm.exe
|
mv -v rgb{asm,link,fix,gfx}.exe bins/
|
||||||
mv rgblink bins/rgblink.exe
|
cp -v /usr/${{ matrix.triplet }}/lib/zlib1.dll bins
|
||||||
mv rgbfix bins/rgbfix.exe
|
cp -v /usr/${{ matrix.triplet }}/bin/libpng16-16.dll bins
|
||||||
mv rgbgfx bins/rgbgfx.exe
|
[ "${{ matrix.bits }}" -ne 32 ] || cp -v /usr/lib/gcc/${{ matrix.triplet }}/10-win32/lib{gcc_s_dw2-1,ssp-0,stdc++-6}.dll bins
|
||||||
cp /usr/${{ matrix.triplet }}/lib/zlib1.dll bins
|
|
||||||
cp /usr/${{ matrix.triplet }}/bin/libpng16-16.dll bins
|
|
||||||
if [ ${{ matrix.bits }} -eq 32 ]; then cp /usr/lib/gcc/${{ matrix.triplet }}/7.3-win32/lib{gcc_s_sjlj-1,stdc++-6}.dll bins; fi
|
|
||||||
mv test/gfx/randtilegen{,.exe}
|
|
||||||
mv test/gfx/rgbgfx_test{,.exe}
|
|
||||||
- name: Upload Windows binaries
|
- name: Upload Windows binaries
|
||||||
uses: actions/upload-artifact@v3
|
uses: actions/upload-artifact@v3
|
||||||
with:
|
with:
|
||||||
|
|||||||
4
Makefile
4
Makefile
@@ -267,12 +267,12 @@ debug:
|
|||||||
mingw32:
|
mingw32:
|
||||||
$Q${MAKE} all test/gfx/randtilegen test/gfx/rgbgfx_test \
|
$Q${MAKE} all test/gfx/randtilegen test/gfx/rgbgfx_test \
|
||||||
CC=i686-w64-mingw32-gcc CXX=i686-w64-mingw32-g++ \
|
CC=i686-w64-mingw32-gcc CXX=i686-w64-mingw32-g++ \
|
||||||
BISON=bison PKG_CONFIG=i686-w64-mingw32-pkg-config -j
|
BISON=bison PKG_CONFIG="PKG_CONFIG_SYSROOT_DIR=/usr/i686-w64-mingw32 pkg-config"
|
||||||
|
|
||||||
mingw64:
|
mingw64:
|
||||||
$Q${MAKE} all test/gfx/randtilegen test/gfx/rgbgfx_test \
|
$Q${MAKE} all test/gfx/randtilegen test/gfx/rgbgfx_test \
|
||||||
CC=x86_64-w64-mingw32-gcc CXX=x86_64-w64-mingw32-g++ \
|
CC=x86_64-w64-mingw32-gcc CXX=x86_64-w64-mingw32-g++ \
|
||||||
BISON=bison PKG_CONFIG=x86_64-w64-mingw32-pkg-config -j
|
BISON=bison PKG_CONFIG="PKG_CONFIG_SYSROOT_DIR=/usr/x86_64-w64-mingw32 pkg-config"
|
||||||
|
|
||||||
wine-shim:
|
wine-shim:
|
||||||
$Qecho '#!/bin/bash' > rgbshim.sh
|
$Qecho '#!/bin/bash' > rgbshim.sh
|
||||||
|
|||||||
Reference in New Issue
Block a user