rwxrob-dot/scripts/godistbuild
Rob Muhlestein 2ea0289e9f Rebase
2022-02-09 02:29:05 -05:00

26 lines
639 B
Bash
Executable File

#!/usr/bin/env bash
# Builds the passed Go package or command for every supported operating system and architecture into directories named for such and logs.
godistbuild () {
declare relpath="${1-$PWD}"
declare dir="$PWD/dist"
declare log="$dir/build.log"
rm -rf "$dir"
mkdir "$dir"
cd "$dir"
>| $log # truncate
for dist in $(go tool dist list); do
[[ ! -d $dist ]] && mkdir -p $dist
declare os=${dist%/*}
declare arch=${dist#*/}
echo "BUILDING: $os-$arch" | tee -a $log
cd $dist
GOOS=$os GOARCH=$arch go build $relpath >> $log 2>&1
echo >> $log
cd - &>/dev/null
done
}
godistbuild $*