This repository has been archived by the owner on Jun 8, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMakefile
74 lines (62 loc) · 2.47 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
.PHONY: help build build_darwin build_linux build_linux_app build_termbox clean install fix test travis uninstall
default: build
help:
@grep -E '^[a-zA-Z_-]+:.*?## .' $(MAKEFILE_LIST) | sort | awk -F ':.*?## ' '{printf "%s\t\t\t%s\n",$$1,$$2}'
build: ## Build a release binary
$(MAKE) build_linux
ifeq ($(shell uname -s),Darwin)
$(MAKE) build_darwin
endif
build_darwin:
crystal deps --production
$(MAKE) build_termbox
crystal build.darwin-x86_64.cr
otool -L bin/git-cleanup-branch-darwin-x86_64
sandbox-exec -f test.darwin-x86_64.sb bin/git-cleanup-branch-darwin-x86_64 --help
build_linux:
docker build -f Dockerfile.build.linux-x86_64 -t git-cleanup-branch.build.linux-x86_64 .
docker run --rm -v $(shell pwd):/data git-cleanup-branch.build.linux-x86_64 make build_linux_app
docker build -f Dockerfile.test.linux-x86_64 -t git-cleanup-branch.test.linux-x86_64 .
docker run --rm git-cleanup-branch.test.linux-x86_64 git-cleanup-branch --help
build_linux_app:
crystal deps --production
$(MAKE) build_termbox
crystal build --release -o bin/git-cleanup-branch-linux-x86_64 --link-flags '-static' bin/git-cleanup-branch.cr
build_termbox:
cd lib/termbox \
&& (ls lib-termbox || git clone --depth=1 https://github.com/nsf/termbox lib-termbox) \
&& cd lib-termbox \
&& git pull \
&& ./waf configure --prefix=/usr/local \
&& ./waf clean \
&& ./waf \
&& ./waf install --destdir=/
clean: ## Clean
rm -f bin/git-cleanup-branch-darwin-x86_64.o bin/git-cleanup-branch-darwin-x86_64 bin/git-cleanup-branch-linux-x86_64
fix: ## Fix lint automatically
find bin src spec -type f -name '*.cr' -exec crystal tool format {} \;
bundle exec rubocop -a
install: ## cp the binary to PATH
ifeq ($(shell uname -s),Linux)
cp bin/git-cleanup-branch-linux-x86_64 /usr/local/bin/git-cleanup-branch
endif
ifeq ($(shell uname -s),Darwin)
cp bin/git-cleanup-branch-darwin-x86_64 /usr/local/bin/git-cleanup-branch
endif
test: ## Test
find . bin -depth 1 -name '*.sh' -exec shellcheck -s sh {} \;
find bin src spec -name '*.cr' -exec crystal tool format --check {} \;
crystal spec
bundle exec rubocop
rm -f greenletters.log
bundle exec cucumber
travis:
cd lib/termbox \
&& git clone --depth=1 https://github.com/nsf/termbox lib-termbox \
&& cd lib-termbox \
&& ./waf configure --prefix=$(HOME) \
&& ./waf \
&& ./waf install --destdir=/
LIBRARY_PATH=$(HOME)/lib:$(LIBRARY_PATH) LD_LIBRARY_PATH=$(HOME)/lib:$(LD_LIBRARY_PATH) crystal spec
uninstall: ## rm the installed binary
rm -f /usr/local/bin/git-cleanup-branch