-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathMakefile
51 lines (43 loc) · 1.56 KB
/
Makefile
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
50
51
SHELL = bash
OSARCHES := "darwin/amd64 linux/386 linux/amd64 linux/arm linux/arm64 linux/ppc64 linux/ppc64le linux/s390x"
DARWIN_ARCHES = amd64 arm64
LINUX_ARCHES = 386 amd64 arm arm64 ppc64 ppc64le s390x
OUTPUT := "build/bifrost-$(VERSION)-{{.OS}}-{{.Arch}}/bifrost"
test:
@socat pty,link=/tmp/bifrostport1,echo=0,crnl pty,link=/tmp/bifrostport2,echo=0,crnl & echo "$$!" > "socat.pid"
go test -v
@if [ -a socat.pid ]; then \
kill -TERM $$(cat socat.pid) || true; \
rm socat.pid || true; \
fi
test_coverage:
@socat pty,link=/tmp/bifrostport1,echo=0,crnl pty,link=/tmp/bifrostport2,echo=0,crnl & echo "$$!" > "socat.pid"
go test -v -coverprofile=cover.out && go tool cover -html=cover.out
@if [ -a socat.pid ]; then \
kill -TERM $$(cat socat.pid) || true; \
fi
@rm socat.pid
# build darwin/amd64 separately when building on Linux
# use cross compiler xgo
# xgo --targets=darwin/amd64 github.com/ishuah/bifrost
build_all:
if [ -z $(VERSION) ]; then \
echo "You need to specify a VERSION"; \
exit 1; \
fi
mkdir -p build
if [ -d "build/" ]; then \
rm -rf build/*; \
fi
# Build Darwin first
for arch in $(DARWIN_ARCHES); do \
echo $$arch; \
GOOS=darwin GOARCH=$$arch go build -o "build/bifrost-$(VERSION)-darwin-$$arch/bifrost"; \
done
# Build Linux
for arch in $(LINUX_ARCHES); do \
echo $$arch; \
GOOS=linux GOARCH=$$arch go build -o "build/bifrost-$(VERSION)-linux-$$arch/bifrost"; \
done
echo "compressing build files"
cd build && for d in */; do filepath=$${d%/*}; echo $$filepath; zip "$${filepath##*/}.zip" "$${filepath##*/}/bifrost"; done