Add windows builds

This commit is contained in:
Travis Burtrum 2020-01-03 00:20:05 -05:00
parent c05e5cc906
commit cb8ff1c78e
5 changed files with 98 additions and 5 deletions

View File

@ -1,5 +1,7 @@
#!/bin/sh
ARCH="$1"
set -exu
# change to the directory this script is in
@ -33,3 +35,61 @@ export TEST_BINS="./pegh.static.openssl ./pegh.openssl ./pegh.static.libsodium-o
./test.sh
echo "successfully built and tested static pegh against libsodium and openssl!"
if [ "$ARCH" == "amd64" ] || [ "$ARCH" == "i386" ]
then
echo 'going to try to build windows here...'
apk add mingw-w64-gcc curl
STATIC_LIB_DIR="$(pwd)"
LIBSODIUM_VERSION=1.0.18
curl -O https://download.libsodium.org/libsodium/releases/libsodium-${LIBSODIUM_VERSION}-stable-mingw.tar.gz -O https://curl.haxx.se/windows/dl-7.67.0_5/openssl-1.1.1d_5-win64-mingw.zip -O https://curl.haxx.se/windows/dl-7.67.0_5/openssl-1.1.1d_5-win32-mingw.zip
echo "df9c5df0355ddd423350471f37d2a595b9b1be228a787f4ed8109c208d9e2655 libsodium-${LIBSODIUM_VERSION}-stable-mingw.tar.gz" > libs.sha256
echo '4f474918a1597d6d1d35e524cf79827623f8ce511259b0047ee95bc0fddbf29c openssl-1.1.1d_5-win32-mingw.zip' >> libs.sha256
echo '936260c5a865c8e3f6af35a5394dd1acc43063a40a206c717350f1a341d8d822 openssl-1.1.1d_5-win64-mingw.zip' >> libs.sha256
sha256sum -c libs.sha256
tar xzvf libsodium-${LIBSODIUM_VERSION}-stable-mingw.tar.gz
unzip openssl-1.1.1d_5-win32-mingw.zip
unzip openssl-1.1.1d_5-win64-mingw.zip
if [ "$ARCH" == "i386" ]
then
make CC=i686-w64-mingw32-cc PEGH_LIBSODIUM_WIN="${STATIC_LIB_DIR}/libsodium-win32" clean all
mv pegh.exe pegh-i386-libsodium.exe
make CC=i686-w64-mingw32-cc PEGH_OPENSSL_WIN="${STATIC_LIB_DIR}/openssl-1.1.1d-win32-mingw" clean all
mv pegh.exe pegh-i386-openssl.exe
make CC=i686-w64-mingw32-cc PEGH_OPENSSL_WIN="${STATIC_LIB_DIR}/openssl-1.1.1d-win32-mingw" PEGH_LIBSODIUM_WIN="${STATIC_LIB_DIR}/libsodium-win32" clean all
mv pegh.exe pegh-i386-libsodium-openssl.exe
fi
if [ "$ARCH" == "amd64" ]
then
make CC=x86_64-w64-mingw32-cc PEGH_LIBSODIUM_WIN="${STATIC_LIB_DIR}/libsodium-win64" clean all
mv pegh.exe pegh-amd64-libsodium.exe
make CC=x86_64-w64-mingw32-cc PEGH_OPENSSL_WIN="${STATIC_LIB_DIR}/openssl-1.1.1d-win64-mingw" clean all
mv pegh.exe pegh-amd64-openssl.exe
make CC=x86_64-w64-mingw32-cc PEGH_OPENSSL_WIN="${STATIC_LIB_DIR}/openssl-1.1.1d-win64-mingw" PEGH_LIBSODIUM_WIN="${STATIC_LIB_DIR}/libsodium-win64" clean all
mv pegh.exe pegh-amd64-libsodium-openssl.exe
fi
ls -lah *.exe
strip *.exe
ls -lah *.exe
file *.exe
# todo: no testing these here for now...
fi

View File

