mirror of
https://github.com/benbusby/farside.git
synced 2025-04-19 18:38:42 +00:00
Add cross compiler script [skip ci]
This commit is contained in:
parent
6682d5c59a
commit
4ec94a141d
2 changed files with 46 additions and 0 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -1,3 +1,4 @@
|
||||||
badger-db
|
badger-db
|
||||||
farside
|
farside
|
||||||
deploy.sh
|
deploy.sh
|
||||||
|
out
|
||||||
|
|
45
cross_compile.sh
Executable file
45
cross_compile.sh
Executable file
|
@ -0,0 +1,45 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
dir=$(CDPATH= cd -- "$(dirname -- "$0")" && pwd)
|
||||||
|
|
||||||
|
mkdir -p $dir/out/
|
||||||
|
rm -f $dir/out/*
|
||||||
|
|
||||||
|
platforms=(
|
||||||
|
"linux/arm"
|
||||||
|
"linux/amd64"
|
||||||
|
"linux/arm64"
|
||||||
|
"linux/386"
|
||||||
|
"darwin/amd64"
|
||||||
|
"darwin/arm64"
|
||||||
|
"windows/386"
|
||||||
|
"windows/amd64"
|
||||||
|
"windows/arm64")
|
||||||
|
|
||||||
|
for platform in "${platforms[@]}"
|
||||||
|
do
|
||||||
|
platform_split=(${platform//\// })
|
||||||
|
GOOS=${platform_split[0]}
|
||||||
|
GOARCH=${platform_split[1]}
|
||||||
|
output_name="farside"
|
||||||
|
|
||||||
|
tar_name="farside_${GOOS}_${GOARCH}.tar.gz"
|
||||||
|
if [ $GOOS = "darwin" ]; then
|
||||||
|
tar_name="farside_macOS_${GOARCH}.tar.gz"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ $GOOS = "windows" ]; then
|
||||||
|
output_name+=".exe"
|
||||||
|
fi
|
||||||
|
|
||||||
|
compile_cmd="GOOS=$GOOS GOARCH=$GOARCH go build -ldflags='-s -w' -o $output_name ."
|
||||||
|
echo "└ $compile_cmd"
|
||||||
|
eval $compile_cmd
|
||||||
|
if [ $? -ne 0 ]; then
|
||||||
|
echo "An error has occurred! Aborting the script execution..."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
tar -czvf out/$tar_name $output_name
|
||||||
|
rm -f $output_name
|
||||||
|
done
|
Loading…
Add table
Reference in a new issue