-
Notifications
You must be signed in to change notification settings - Fork 18
/
Makefile
96 lines (78 loc) · 2.57 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
VERSION = 0.3.5
BIN = ./bin
INSTALL_PKG = ./cmd/goggles
RELEASE_PLATFORMS = darwin/386 darwin/amd64 linux/386 linux/amd64 linux/arm windows/386 windows/amd64
LD_FLAGS = -ldflags "-X github.com/KyleBanks/goggles/cmd.version=$(VERSION)"
APP_INSTALL_PKG = ./cmd/goggles-app
APP_NAME = Goggles.app
APP_FOLDER = $(BIN)/$(APP_NAME)
APP_LOG_FILE = ~/Library/Logs/goggles.log
APP_BUNDLE_ID = com.kylewbanks.goggles
APP_BUNDLE_NAME = Goggles
# Runs Goggles within a web browser.
#
# This is the default command.
browser: | install
@goggles
.PHONY: browser
# Runs Goggles as a standalone app and opens the logs.
app: | build.app
@pkill Goggles || true
@open $(APP_FOLDER)
@tail -100f $(APP_LOG_FILE)
.PHONY: app
# Cleans, lints, and generates static assets.
assets:
@cd static ; \
npm install ; \
gulp
@go-bindata-assetfs -ignore=node_modules\|.DS_Store -pkg assets static/... ; \
mv bindata_assetfs.go server/assets/
.PHONY: assets
# Cleans any built artifacts.
clean:
@rm -rf $(BIN)
@rm -f $(APP_LOG_FILE)
.PHONY: clean
# Builds and installs Goggles as a browser application.
install: | clean assets
@go install -v $(LD_FLAGS) $(INSTALL_PKG)
.PHONY: install
# Builds Goggles as a standalone app to the ./bin directory.
build.app: | clean assets
@mkdir -p $(BIN)
@go build -v $(LD_FLAGS) -o $(BIN)/goggles-app $(APP_INSTALL_PKG)
@gallium-bundle $(BIN)/goggles-app \
--output $(APP_FOLDER) \
--identifier $(APP_BUNDLE_ID) \
--name $(APP_BUNDLE_NAME)
.PHONY: build.app
# Builds a release bundle for the standalone application, and
# binaries for the browser application.
release: | sanity build.app
@cd $(BIN) ; \
zip -r -y goggles.osx.app.$(VERSION).zip $(APP_NAME)
@gox -osarch="$(strip $(RELEASE_PLATFORMS))" \
-output "bin/{{.Dir}}_$(VERSION)_{{.OS}}_{{.Arch}}" $(INSTALL_PKG)
.PHONY: release
# Runs test cases in Docker.
test.docker:
@docker build -t goggles-test .
@docker run -it goggles-test
.PHONY: test.docker
# Runs test suit, vet, golint, and fmt.
sanity:
@echo "---------------- TEST ----------------"
@go list ./... | grep -v vendor/ | xargs go test --cover
@echo "---------------- VET ----------------"
@go list ./... | grep -v vendor/ | xargs go vet
@echo "---------------- LINT ----------------"
@go list ./... | grep -v -e vendor/ -e server/assets | xargs golint
@echo "---------------- FMT ----------------"
@go list ./... | grep -v vendor/ | xargs go fmt
.PHONY: sanity
# Installs a pre-commit Git hook that executes "make sanity" prior to commiting.
precommit:
@echo "make sanity" > .git/hooks/pre-commit
@chmod +x .git/hooks/pre-commit
.PHONY: precommit