This repository has been archived by the owner on Oct 7, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMakefile
209 lines (166 loc) · 6.11 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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
# Auto-generated by https://github.com/Pouriya-Jahanbakhsh/estuff
CFG_DIR = $(CURDIR)/config
TOOLS_DIR = $(CURDIR)/tools
REBAR = $(TOOLS_DIR)/rebar3
ERL := $(shell command -v erl 2> /dev/null)
RELEASE_DIR = $(CURDIR)/_build/default/rel/graphite_encoderl
VERSION := $(shell erl -noshell -eval 'io:format("~s", [case file:consult("$(CURDIR)/src/graphite_encoderl.app.src") of {ok, [{_, _, Terms}]} -> proplists:get_value(vsn, Terms, "0.0.0"); _ -> "0.0.0" end]),erlang:halt().')
RELEASE_NAME = graphite_encoderl-$(VERSION)
NAME_UPPER := $(shell echo graphite_encoderl | awk '{print toupper($$1)}')
PRE = @
POST =
BUILD_DEBUG = 0
REBAR_DEBUG =
v = 1
ifeq ($(v),0)
POST = > /dev/null
endif
ifeq ($(v),2)
PRE =
endif
ifeq ($(v),3)
PRE =
BUILD_DEBUG = 1
endif
ifeq ($(v),4)
PRE =
BUILD_DEBUG = 1
REBAR_DEBUG = 1
endif
coverage = 0
ifeq ($(coverage),0)
coverage = /dev/null
endif
ifndef ERL
$(error Could not found Erlang/OTP ('erl' command) installed on this system.)
endif
.PHONY: all compile shell docs test dialyzer cover release package package-src package-app package-release clean distclean docker push
all: test docs package
compile:
@ echo Compiling code
$(PRE) \
export $(NAME_UPPER)_BUILD=COMPILE && \
export DEBUG=$(REBAR_DEBUG) && \
export $(NAME_UPPER)_VERSION=$(VERSION) && \
export $(NAME_UPPER)_BUILD_DEBUG=$(BUILD_DEBUG) && \
$(REBAR) compile \
$(POST)
$(PRE) cp -r $(CURDIR)/_build/default/lib/graphite_encoderl/ebin $(CURDIR)
shell:
@ echo Compiling user_default module
$(PRE) erlc -o $(TOOLS_DIR) $(TOOLS_DIR)/user_default.erl $(POST)
$(PRE) \
export $(NAME_UPPER)_BUILD=SHELL && \
export DEBUG=$(REBAR_DEBUG) && \
export $(NAME_UPPER)_VERSION=$(VERSION) && \
export $(NAME_UPPER)_BUILD_DEBUG=$(BUILD_DEBUG) && \
$(REBAR) compile \
$(POST) && \
erl -pa `ls -d _build/default/lib/*/ebin` \
-pz $(TOOLS_DIR) \
-config $(CFG_DIR)/sys.config \
-args_file $(CFG_DIR)/vm.args \
-eval "begin application:load('graphite_encoderl'), catch code:load_file('graphite_encoderl') end" \
+B
docs:
@ echo Building documentation
$(PRE) \
export $(NAME_UPPER)_BUILD=DOC && \
export DEBUG=$(REBAR_DEBUG) && \
export $(NAME_UPPER)_VERSION=$(VERSION) && \
export $(NAME_UPPER)_BUILD_DEBUG=$(BUILD_DEBUG) && \
$(REBAR) edoc \
$(POST)
test: cover dialyzer
dialyzer: compile
@ echo Running dialyzer
$(PRE) \
export $(NAME_UPPER)_BUILD=DIALYZER && \
export DEBUG=$(REBAR_DEBUG) && \
export $(NAME_UPPER)_VERSION=$(VERSION) && \
export $(NAME_UPPER)_BUILD_DEBUG=$(BUILD_DEBUG) && \
$(REBAR) dialyzer \
$(POST)
cover: compile
@ echo Running tests
$(PRE) \
export $(NAME_UPPER)_BUILD=TEST && \
export DEBUG=$(REBAR_DEBUG) && \
export $(NAME_UPPER)_VERSION=$(VERSION) && \
export $(NAME_UPPER)_BUILD_DEBUG=$(BUILD_DEBUG) && \
$(REBAR) do ct, cover \
$(POST)
@ echo Coverage summary:
$(PRE) \
awk -f $(TOOLS_DIR)/coverage_summary.awk \
-v indent="\t" \
-v colorize=1 \
$(CURDIR)/_build/test/cover/index.html \
|| true
$(PRE) \
awk -f $(TOOLS_DIR)/coverage_summary.awk \
$(CURDIR)/_build/test/cover/index.html \
> $(coverage) || true
release: compile
@ echo Building release $(RELEASE_NAME)
$(PRE) \
export $(NAME_UPPER)_BUILD=RELEASE && \
export DEBUG=$(REBAR_DEBUG) && \
export $(NAME_UPPER)_VERSION=$(VERSION) && \
export $(NAME_UPPER)_BUILD_DEBUG=$(BUILD_DEBUG) && \
$(REBAR) release \
$(POST)
$(PRE) mkdir -p $(CURDIR)/$(RELEASE_NAME) $(POST)
$(PRE) cp -r $(RELEASE_DIR)/* $(CURDIR)/$(RELEASE_NAME) $(POST)
package-release: release
@ echo Packaging release to $(RELEASE_NAME)-release.tar.gz
$(PRE) \
rm -rf .tar && \
find $(RELEASE_NAME)/ -type f > .tar && \
tar -zcvf $(RELEASE_NAME)-release.tar.gz -T .tar $(POST) && \
rm -rf .tar $(POST)
package-src: compile
@ echo Packaging source to $(RELEASE_NAME)-src.tar.gz
$(PRE) \
rm -rf .tar && \
find src/ -type f > .tar && \
find include/ -type f >> .tar || true && \
find config/ -type f >> .tar && \
find tools/ -type f >> .tar && \
find test/ -type f >> .tar && \
find priv/ -type f >> .tar || true && \
echo Dockerfile >> .tar || true && \
echo LICENSE >> .tar && \
echo Makefile >> .tar && \
echo README.md >> .tar && \
echo rebar.config >> .tar || true && \
echo rebar.config.script >> .tar && \
tar -zcvf $(RELEASE_NAME)-src.tar.gz -T .tar $(POST) && \
rm -rf .tar $(POST)
package-app: compile
@ echo Packaging application to $(RELEASE_NAME)-app.tar.gz
$(PRE) \
rm -rf .tar && \
find src/ -type f > .tar && \
find include/ -type f >> .tar || true && \
find ebin/ -type f >> .tar && \
find priv/ -type f >> .tar || true && \
tar -zcvf $(RELEASE_NAME)-app.tar.gz -T .tar $(POST) && \
rm -rf .tar $(POST)
package: package-src package-app package-release
clean:
@ echo Cleaning out
$(PRE) \
export $(NAME_UPPER)_BUILD=CLEAN && \
export DEBUG=$(REBAR_DEBUG) && \
export $(NAME_UPPER)_VERSION=$(VERSION) && \
export $(NAME_UPPER)_BUILD_DEBUG=$(BUILD_DEBUG) && \
$(REBAR) clean $(POST)
$(PRE) rm -rf $(CURDIR)/ebin $(POST)
distclean: clean
$(PRE) rm -rf _build rebar.lock $(RELEASE_NAME) $(RELEASE_NAME)-*.tar.gz ebin tools/user_default.beam *.crashdump $(POST)
docker:
$(PRE) docker build -t graphite_encoderl ./ $(POST)
push: cover
@ echo Pushing to master branch
$(PRE) git push origin master