mirror of
https://github.com/rwxrob/dot
synced 2024-11-18 15:25:52 +00:00
26 lines
639 B
Bash
Executable File
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 $*
|