From 3bf23349a12b26e51ac06d5793a604ec93233a12 Mon Sep 17 00:00:00 2001 From: AJ ONeal Date: Sat, 4 Nov 2023 22:35:41 -0600 Subject: [PATCH] feat: add build scripts for tinygo --- tinygo-build-linux.sh | 54 +++++++++++++++++++++++++++++++++++++++++++ tinygo-build-macos.sh | 38 ++++++++++++++++++++++++++++++ 2 files changed, 92 insertions(+) create mode 100644 tinygo-build-linux.sh create mode 100644 tinygo-build-macos.sh diff --git a/tinygo-build-linux.sh b/tinygo-build-linux.sh new file mode 100644 index 0000000..0cd42ab --- /dev/null +++ b/tinygo-build-linux.sh @@ -0,0 +1,54 @@ +#!/bin/sh +set -e +set -u + +# NOTE +# building for linux on linux seems to yield smaller sizes + +# TODO use the git log describe thing +my_version="0.6.0" +export GOOS="linux" + +fn_package() { ( + if test -n "${GOARM:-}"; then + my_arch="${GOARCH}v${GOARM}" + elif test -n "${GOAMD64:-}"; then + my_arch="${GOARCH}_${GOAMD64}" + else + my_arch="${GOARCH}" + fi + + my_bin="pathman-v${my_version}-${GOOS}-${my_arch}" + tinygo build -no-debug -o "${my_bin}" + strip "${my_bin}" || true + + tar cvf "$my_bin.tar" "$my_bin" + gzip --keep "$my_bin.tar" + xz --keep "$my_bin.tar" + + echo "$my_bin.tar.xz" +); } + +export GOAMD64=v1 +export GOARCH=amd64 +fn_package +export GOAMD64='' + +export GOARCH=386 +fn_package + +export GOARCH=arm64 +fn_package + +export GOARCH=arm +export GOARM=7 +fn_package + +export GOARCH=arm +export GOARM=6 +fn_package + +# no longer supported +# export GOARCH=arm +# export GOARM=5 +# fn_package diff --git a/tinygo-build-macos.sh b/tinygo-build-macos.sh new file mode 100644 index 0000000..e6fad91 --- /dev/null +++ b/tinygo-build-macos.sh @@ -0,0 +1,38 @@ +#!/bin/sh +set -e +set -u + +# NOTE +# building for macOS on macOS seems to yield smaller sizes + +# TODO use the git log describe thing +my_version="0.6.0" +export GOOS="darwin" + +fn_package() { ( + if test -n "${GOARM:-}"; then + my_arch="${GOARCH}v${GOARM}" + elif test -n "${GOAMD64:-}"; then + my_arch="${GOARCH}_${GOAMD64}" + else + my_arch="${GOARCH}" + fi + + my_bin="pathman-v${my_version}-${GOOS}-${my_arch}" + tinygo build -no-debug -o "${my_bin}" + strip "${my_bin}" || true + + tar cvf "$my_bin.tar" "$my_bin" + gzip --keep "$my_bin.tar" + xz --keep "$my_bin.tar" + + echo "$my_bin.tar.xz" +); } + +export GOAMD64=v2 +export GOARCH=amd64 +fn_package +export GOAMD64='' + +export GOARCH=arm64 +fn_package