You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
rwxrob-dot/scripts/godistbuild

26 lines
639 B
Bash

#!/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 $*