forked from pksunkara/alpaca
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
65 lines (47 loc) · 1.87 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
VERSION = 0.2.0
TEMPLATES_DIR = templates
TEMPLATES_FILE = $(TEMPLATES_DIR)/templates.go
GO_BINDATA = go-bindata
GO_FMT = gofmt -w
GO_XC = goxc
GOXC_FILE = .goxc.local.json
func_name_from_file = $(subst .,zz,$(subst /,z,$(1:$(TEMPLATES_DIR)/%=%)))
file_name_from_func = $(addprefix $(TEMPLATES_DIR)/,$(subst z,/,$(subst zz,.,$(1))))
remove_tmpl_dir = $(1:$(TEMPLATES_DIR)/%=%)
SOURCES = $(filter-out %.go,$(shell find $(TEMPLATES_DIR)/* -type f))
OBJECTS = $(addsuffix .go, $(foreach src, $(SOURCES), $(call func_name_from_file,$(src))))
DEPS = \
github.com/jteeuwen/go-bindata \
github.com/robertkrimen/terst \
github.com/jessevdk/go-flags \
bitbucket.org/pkg/inflect
all:deps templates
templates:clean ${TEMPLATES_FILE} ${OBJECTS}
$(shell echo '}' >> $(TEMPLATES_FILE))
$(GO_FMT) $(TEMPLATES_DIR)/*.go
%.go:
${GO_BINDATA} -pkg="templates" -out="$(TEMPLATES_DIR)/$@" -func="$(*)" $(call file_name_from_func,$*)
$(shell echo '\t"$(call remove_tmpl_dir,$(call file_name_from_func,$*))" : $(*:($TEMPLATES_DIR)/%=%),' >> $(TEMPLATES_FILE))
${TEMPLATES_FILE}:
$(shell echo "package templates\nvar Data = map[string] func() []byte{" > $(TEMPLATES_FILE))
compile:templates goxc
goxc:
$(shell echo '{\n "ArtifactsDest": "build",\n "ConfigVersion": "0.9",' > $(GOXC_FILE))
$(shell echo ' "PackageVersion": "$(VERSION)",\n "TaskSettings": {' >> $(GOXC_FILE))
$(shell echo ' "bintray": {\n "apikey": "",\n "package": "alpaca",' >> $(GOXC_FILE))
$(shell echo ' "repository": "utils",\n "subject": "pksunkara"' >> $(GOXC_FILE))
$(shell echo ' }\n }\n}' >> $(GOXC_FILE))
$(GO_XC)
bintray:
$(GO_XC) bintray
test:
go test github.com/pksunkara/alpaca/alpaca
test-cover:
go test -coverprofile=coverage.out github.com/pksunkara/alpaca/alpaca
go tool cover -html=coverage.out
install:
go install github.com/pksunkara/alpaca
deps:
go get -u $(DEPS)
clean:
rm -f ${TEMPLATES_DIR}/*.go