forked from 2600hz/kazoo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
231 lines (175 loc) · 7.71 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
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
ROOT = $(shell readlink -f .)
RELX = $(ROOT)/deps/relx
ELVIS = $(ROOT)/deps/elvis
FMT = $(ROOT)/make/erlang-formatter-master/fmt.sh
KAZOODIRS = core/Makefile applications/Makefile
.PHONY: $(KAZOODIRS) deps core apps xref xref_release dialyze dialyze-it dialyze-apps dialyze-core dialyze-kazoo clean clean-test clean-release build-release build-ci-release tar-release release read-release-cookie elvis install ci diff fmt bump-copyright apis validate-swagger coverage-report fs-headers docs
all: compile rel/dev-vm.args
compile: ACTION = all
compile: deps $(KAZOODIRS)
$(KAZOODIRS):
$(MAKE) -C $(@D) $(ACTION)
clean: ACTION = clean
clean: $(KAZOODIRS)
$(if $(wildcard *crash.dump), rm *crash.dump)
$(if $(wildcard scripts/log/*), rm -rf scripts/log/*)
$(if $(wildcard rel/dev-vm.args), rm rel/dev-vm.args)
$(if $(wildcard $(FMT)), rm -r $(dir $(FMT)))
clean-test: ACTION = clean-test
clean-test: $(KAZOODIRS)
clean-kazoo: ACTION = clean
clean-kazoo: $(KAZOODIRS)
compile-test: ACTION = compile-test
compile-test: ERLC_OPTS += +nowarn_missing_spec
compile-test: deps $(KAZOODIRS)
eunit: ACTION = eunit
eunit: $(KAZOODIRS)
proper: ACTION = eunit
proper: ERLC_OPTS += -DPROPER
proper: $(KAZOODIRS)
test: ACTION = test
test: ERLC_OPTS += -DPROPER
test: ERLC_OPTS += +nowarn_missing_spec
test: $(KAZOODIRS)
coverage-report:
$(ROOT)/scripts/cover.escript
check: ERLC_OPTS += -DPROPER
check: compile-test eunit clean-kazoo kazoo
clean-deps:
$(if $(wildcard deps/), $(MAKE) -C deps/ clean)
$(if $(wildcard deps/), rm -r deps/)
.erlang.mk:
wget 'https://raw.githubusercontent.com/ninenines/erlang.mk/2016.01.12/erlang.mk' -O $(ROOT)/erlang.mk
deps: deps/Makefile
$(MAKE) -C deps/ all
deps/Makefile: .erlang.mk
mkdir -p deps
$(MAKE) -f erlang.mk deps
cp $(ROOT)/make/Makefile.deps deps/Makefile
core:
$(MAKE) -C core/ all
apps:
$(MAKE) -C applications/ all
kazoo: core apps
$(RELX):
wget 'https://github.com/erlware/relx/releases/download/v3.19.0/relx' -O $@
chmod +x $@
clean-release:
$(if $(wildcard _rel/), rm -r _rel/)
$(if $(wildcard rel/relx.config rel/vm.args rel/dev-vm.args), \
rm $(wildcard rel/relx.config rel/vm.args rel/dev-vm.args) )
build-release: $(RELX) clean-release rel/relx.config rel/vm.args
$(RELX) --config rel/relx.config -V 2 release --relname 'kazoo'
build-dev-release: $(RELX) clean-release rel/relx.config-dev rel/vm.args
$(RELX) --dev-mode true --config rel/relx.config -V 2 release --relname 'kazoo'
build-ci-release: $(RELX) clean-release rel/relx.config rel/vm.args
$(RELX) --config rel/relx.config -V 2 release --relname 'kazoo' --sys_config rel/ci-sys.config
tar-release: $(RELX) rel/relx.config rel/vm.args
$(RELX) --config rel/relx.config -V 2 release tar --relname 'kazoo'
rel/relx.config: rel/relx.config.src
$(ROOT)/scripts/src2any.escript $<
rel/relx.config-dev: export KAZOO_DEV='true'
rel/relx.config-dev: rel/relx.config.src
$(ROOT)/scripts/src2any.escript $<
rel/dev-vm.args: rel/args # Used by scripts/dev-start-*.sh
cp $^ $@
rel/vm.args: rel/args rel/dev-vm.args
( cat $<; echo '$${KZname}' ) > $@
## More ACTs at //github.com/erlware/relx/priv/templates/extended_bin
release: ACT ?= console # start | attach | stop | console | foreground
release: REL ?= kazoo_apps # kazoo_apps | ecallmgr | …
ifneq ($(findstring kazoo_apps,$(REL)),kazoo_apps)
release: export KAZOO_APPS = 'ecallmgr'
endif
release:
@RELX_REPLACE_OS_VARS=true KZname='-name $(REL)' _rel/kazoo/bin/kazoo $(ACT) "$$@"
install: compile build-release
cp -a _rel/kazoo /opt
read-release-cookie: REL ?= kazoo_apps
read-release-cookie:
@RELX_REPLACE_OS_VARS=true KZname='-name $(REL)' _rel/kazoo/bin/kazoo escript lib/kazoo_config-*/priv/read-cookie.escript "$$@"
DIALYZER ?= dialyzer
PLT ?= .kazoo.plt
OTP_APPS ?= erts kernel stdlib crypto public_key ssl asn1 inets xmerl
$(PLT): DEPS_SRCS ?= $(shell find $(ROOT)/deps -name src )
# $(PLT): CORE_EBINS ?= $(shell find $(ROOT)/core -name ebin)
$(PLT):
@$(DIALYZER) --no_native --build_plt --output_plt $(PLT) \
--apps $(OTP_APPS) \
-r $(DEPS_SRCS)
@for ebin in $(CORE_EBINS); do \
$(DIALYZER) --no_native --add_to_plt --plt $(PLT) --output_plt $(PLT) -r $$ebin; \
done
build-plt: $(PLT)
dialyze-kazoo: TO_DIALYZE = $(shell find $(ROOT)/applications $(ROOT)/core -name ebin)
dialyze-kazoo: dialyze
dialyze-apps: TO_DIALYZE = $(shell find $(ROOT)/applications -name ebin)
dialyze-apps: dialyze
dialyze-core: TO_DIALYZE = $(shell find $(ROOT)/core -name ebin)
dialyze-core: dialyze
dialyze: TO_DIALYZE ?= $(shell find $(ROOT)/applications -name ebin)
dialyze: dialyze-it
dialyze-it: $(PLT)
@if [ -n "$(TO_DIALYZE)" ]; then $(ROOT)/scripts/check-dialyzer.escript $(ROOT)/.kazoo.plt $(TO_DIALYZE); fi;
xref: TO_XREF ?= $(shell find $(ROOT)/applications $(ROOT)/core $(ROOT)/deps -name ebin)
xref:
@$(ROOT)/scripts/check-xref.escript $(TO_XREF)
xref_release: TO_XREF = $(shell find $(ROOT)/_rel/kazoo/lib -name ebin)
xref_release:
@$(ROOT)/scripts/check-xref.escript $(TO_XREF)
sup_completion: sup_completion_file = $(ROOT)/sup.bash
sup_completion: kazoo
@$(if $(wildcard $(sup_completion_file)), rm $(sup_completion_file))
@$(ROOT)/core/sup/priv/build-autocomplete.escript $(sup_completion_file) applications/ core/
@echo SUP Bash completion file written at $(sup_completion_file)
$(ELVIS):
wget 'https://github.com/inaka/elvis/releases/download/0.2.12/elvis' -O $@
chmod +x $@
elvis: $(ELVIS)
$(ELVIS) --config make/elvis.config rock
ci: clean compile xref build-plt diff sup_completion build-ci-release compile-test eunit elvis
diff: export TO_DIALYZE = $(shell git diff --name-only master... -- $(ROOT)/applications/ $(ROOT)/core/)
diff: dialyze-it
bump-copyright:
@$(ROOT)/scripts/bump-copyright-year.sh $(shell find applications core -iname '*.erl' -or -iname '*.hrl')
$(FMT):
wget -qO - 'https://codeload.github.com/fenollp/erlang-formatter/tar.gz/master' | tar xz -C $(ROOT)/make/
fmt: TO_FMT ?= $(shell find applications core -iname '*.erl' -or -iname '*.hrl' -or -iname '*.app.src')
fmt: $(FMT)
@$(FMT) $(TO_FMT)
code_checks:
@ERL_LIBS=deps/:core/:applications/ $(ROOT)/scripts/no_raw_json.escript
@$(ROOT)/scripts/kz_diaspora.bash
apis:
@ERL_LIBS=deps/:core/:applications/ $(ROOT)/scripts/generate-schemas.escript
@$(ROOT)/scripts/format-json.sh applications/crossbar/priv/couchdb/schemas/*.json
@ERL_LIBS=deps/:core/:applications/ $(ROOT)/scripts/generate-api-endpoints.escript
@$(ROOT)/scripts/generate-doc-schemas.sh applications/crossbar/doc/ref/*.md
@$(ROOT)/scripts/format-json.sh applications/crossbar/priv/api/swagger.json
@$(ROOT)/scripts/format-json.sh applications/crossbar/priv/api/*.json
@ERL_LIBS=deps/:core/:applications/ $(ROOT)/scripts/generate-fs-headers-hrl.escript
DOCS_ROOT=$(ROOT)/doc/mkdocs
docs: docs-validate docs-report docs-setup docs-build
docs-validate:
@$(ROOT)/scripts/check-scripts-readme.bash
@$(ROOT)/scripts/empty_schema_descriptions.bash
docs-report:
@$(ROOT)/scripts/reconcile_docs_to_index.bash
docs-validate:
docs-setup:
@$(ROOT)/scripts/validate_mkdocs.py
@$(ROOT)/scripts/setup_docs.bash
@cp $(DOCS_ROOT)/mkdocs.yml $(DOCS_ROOT)/mkdocs.local.yml
@mkdir -p $(DOCS_ROOT)/theme
@if [ -f $(DOCS_ROOT)/theme/global.yml ]; then cat $(DOCS_ROOT)/theme/global.yml >> $(DOCS_ROOT)/mkdocs.local.yml; fi
docs-build:
@echo "\ntheme: null\ntheme_dir: '$(DOCS_ROOT)/theme'\ndocs_dir: '$(DOCS_ROOT)/docs'\n" >> $(DOCS_ROOT)/mkdocs.local.yml
@mkdocs build -f $(DOCS_ROOT)/mkdocs.local.yml --clean -q --site-dir $(DOCS_ROOT)/site
docs-clean:
@rm -rf $(DOCS_ROOT)/site $(DOCS_ROOT)/docs $(DOCS_ROOT)/mkdocs.local.yml
docs-serve: docs-build
@mkdocs serve --dev-addr=0.0.0.0:9876 -f $(DOCS_ROOT)/mkdocs.local.yml
fs-headers:
@ERL_LIBS=deps/:core/:applications/ $(ROOT)/scripts/generate-fs-headers-hrl.escript
validate-swagger:
$(ROOT)/scripts/validate-swagger.sh