-
Notifications
You must be signed in to change notification settings - Fork 4
/
Makefile
105 lines (83 loc) · 2.7 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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
.PHONY: list
# --------
# for those that like to go against the grain :-)
ifndef GOPATH
GOPATH:=$(shell go env GOPATH)
else
GOPATH:=$(firstword $(subst :, ,$(GOPATH)))
endif
ifndef GOBIN
GOBIN:=$(GOPATH)/bin
endif
EXAMPLE_FILE:=examples/example.lang
# --------
default: run
run: clean build test smoke
# list available targets in Makefile
list:
@echo ""
@echo "Make targets:"
@echo ' ' `$(MAKE) -pRrq -f $(lastword $(MAKEFILE_LIST)) : 2>/dev/null | awk -v RS= -F: '/^# File/,/^# Finished Make data base/ {if ($$1 !~ "^[#.]") {print $$1}}' | sort | egrep -v -e '^[^[:alnum:]]' -e '^(default|setup|ci|exectest|execsmoke)$$' -e '^$@$$' | xargs`
@echo ""
# one-time setup for local environments
setup:
@echo "===== Setup ====="
@which go > /dev/null 2>&1 && echo "<`go version`> is already installed" || brew install golang
@echo 'Ensure the following environment variables are set if you have not already done so:'
@echo ' GOPATH=$(GOPATH)'
@echo ' PATH=$(GOBIN):$$PATH'
@mkdir -p $(GOPATH)/src/github.com/ThoughtWorksStudios
@test -e $(GOPATH)/src/github.com/ThoughtWorksStudios/bobcat || ln -s `pwd` $(GOPATH)/src/github.com/ThoughtWorksStudios/bobcat
@echo ""
# one-time automation of dev setup for local environments
local: setup clean depend build test smoke
# automate run for ci
ci: clean depend run
# add and run werkcer cli locally
wercker:
brew tap wercker/wercker
brew install wercker-cli
wercker build
# get dependencies requires by the application
depend:
go get github.com/mna/pigeon
go get -d -t
prepare:
@$(GOBIN)/pigeon -o dsl/dsl.go dsl/dsl.peg
compile:
@echo "===== Compiling ====="
@for platform in `test -z "$$WERCKER_ROOT" && echo "darwin" || echo "darwin linux windows"`; do \
echo "Building binary for $$platform"; GOOS=$$platform GOARCH=amd64 go build -o bobcat-$$platform; \
done
@echo ""
exectest:
@echo "===== Unit tests ====="
go test ./common ./dictionary ./dsl ./emitter ./generator ./interpreter .
@echo ""
execsmoke:
@echo "===== Smoke test ====="
@echo "Running binary on $(EXAMPLE_FILE)"
@test "Darwin" = `uname -s` && ./bobcat-darwin $(EXAMPLE_FILE) || ./bobcat-linux $(EXAMPLE_FILE)
@echo ""
build: prepare compile
# just run tests
test: prepare exectest
# smoke tests
smoke: build execsmoke
# Runs benchmarks
performance:
go test -bench=. ./dictionary ./interpreter ./generator
# remove junk files
clean:
@echo "===== Cleaning up ====="
go clean
rm -f dsl/dsl.go
rm -f bobcat bobcat-*
find . -type f ! -name 'package.json' -name '*.json' -delete
@echo ""
# create a release tarball
release: depend build
@echo ""
@echo "===== Packaging release ====="
tar czf bobcat.tar.gz bobcat-* examples/example.lang examples/users.lang examples/full_address_format
@echo ""