-
Notifications
You must be signed in to change notification settings - Fork 36
/
Makefile
59 lines (46 loc) · 1.22 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
BINFILE := bank/bin.go
NAMEFILE := bank/name.go
DATABINFILE := data/bin.csv
DATANAMEFILE := data/name.csv
TMPBINFILE := data/bin.tmp
REPOPATH := github.com/hexindai/bcbc
ifeq ($(DEBUG), 1)
debug := 1
else
debug := 0
endif
.PHONY: all
all: clean build test
.PHONY: clean
clean:
@echo "Clean..." \
&& rm -f $(BINFILE) $(NAMEFILE) \
&& go clean -i -testcache $(REPOPATH)
.PHONY: test
test: build
@echo "TEST..." \
&& go test $(REPOPATH)/bank
.PHONY: build
build:
@echo ">> Generating go source files with bankcard data" \
&& $(call sort_bin,$(DATABINFILE)) \
&& awk -f scripts/make-bin-go.awk $(DATABINFILE) > $(BINFILE) \
&& awk -f scripts/make-name-go.awk $(DATANAMEFILE) > $(NAMEFILE)
@echo ">> Formating and building" \
&& gofmt -l -w -s bank \
&& go build -v $(REPOPATH)
.PHONY: install
install:
go install $(REPOPATH)
.PHONY: add
add:
@# check bin via api
@# if success, append it to $(DATABINFILE)
@# use DEBUG=1 to enable debug
@echo "CHECK bin: $(bin) len: $(len)" \
&& awk -f scripts/check-bin.awk -v bin=$(bin) -v len=$(len) -v binfile=$(DATABINFILE) -v debug=$(debug)
@$(call sort_bin,$(DATABINFILE))
define sort_bin
awk -f scripts/sort-bin.awk -v to=$(TMPBINFILE) $(1) \
&& mv $(TMPBINFILE) $(1)
endef