@ -10,11 +10,14 @@ rm -rf "$BUILD_DIR"
mkdir -p "$BUILD_DIR"
cp * .ci/build.sh "$BUILD_DIR"
docker run --rm -v "$BUILD_DIR":/tmp "$DOCKER_IMAGE" /tmp/build.sh || exit 1
docker run --rm -v "$BUILD_DIR":/tmp "$DOCKER_IMAGE" /tmp/build.sh "$ARCH" || exit 1
mv "$BUILD_DIR"pegh.static.openssl "./pegh-$ARCH-openssl"
mv "$BUILD_DIR"pegh.static.libsodium "./pegh-$ARCH-libsodium"
mv "$BUILD_DIR"pegh.static.libsodium-openssl "./pegh-$ARCH-libsodium-openssl"
mv "$BUILD_DIR"pegh-*.exe ./
rm -rf "$BUILD_DIR" 2>/dev/null
exit 0

2
.gitignore vendored
View File

@ -4,4 +4,6 @@ pegh.libsodium*
pegh.openssl
bla.txt
*.exe
*.kate-swp

View File

@ -8,6 +8,26 @@ CFLAGS += -Wall -Wextra -Werror -std=c89 -pedantic \
-Wno-missing-prototypes -Wno-missing-noreturn -Wno-format \
-O3
# build or grab from https://curl.haxx.se/windows/
ifdef PEGH_OPENSSL_WIN
ifdef PEGH_LIBSODIUM_WIN
# both libsodium and openssl
CFLAGS = -DPEGH_LIBSODIUM -DPEGH_OPENSSL -I "${PEGH_LIBSODIUM_WIN}/include/" -I "${PEGH_OPENSSL_WIN}/include/"
LDLIBS += "${PEGH_LIBSODIUM_WIN}/lib/libsodium.a" "${PEGH_OPENSSL_WIN}/lib/libcrypto.a" -lws2_32
else
# only openssl
CFLAGS = -DPEGH_OPENSSL -I "${PEGH_OPENSSL_WIN}/include/"
LDLIBS += "${PEGH_OPENSSL_WIN}/lib/libcrypto.a" -lws2_32
endif
else
# build or grab from https://download.libsodium.org/libsodium/releases/
ifdef PEGH_LIBSODIUM_WIN
CFLAGS = -DPEGH_LIBSODIUM -I "${PEGH_LIBSODIUM_WIN}/include/"
LDLIBS += "${PEGH_LIBSODIUM_WIN}/lib/libsodium.a"
else
ifdef PEGH_OPENSSL
ifdef PEGH_LIBSODIUM
@ -31,6 +51,8 @@ CFLAGS += -DPEGH_OPENSSL
LDLIBS += -lcrypto
endif
endif
endif
endif
all : pegh

View File

@ -12,11 +12,17 @@ This implementation is built in C and can link with OpenSSL, libsodium, *or* lib
Releases
--------
[Releases](https://github.com/moparisthebest/pegh/releases) contains static binaries for Linux architectures amd64, i386, and aarch64, more to come...
[Releases](https://github.com/moparisthebest/pegh/releases) contain static binaries for:
`pegh-$ARCH-openssl` - supports AES-256-GCM and Chacha20-Poly1305 on all CPUs
`pegh-$ARCH-libsodium` - supports Chacha20-Poly1305 on all CPUs, but AES-256-GCM only on CPUs with hardware support for aes-ni
`pegh-$ARCH-libsodium-openssl` - supports AES-256-GCM and Chacha20-Poly1305 on all CPUs, uses libsodium for everything if possible, but OpenSSL's software AES implementation if the CPU does not support aes-ni
* Linux amd64, i386, aarch64
* Windows amd64, i386
* more to come?
what do the names mean?
* `pegh-$ARCH-openssl` - supports AES-256-GCM and Chacha20-Poly1305 on all CPUs
* `pegh-$ARCH-libsodium` - supports Chacha20-Poly1305 on all CPUs, but AES-256-GCM only on CPUs with hardware support for aes-ni
* `pegh-$ARCH-libsodium-openssl` - supports AES-256-GCM and Chacha20-Poly1305 on all CPUs, uses libsodium for everything if possible, but OpenSSL's software AES implementation if the CPU does not support aes-ni
Usage
-----