-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.sh
More file actions
41 lines (32 loc) · 818 Bytes
/
build.sh
File metadata and controls
41 lines (32 loc) · 818 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#!/usr/bin/env bash
set -eu
: "${WORK_DIR:=./}"
: "${CHARS_FILE:=${1:-glyph.txt}}"
build() {
local GOOS="${1:-linux}" GOARCH="${2:-amd64}" bin
bin="homo${CHARS_FILE%.txt}-$GOOS-$GOARCH"
[ "$GOOS" = windows ] && bin+=.exe
printf 'Build:\t%-10s%-7s' "$GOOS" "$GOARCH"
CGO_ENABLED=0 GOARCH="$GOARCH" GOOS="$GOOS" \
GOFLAGS="-buildvcs=false -trimpath" \
go build -ldflags="-s -w " -o "./build/$bin" "$WORK_DIR"/...
echo "./build/$bin"
}
mkdir -p ./build
rm -f homoglyph.go homoglitch.go
go mod tidy
go run generate.go "$CHARS_FILE"
if [ -z "${3:-}" ]; then
build darwin amd64
build darwin arm64
build linux 386
build linux amd64
build linux arm
build linux arm64
build windows 386
build windows amd64
build windows arm64
else
build "${@:3}"
fi
rm "homo${CHARS_FILE%.txt}.go"