-
Notifications
You must be signed in to change notification settings - Fork 84
/
install
executable file
·50 lines (43 loc) · 1.57 KB
/
install
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
42
43
44
45
46
47
48
49
#!/usr/bin/env bash
extract() {
if [ -f "vendor.tar.gz" ]; then
tar xvf vendor.tar.gz
fi
}
if [ ! -f install ]; then
echo 'install must be run within its container folder' 1>&2
exit 1
fi
CURDIR=`pwd`
cd $CURDIR
OLDGOPATH="$GOPATH"
export GOPATH="$CURDIR/vendor:$CURDIR"
if [ ! -d src ]; then
gofmt -w src
fi
if [ $# = 1 ]; then
case $1 in
init) cd $CURDIR;extract;mkdir -p src bin dat pkg;;
clean) cd $CURDIR;rm -rf vendor bin dat pkg;;
esac
fi
if [ $# = 2 ]; then
cd "src"
cp "./test/$2.go" main.go
case $1 in
local) go get;CGO_ENABLED=0 go build -ldflags="-s -w" -o "$CURDIR/bin/$2-local";;
mips) go get;CGO_ENABLED=0 GOOS=linux GOARCH=mips go build -ldflags="-s -w" -o "$CURDIR/bin/$2-mips";;
mipsle) go get;CGO_ENABLED=0 GOOS=linux GOARCH=mipsle go build -ldflags="-s -w" -o "$CURDIR/bin/$2-mipsle";;
arm) go get;CGO_ENABLED=0 GOOS=linux GOARCH=arm GOARM=5 go build -ldflags="-s -w" -o "$CURDIR/bin/$2-arm";;
arm64) go get;CGO_ENABLED=0 GOOS=linux GOARCH=arm64 go build -ldflags="-s -w" -o "$CURDIR/bin/$2-arm64";;
linux) go get;CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags="-s -w" -o "$CURDIR/bin/$2-lin64";;
lin86) go get;CGO_ENABLED=0 GOOS=linux GOARCH=386 go build -ldflags="-s -w" -o "$CURDIR/bin/$2-lin86";;
win64) go get;CGO_ENABLED=0 GOOS=windows GOARCH=amd64 go build -ldflags="-s -w" -o "$CURDIR/bin/$2-win64";;
win32) go get;CGO_ENABLED=0 GOOS=windows GOARCH=386 go build -ldflags="-s -w" -o "$CURDIR/bin/$2-win32";;
esac
echo "build ok ...."
fi
if [ ! -f main.go ]; then
rm -rf main.go
fi
export GOPATH="$OLDGOPATH"