Script for building for all platforms

This commit is contained in:
r4 2021-07-02 16:46:22 +02:00
parent a0ae32050f
commit 4e0274d7eb

28
build-all.sh Executable file
View File

@ -0,0 +1,28 @@
#! /usr/bin/env sh
BUILDDIR="build"
[ "$1" = "clean" ] && echo "Cleaning $BUILDDIR" && rm -rf "$BUILDDIR" && exit 0
build() {
# [linux|dragonfly|freebsd|netbsd|openbsd|plan9|solaris|darwin|windows]"
OS="$1"
# [arm|arm64|ppc64|ppc64le|mips64|386|amd64]
ARCH="$2"
echo "Building for $OS on $ARCH"
[ "$OS" = "windows" ] && EXT=".exe"
mkdir -p "$BUILDDIR"
env GOOS="$OS" GOARCH="$ARCH" CGO_ENABLED=0 go build -ldflags "-s -w" -o "$BUILDDIR/$OS-$ARCH$EXT"
}
build linux 386
build linux amd64
build linux arm
build linux arm64
build darwin amd64
build windows 386
build windows amd64