-
Notifications
You must be signed in to change notification settings - Fork 64
/
Makefile
165 lines (132 loc) · 4.7 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
# See LICENSE for licensing information.
CHMOD := $(shell command -v chmod 2>/dev/null)
CURL := $(shell command -v curl 2>/dev/null)
OTP_RELEASE := $(shell erl -eval 'io:format("~s", [erlang:system_info(otp_release)]), halt().' -noshell)
GIT_DESCRIBE := $(shell git describe --tags --first-parent --always --dirty)
REBAR3 := ./rebar3.OTP$(OTP_RELEASE)
SRCS := $(wildcard src/* include/* rebar.config)
.PHONY: all
all: ebin/jesse.app bin/jesse
# Clean
.PHONY: clean
clean: $(REBAR3)
$(REBAR3) clean
rm $(REBAR3)
.PHONY: distclean
distclean: clean
$(RM) -r _build
$(RM) doc/*.html
$(RM) doc/edoc-info
$(RM) doc/erlang.png
$(RM) doc/stylesheet.css
$(RM) -r logs
.PHONY: clean-tests
clean-tests:
@ rm -rf _build/test/lib
# Docs
.PHONY: docs
docs: $(REBAR3)
$(REBAR3) edoc
# Compile
bin/jesse: escript
mkdir -p bin
cp -a _build/default/bin/jesse bin/jesse
ebin/jesse.app: compile
.PHONY: escript
escript: $(REBAR3) ebin/jesse.app
$(REBAR3) escriptize
./_build/default/bin/jesse --help
.PHONY: compile
compile: $(REBAR3) $(SRCS)
$(REBAR3) compile
# Tests
test/JSON-Schema-Test-Suite/tests:
git submodule sync --recursive
git submodule update --init --recursive
.PHONY: test
# Would be nice to include elvis to test, but it fails on OTP-18
# test: elvis
test: eunit ct xref dialyzer proper cover
.PHONY: elvis
elvis: $(REBAR3)
$(REBAR3) lint
.PHONY: check
check: elvis
.PHONY: eunit
eunit: $(REBAR3) clean-tests
$(REBAR3) eunit
.PHONY: ct
ct: $(REBAR3) test/JSON-Schema-Test-Suite/tests clean-tests
TEST_DIR=_build/default/test/lib/jesse/test $(REBAR3) ct
.PHONY: xref
xref: $(REBAR3)
$(REBAR3) xref
.PHONY: dialyzer
dialyzer: $(REBAR3)
$(REBAR3) dialyzer
.PHONY: cover
cover: $(REBAR3) clean-tests
$(REBAR3) cover -v
.PHONY: proper
proper: $(REBAR3)
$(REBAR3) proper
.PHONY: publish
publish: $(REBAR3) docs
$(REBAR3) hex publish -r hexpm --yes
# TODO: there must be a better way
.PHONY: symlinks
symlinks: test/JSON-Schema-Test-Suite/tests
cd test/jesse_tests_draft3_SUITE_data && \
ln -sf ../../test/JSON-Schema-Test-Suite/tests/draft3 standard && \
ln -sf ../../test/JSON-Schema-Test-Suite/remotes remotes
cd test/jesse_tests_draft4_SUITE_data && \
ln -sf ../../test/JSON-Schema-Test-Suite/tests/draft4 standard && \
ln -sf ../../test/JSON-Schema-Test-Suite/remotes remotes
cd test/jesse_tests_draft6_SUITE_data && \
ln -sf ../../test/JSON-Schema-Test-Suite/tests/draft6 standard && \
ln -sf ../../test/JSON-Schema-Test-Suite/remotes remotes
# https://github.com/erlang/rebar3/issues/2903
./rebar3.OTP18:
$(CURL) -qfsSL -o $@ https://github.com/erlang/rebar3/releases/download/3.15.3/rebar3 && $(CHMOD) +x $@
./rebar3.OTP19:
$(CURL) -qfsSL -o $@ https://github.com/erlang/rebar3/releases/download/3.15.2/rebar3 && $(CHMOD) +x $@
./rebar3.OTP20:
$(CURL) -qfsSL -o $@ https://github.com/erlang/rebar3/releases/download/3.15.2/rebar3 && $(CHMOD) +x $@
./rebar3.OTP21:
$(CURL) -qfsSL -o $@ https://github.com/erlang/rebar3/releases/download/3.15.2/rebar3 && $(CHMOD) +x $@
./rebar3.OTP22:
$(CURL) -qfsSL -o $@ https://github.com/erlang/rebar3/releases/download/3.18.0/rebar3 && $(CHMOD) +x $@
./rebar3.OTP23:
$(CURL) -qfsSL -o $@ https://github.com/erlang/rebar3/releases/download/3.19.0/rebar3 && $(CHMOD) +x $@
./rebar3.OTP24:
$(CURL) -qfsSL -o $@ https://github.com/erlang/rebar3/releases/download/3.20.0/rebar3 && $(CHMOD) +x $@
./rebar3.OTP25:
$(CURL) -qfsSL -o $@ https://github.com/erlang/rebar3/releases/download/3.21.0/rebar3 && $(CHMOD) +x $@
./rebar3.OTP26:
$(CURL) -qfsSL -o $@ https://github.com/erlang/rebar3/releases/download/3.23.0/rebar3 && $(CHMOD) +x $@
./rebar3.OTP27:
$(CURL) -qfsSL -o $@ https://github.com/erlang/rebar3/releases/download/3.23.0/rebar3 && $(CHMOD) +x $@
.PHONY: docker
docker:
if git tag | grep -q -Fx "$(GIT_DESCRIBE)"; then \
$(MAKE) docker-force; \
else \
echo "Current version $(GIT_DESCRIBE) isn't in 'git tag'."; \
echo "Run 'make docker-force' if you really want to build and push a $(GIT_DESCRIBE) version."; \
exit 1; \
fi
.PHONY: docker-force
docker-force:
# docker context create aws-docker-amd64 --docker host=ssh://ec2-13-51-198-153.eu-north-1.compute.amazonaws.com
# docker context create aws-docker-arm64 --docker host=ssh://ec2-13-48-46-86.eu-north-1.compute.amazonaws.com
# docker buildx create --name aws-multiarch-builder aws-docker-amd64
# docker buildx create --name aws-multiarch-builder --append aws-docker-arm64
# docker buildx use aws-multiarch-builder
docker buildx build . \
--push \
--platform linux/amd64,linux/arm64 \
--tag ysoftwareab/jesse:$(GIT_DESCRIBE) \
--tag ysoftwareab/jesse:latest \
--build-arg FROM=erlang:slim \
--build-arg LABEL_VCS_REF=$$(git rev-parse HEAD) \
--build-arg LABEL_BUILD_DATE=$$(date -u +"%Y-%m-%dT%H:%M:%SZ")