Skip to content

Commit

Permalink
Create buildbin.sh
Browse files Browse the repository at this point in the history
  • Loading branch information
brechtsanders committed Mar 28, 2024
1 parent b968a31 commit 4054fd9
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions buildbin.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#!/bin/sh
CC=gcc
CXX=g++

# determine target platform
TARGET=
if ( uname -s | grep -qi "MINGW\|MSYS" ); then
if ( gcc --version | grep -q x86_64 ); then
TARGET=win64
else
TARGET=win32
fi
fi
if [ "$TARGET" = "" ]; then
echo "Unsupported platform, currently only MinGW on Windows is supported"
exit 1;
fi

VERSION=$(sed -ne "s/^#define\s*XLSXIO_VERSION_[A-Z]*\s*\([0-9]*\)\s*$/\1./p" include/xlsxio_version.h | tr -d "\n" | sed -e "s/\.$//")
BUILDDST=build_$TARGET
ZIPFILE=xlsxio-$VERSION-binary-$TARGET.zip
#CFLAGS="-DUSE_LIBZIP"
#LDFLAGS="-lzip -lz"
CFLAGS="-DUSE_MINIZIP"
LDFLAGS="-lminizip -lz"

rm -f $ZIPFILE &> /dev/null
mkdir -p $BUILDDST &&
$CC -mdll -static -o$BUILDDST/xlsxio_read.dll -Wl,--out-implib,$BUILDDST/libxlsxio_read.a -DBUILD_XLSXIO_DLL -DBUILD_XLSXIO_STATIC_DLL -Iinclude lib/xlsxio_read.c lib/xlsxio_read_sharedstrings.c $CFLAGS $LDFLAGS -lexpat &&
$CC -mdll -static -o$BUILDDST/xlsxio_write.dll -Wl,--out-implib,$BUILDDST/libxlsxio_write.a -DBUILD_XLSXIO_DLL -DBUILD_XLSXIO_STATIC_DLL -Iinclude lib/xlsxio_write.c $CFLAGS $LDFLAGS &&
$CC -mconsole -s -o$BUILDDST/xlsxio_xlsx2csv.exe src/xlsxio_xlsx2csv.c -Iinclude $BUILDDST/libxlsxio_read.a &&
$CC -mconsole -s -o$BUILDDST/xlsxio_csv2xlsx.exe src/xlsxio_csv2xlsx.c -Iinclude $BUILDDST/libxlsxio_write.a &&
zip -qj $ZIPFILE LICENSE.txt Changelog.txt README.md include/* $BUILDDST/* &&
echo Created $ZIPFILE &&
rm -rf $BUILDDST

0 comments on commit 4054fd9

Please sign in to comment.