forked from AdaCore/RecordFlux
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
234 lines (178 loc) · 6.92 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
232
233
234
VERBOSE ?= @
TEST_PROCS ?= $(shell nproc)
RECORDFLUX_ORIGIN ?= https://github.com/Componolit
PYTHON_STYLE_HEAD = 6440cc638a85a89d486af16eef5541de83e06b54
SHELL := /bin/bash
PYTEST := python3 -m pytest -n$(TEST_PROCS) -vv --timeout=3600
python-packages := bin doc/conf.py examples/apps rflx tests tools stubs setup.py
build-dir := build
# Switch to a specific revision of the git repository.
#
# @param $(1) directory of the git repository
# @param $(2) commit id
define checkout_repo
$(shell test -d $(1) && git -C $(1) fetch && git -C $(1) -c advice.detachedHead=false checkout $(2))
endef
# Get the HEAD revision of the git repository.
#
# @param $(1) directory of the git repository
# @param $(2) default value
repo_head = $(shell test -d $(1) && git -C $(1) rev-parse HEAD || echo $(2))
# Switch to the expected revision of the git repository, if the current HEAD is not the expected one.
#
# @param $(1) directory of the git repository
# @param $(2) expected revision
reinit_repo = $(if $(filter-out $(2),$(call repo_head,$(1),$(2))),$(call checkout_repo,$(1),$(2)),)
# Remove the git repository, if no changes are present.
#
# The function looks for changed and untracked files as well as commits that are not pushed to a
# remote branch. If the repository is unchanged, it will be removed completely.
#
# @param $(1) directory of the git repository
define remove_repo
$(if
$(or
$(shell test -d $(1) && git -C $(1) status --porcelain),
$(shell test -d $(1) && git -C $(1) log --branches --not --remotes --format=oneline)
),
$(info Keeping $(1) due to local changes),
$(shell rm -rf $(1))
)
endef
$(shell $(call reinit_repo,.config/python-style,$(PYTHON_STYLE_HEAD)))
.PHONY: all
all: check test prove
.PHONY: init deinit
init: .config/python-style
$(VERBOSE)$(call checkout_repo,.config/python-style,$(PYTHON_STYLE_HEAD))
$(VERBOSE)ln -sf .config/python-style/pyproject.toml
$(VERBOSE)git update-index --skip-worktree pyproject.toml
deinit:
$(VERBOSE)$(call remove_repo,.config/python-style)
$(VERBOSE)ln -sf .config/pyproject.toml
$(VERBOSE)git update-index --no-skip-worktree pyproject.toml
.config/python-style:
$(VERBOSE)git clone $(RECORDFLUX_ORIGIN)/python-style.git .config/python-style
.PHONY: check check_packages check_dependencies check_black check_isort check_flake8 check_pylint check_mypy check_contracts check_pydocstyle check_doc \
format \
test test_python test_python_unit test_python_integration test_python_property test_python_property_verification test_python_optimized test_python_coverage test_apps test_compilation test_binary_size test_specs test_installation \
prove prove_tests prove_python_tests prove_apps \
install_devel install_devel_edge upgrade_devel install_gnat printenv_gnat \
generate \
doc \
dist \
clean
check: check_packages check_dependencies check_black check_isort check_flake8 check_pylint check_mypy check_contracts check_pydocstyle check_doc
check_packages:
tools/check_packages.py $(python-packages)
check_dependencies:
tools/check_dependencies.py
check_black:
black --check --diff --line-length 100 $(python-packages) ide/gnatstudio
check_isort:
isort --check --diff $(python-packages) ide/gnatstudio
check_flake8:
pflake8 $(python-packages) ide/gnatstudio
check_pylint:
pylint $(python-packages)
check_mypy:
mypy --pretty $(python-packages)
check_contracts:
pyicontract-lint $(python-packages)
check_pydocstyle:
pydocstyle $(python-packages)
check_doc:
tools/check_doc.py
format:
black -l 100 $(python-packages) ide/gnatstudio
isort $(python-packages) ide/gnatstudio
test: test_python_coverage test_python_unit_coverage test_python_property test_apps test_compilation test_binary_size test_specs test_installation
test_python:
$(PYTEST) -m "not hypothesis" tests
test_python_unit:
$(PYTEST) tests/unit
test_python_integration:
$(PYTEST) tests/integration
test_python_property:
$(PYTEST) -m "not verification" tests/property
test_python_property_verification:
$(PYTEST) -m "verification" -s tests/property
test_python_optimized:
PYTHONOPTIMIZE=1 $(PYTEST) -m "not verification and not hypothesis" tests
test_python_coverage:
timeout -k 60 7200 $(PYTEST) --cov=rflx --cov-branch --cov-fail-under=100 --cov-report=term-missing:skip-covered -m "not verification and not hypothesis and not compilation" tests
test_python_unit_coverage:
timeout -k 60 7200 $(PYTEST) --cov=rflx --cov-branch --cov-fail-under=96.11 --cov-report=term-missing:skip-covered -m "not verification and not hypothesis and not compilation" tests/unit
test_apps:
$(MAKE) -C examples/apps/ping test_python
$(MAKE) -C examples/apps/ping test_spark
$(MAKE) -C examples/apps/dhcp_client test
test_compilation:
# Skip test for FSF GNAT to prevent violations of restriction "No_Secondary_Stack" in AUnit units
[[ "${GNAT}" == fsf* ]] || $(MAKE) -C tests/spark build_strict
$(MAKE) -C tests/spark clean
$(MAKE) -C tests/spark test
$(MAKE) -C examples/apps/ping build
$(MAKE) -C examples/apps/dhcp_client build
$(PYTEST) -m "compilation and not verification" tests
$(MAKE) -C tests/spark test NOPREFIX=1
$(MAKE) -C tests/spark clean
$(MAKE) -C tests/spark test_optimized
test_binary_size:
$(MAKE) -C examples/apps/dhcp_client binary_size
test_specs:
cd examples/specs && $(PYTEST) tests/test_specs.py
test_installation:
rm -rf $(build-dir)/venv $(build-dir)/test_installation
mkdir -p $(build-dir)/test_installation
python3 -m venv $(build-dir)/venv
$(build-dir)/venv/bin/pip install .
$(build-dir)/venv/bin/rflx --version
HOME=$(build-dir)/test_installation $(build-dir)/venv/bin/rflx setup_ide
test -f $(build-dir)/test_installation/.gnatstudio/plug-ins/recordflux.py
prove: prove_tests prove_python_tests prove_apps
prove_tests:
$(MAKE) -C tests/spark prove
prove_python_tests:
$(PYTEST) -m "verification and not hypothesis" tests
prove_apps:
$(MAKE) -C examples/apps/ping prove
$(MAKE) -C examples/apps/dhcp_client prove
install_devel:
tools/check_pip_version.py
$(MAKE) -C .config/python-style install_devel
pip3 install -e ".[devel]"
install_git_hooks:
install -m 755 tools/pre-{commit,push} .git/hooks/
upgrade_devel:
tools/upgrade_dependencies.py
install_devel_edge: install_devel
$(MAKE) -C .config/python-style install_devel_edge
install_gnat: FSF_GNAT_VERSION ?= 11.2.4
install_gnat: GPRBUILD_VERSION ?= 22.0.1
install_gnat:
test -d build/alire || ( \
mkdir -p build && \
cd build && \
alr -n init --lib alire && \
cd alire && \
alr toolchain --select --local gnat_native=$(FSF_GNAT_VERSION) gprbuild=$(GPRBUILD_VERSION) && \
alr -n with aunit gnatcoll_iconv gnatcoll_gmp \
)
printenv_gnat:
@test -d build/alire && (\
cd build/alire && \
alr printenv \
) || true
generate:
tools/generate_spark_test_code.py
doc: check_doc
$(MAKE) -C doc html
dist:
python3 setup.py sdist
clean:
rm -rf $(build-dir) .coverage .hypothesis .mypy_cache .pytest_cache
$(MAKE) -C tests/spark clean
$(MAKE) -C examples/apps/ping clean
$(MAKE) -C examples/apps/dhcp_client clean
$(MAKE) -C doc clean