From 6f178a6de46a81da6b660cf1ea4dd04f51c28815 Mon Sep 17 00:00:00 2001 From: AJ ONeal Date: Sat, 4 Nov 2023 23:18:29 -0600 Subject: [PATCH] feat: tinygo build scripts for windows --- tinygo-build-windows.ps1 | 49 +++++++++++++++++++++++++++++++++++++++ tinygo-build-windows.sh | 50 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 99 insertions(+) create mode 100644 tinygo-build-windows.ps1 create mode 100644 tinygo-build-windows.sh diff --git a/tinygo-build-windows.ps1 b/tinygo-build-windows.ps1 new file mode 100644 index 0000000..5bafec1 --- /dev/null +++ b/tinygo-build-windows.ps1 @@ -0,0 +1,49 @@ +#!/bin/bin/env pwsh + +# TODO use the git log describe thing +$my_version = git describe --tags +$Env:GOOS = "windows" + +function fn_package() { + IF ($Env:GOARM.Length -gt 0) { + $my_arch = "${Env:GOARCH}v${Env:GOARM}" + } ELSEIF ($Env:GOAMD64.Length -gt 0) { + $my_arch = "${Env:GOARCH}_${Env:GOAMD64}" + } ELSE { + $my_arch = "${Env:GOARCH}" + } + + $my_bin = "pathman-${my_version}-${Env:GOOS}-${my_arch}" + tinygo build -no-debug -o "${my_bin}" + #strip "${my_bin}" || true + + tar cvzf "$my_bin.tar" "$my_bin" + Compress-Archive "$my_bin" "$my_bin.zip" + + Write-Output "$my_bin.zip" + } + +$Env:GOAMD64 = "v1" +$Env:GOARCH = "amd64" +fn_package +$Env:GOAMD64 = "" + +# $Env:GOARCH = "386" +# fn_package + +$Env:GOARCH = "arm64" +fn_package + +# $Env:GOARCH = "arm" +# $Env:GOARM = "7" +# fn_package + +# $Env:GOARCH = "arm" +# $Env:GOARM = "6" +# fn_package + +# unset vars +$Env:GOOS = "" +$Env:GOARCH = "" +$Env:GOARM = "" +$Env:GOAMD64 = "" diff --git a/tinygo-build-windows.sh b/tinygo-build-windows.sh new file mode 100644 index 0000000..19b3428 --- /dev/null +++ b/tinygo-build-windows.sh @@ -0,0 +1,50 @@ +#!/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="windows" + +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-${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" + zip "$my_bin.zip" "$my_bin" + + echo "$my_bin.zip" +); } + +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