forked from mongodb/mongo-tools
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.sh
executable file
·40 lines (32 loc) · 878 Bytes
/
build.sh
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
#!/bin/bash
set -o errexit
tags=""
if [ ! -z "$1" ]
then
tags="$@"
fi
# make sure we're in the directory where the script lives
SCRIPT_DIR="$(cd "$(dirname ${BASH_SOURCE[0]})" && pwd)"
cd $SCRIPT_DIR
. ./set_goenv.sh
set_goenv || exit
BINARY_EXT=""
UNAME_S=$(PATH="/usr/bin:/bin" uname -s)
case ${UNAME_S} in
CYGWIN*)
BINARY_EXT=".exe"
;;
esac
# remove stale packages
rm -rf vendor/pkg
mkdir -p bin
ec=0
for i in bsondump mongostat mongofiles mongoexport mongoimport mongorestore mongodump mongotop mongoreplay; do
echo "Building ${i}..."
go build -o "bin/$i$BINARY_EXT" $(buildflags) -ldflags "$(print_ldflags)" -tags "$(print_tags $tags)" "$i/main/$i.go" || { echo "Error building $i"; ec=1; break; }
./bin/${i}${BINARY_EXT} --version | head -1
done
if [ -t /dev/stdin ]; then
stty sane
fi
exit $ec