-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
75 lines (66 loc) · 2.51 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
# Makefile to help with building portray
#
BUILD_VERSION:=$(shell git describe --tags)
GIT_COMMIT := $(shell git rev-parse HEAD)
BUILD_TIME := $(shell TZ=utc date)
GO_VERSION := $(shell go version | sed 's/go version //')
LDFLAGS=-ldflags "-X main.Version=${BUILD_VERSION} -X main.GitCommit=${GIT_COMMIT} -X \"main.BuildTime=${BUILD_TIME}\" -X \"main.GoVersion=${GO_VERSION}\""
# Colors
NOCOLOR=\033[0m
RED=\033[0;31m
GREEN=\033[0;32m
help:
@echo ""
@echo ""
@echo " build builds portray for your current environment"
@echo " build_multi builds portray for multiple environments"
@echo ""
clean:
@go clean
build:
go get
@echo "Building portray for your current environment"
go build ${LDFLAGS} && echo "${GREEN}Success!${NOCOLOR}" || echo "${RED}Build failed!${NOCOLOR}";
build_multi:
go get
@echo "Building portray for Linux amd64"
GOOS=linux GOARCH=amd64 go build ${LDFLAGS} -o portray-linux-amd64 main.go
@echo "Building portray for Mac OS X amd64"
GOOS=darwin GOARCH=amd64 go build ${LDFLAGS} -o portray-mac-amd64 main.go
@echo "Building portray for Windows amd64"
GOOS=windows GOARCH=amd64 go build ${LDFLAGS} -o portray-windows-amd64 main.go
debug_in_tmux_pane:
@echo "Launching delve debugger in bottom-right tmux pane"
@if pgrep dlv >/dev/null 2>&1; then killall dlv; fi
@tmux send-keys -t bottom-right 'echo "Magic launching Delve debugger"' Enter
@tmux send-keys -t bottom-right 'dlv exec portray -- ${PORTRAY_ARGS}' ENTER
exec_in_tmux_pane:
@echo "Executing in bottom-right tmux pane"
@if pgrep dlv >/dev/null 2>&1; then killall dlv; fi
@tmux send-keys -t bottom-right './portray ${PORTRAY_ARGS}' ENTER
execloop:
@echo "Starting file watcher"
@fswatch --exclude='.*\.git' \
--exclude='.*\.yaml' \
--exclude='.*\.json' \
--exclude='.*\.swp' \
--exclude='.*\debug.*?' \
--exclude='.*4913' \
--exclude='Makefile' \
--exclude='LICENSE' \
--exclude='.*/portray/portray' \
--recursive . | \
xargs -n1 -I{} sh -c 'echo "Change detected: {}"; make clean; make build; if [ -f portray ]; then make exec_in_tmux_pane PORTRAY_ARGS="${PORTRAY_ARGS}"; fi'
debugloop:
@echo "Starting file watcher"
@fswatch --exclude='.*\.git' \
--exclude='.*\.yaml' \
--exclude='.*\.json' \
--exclude='.*\.swp' \
--exclude='.*\debug.*?' \
--exclude='.*4913' \
--exclude='Makefile' \
--exclude='LICENSE' \
--exclude='.*/portray/portray' \
--recursive . | \
xargs -n1 -I{} sh -c 'echo "Change detected: {}"; make clean; make build; if [ -f portray ]; then make debug_in_tmux_pane PORTRAY_ARGS="${PORTRAY_ARGS}"; fi'