forked from obra/kicad-automation-scripts
-
Notifications
You must be signed in to change notification settings - Fork 19
/
Makefile
292 lines (254 loc) · 13.4 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
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
#!/usr/bin/make
PY_COV=python3-coverage
PYTEST=pytest-3
REFDIR=tests/reference/6/
GOOD=tests/kicad6/good-project/good-project.kicad_pcb
REFILL=tests/kicad6/zone-refill/zone-refill.kicad_pcb
GOOD_SCH=tests/kicad6/good-project/good-project.kicad_sch
CWD := $(abspath $(patsubst %/,%,$(dir $(abspath $(lastword $(MAKEFILE_LIST))))))
USER_ID=$(shell id -u)
GROUP_ID=$(shell id -g)
deb:
fakeroot dpkg-buildpackage -uc -b
deb_sig:
fakeroot dpkg-buildpackage -b
deb_clean:
fakeroot debian/rules clean
-@rm -rf kiauto.egg-info
lint:
# flake8 --filename is broken
ln -sf src/eeschema_do eeschema_do.py
ln -sf src/pcbnew_do pcbnew_do.py
# stop the build if there are Python syntax errors or undefined names
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
flake8 . --count --statistics
rm eeschema_do.py pcbnew_do.py
test_server_ki5:
python3-coverage erase
pytest-3 --test_dir output
python3-coverage report
test_server_ki6:
python3-coverage erase
pytest-3 --test_dir output
python3-coverage report
test_server_ki7:
python3-coverage erase
pytest-3 --test_dir output
python3-coverage report
test_server_ki8:
python3-coverage erase
pytest-3 --test_dir output
python3-coverage report
test_server_nightly:
python3-coverage erase
KIAUS_USE_NIGHTLY=7.0 pytest-3 --test_dir output
python3-coverage report
test: lint
rm -rf output
$(PY_COV) erase
# KIAUTO_INTERPOSER_DISABLE=1 KIAUS_USE_NIGHTLY=7.0 $(PYTEST) --test_dir output
$(PYTEST) --test_dir output
$(PY_COV) report
$(PY_COV) html
x-www-browser htmlcov/index.html
-@rm -rf tests/kicad6/kicad4-project/kicad4-project-rescue.lib tests/kicad6/kicad4-project/kicad4-project.kicad_prl \
tests/kicad6/kicad4-project/kicad4-project.kicad_pro tests/kicad6/kicad4-project/kicad4-project.kicad_sch \
tests/kicad6/kicad4-project/kicad4-project.pro-bak tests/kicad6/kicad4-project/rescue-backup/ \
tests/kicad6/kicad4-project/sym-lib-table
test_docker_local:
rm -rf output
$(PY_COV) erase
# Run in the same directory to make the __pycache__ valid
# Also change the owner of the files to the current user (we run as root like in GitHub)
docker run --rm -v $(CWD):$(CWD) --workdir="$(CWD)" setsoft/kicad_auto_test:latest \
/bin/bash -c "flake8 . --count --statistics ; $(PYTEST) --test_dir output ; chown -R $(USER_ID):$(GROUP_ID) output/ tests/kicad5/ .coverage"
$(PY_COV) report
$(PY_COV) html
x-www-browser htmlcov/index.html
t1k5: test_docker_local_1
t1k5ni: test_docker_local_1_ni
test_docker_local_1:
rm -rf output
#$(PY_COV) erase
# Run in the same directory to make the __pycache__ valid
# Also change the owner of the files to the current user (we run as root like in GitHub)
# KIAUTO_INTERPOSER_DISABLE=1
docker run --rm -v $(CWD):$(CWD) --workdir="$(CWD)" ghcr.io/inti-cmnb/kicad_auto_test:ki5 \
/bin/bash -c "$(PYTEST) --log-cli-level debug -k '$(SINGLE_TEST)' --test_dir output ; chown -R $(USER_ID):$(GROUP_ID) output/ tests/kicad5/ .coverage"
#$(PY_COV) report
#$(PY_COV) html
#rm .coverage
test_docker_local_1_ni:
rm -rf output
docker run --rm -v $(CWD):$(CWD) --workdir="$(CWD)" ghcr.io/inti-cmnb/kicad_auto_test:ki5 \
/bin/bash -c "export KIAUTO_INTERPOSER_DISABLE=1; $(PYTEST) --log-cli-level debug -k '$(SINGLE_TEST)' --test_dir output ; chown -R $(USER_ID):$(GROUP_ID) output/ tests/kicad5/ .coverage"
test_docker_local_k6:
rm -rf output
$(PY_COV) erase
# Run in the same directory to make the __pycache__ valid
# Also change the owner of the files to the current user (we run as root like in GitHub)
docker run --rm -v $(CWD):$(CWD) --workdir="$(CWD)" ghcr.io/inti-cmnb/kicad_auto_test:ki6 \
/bin/bash -c "flake8 . --count --statistics ; $(PYTEST) --test_dir output ; chown -R $(USER_ID):$(GROUP_ID) output/ tests/kicad6/ .coverage"
$(PY_COV) report
$(PY_COV) html
x-www-browser htmlcov/index.html
test_docker_local_k6_1:
rm -rf output
$(PY_COV) erase
# Run in the same directory to make the __pycache__ valid
# Also change the owner of the files to the current user (we run as root like in GitHub)
docker run --rm -v $(CWD):$(CWD) --workdir="$(CWD)" ghcr.io/inti-cmnb/kicad_auto_test:ki6 \
/bin/bash -c "flake8 . --count --statistics ; $(PYTEST) --log-cli-level debug -k '$(SINGLE_TEST)' --test_dir output ; chown -R $(USER_ID):$(GROUP_ID) output/ tests/kicad6/ .coverage"
$(PY_COV) report
$(PY_COV) html
rm .coverage
test_docker_local_k6_1_ni:
rm -rf output
$(PY_COV) erase
# Run in the same directory to make the __pycache__ valid
# Also change the owner of the files to the current user (we run as root like in GitHub)
docker run --rm -v $(CWD):$(CWD) --workdir="$(CWD)" ghcr.io/inti-cmnb/kicad_auto_test:ki6 \
/bin/bash -c "export KIAUTO_INTERPOSER_DISABLE=1; $(PYTEST) --log-cli-level debug -k '$(SINGLE_TEST)' --test_dir output ; chown -R $(USER_ID):$(GROUP_ID) output/ tests/kicad6/ .coverage"
$(PY_COV) report
$(PY_COV) html
rm .coverage
t1k6: test_docker_local_k6_1
t1k6ni: test_docker_local_k6_1_ni
test_docker_local_k7:
rm -rf output
$(PY_COV) erase
docker run --rm -v $(CWD):$(CWD) --workdir="$(CWD)" ghcr.io/inti-cmnb/kicad_auto_test:ki7 \
/bin/bash -c "flake8 . --count --statistics ; $(PYTEST) --test_dir output ; chown -R $(USER_ID):$(GROUP_ID) output/ tests/kicad6/ .coverage"
$(PY_COV) report
$(PY_COV) html
rm .coverage
test_docker_local_k8:
rm -rf output
$(PY_COV) erase
docker run --rm -v $(CWD):$(CWD) --workdir="$(CWD)" ghcr.io/inti-cmnb/kicad_auto_test:ki8 \
/bin/bash -c "flake8 . --count --statistics ; $(PYTEST) --test_dir output ; chown -R $(USER_ID):$(GROUP_ID) output/ tests/kicad*/ .coverage.*"
$(PY_COV) report
$(PY_COV) html
rm .coverage.*
test_docker_local_k7_1:
rm -rf output
$(PY_COV) erase
# Run in the same directory to make the __pycache__ valid
# Also change the owner of the files to the current user (we run as root like in GitHub)
docker run --rm -v $(CWD):$(CWD) --workdir="$(CWD)" ghcr.io/inti-cmnb/kicad_auto_test:ki7 \
/bin/bash -c "flake8 . --count --statistics ; $(PYTEST) --log-cli-level debug -k '$(SINGLE_TEST)' --test_dir output ; chown -R $(USER_ID):$(GROUP_ID) output/ tests/kicad7/ .coverage"
$(PY_COV) report
$(PY_COV) html
rm .coverage
#t1k7: test_docker_local_k7_1
test_docker_local_k8_1:
rm -rf output
docker run --rm -v $(CWD):$(CWD) --workdir="$(CWD)" ghcr.io/inti-cmnb/kicad_auto_test:ki8 \
/bin/bash -c "$(PYTEST) --log-cli-level debug -k '$(SINGLE_TEST)' --test_dir output ; chown -R $(USER_ID):$(GROUP_ID) output/ tests/kicad8/ .coverage.*"
rm .coverage.*
t1k8: test_docker_local_k8_1
test_docker_local_k8_1_ni:
rm -rf output
docker run --rm -v $(CWD):$(CWD) --workdir="$(CWD)" ghcr.io/inti-cmnb/kicad_auto_test:ki8 \
/bin/bash -c "export KIAUTO_INTERPOSER_DISABLE=1; $(PYTEST) --log-cli-level debug -k '$(SINGLE_TEST)' --test_dir output ; chown -R $(USER_ID):$(GROUP_ID) output/ tests/kicad8/ .coverage.*"
rm .coverage.*
t1k8ni: test_docker_local_k8_1_ni
test_docker_local_ng:
rm -rf output
$(PY_COV) erase
# Run in the same directory to make the __pycache__ valid
# Also change the owner of the files to the current user (we run as root like in GitHub)
# docker run --rm -v $(CWD):$(CWD) --workdir="$(CWD)" setsoft/kicad_auto_test:nightly \
# /bin/bash -c "flake8 . --count --statistics ; KIAUS_USE_NIGHTLY=6.0 $(PYTEST) --log-cli-level debug -k '$(SINGLE_TEST)' --test_dir output ; chown -R $(USER_ID):$(GROUP_ID) output/ tests/ .coverage"
docker run --rm -v $(CWD):$(CWD) --workdir="$(CWD)" setsoft/kicad_auto_test:nightly \
/bin/bash -c "flake8 . --count --statistics ; KIAUS_USE_NIGHTLY=7.0 $(PYTEST) --log-cli-level debug --test_dir output ; chown -R $(USER_ID):$(GROUP_ID) output/ tests/ .coverage"
$(PY_COV) report
$(PY_COV) html
x-www-browser htmlcov/index.html
-@rm -rf tests/kicad6/kicad4-project/kicad4-project-rescue.lib tests/kicad6/kicad4-project/kicad4-project.kicad_prl \
tests/kicad6/kicad4-project/kicad4-project.kicad_pro tests/kicad6/kicad4-project/kicad4-project.kicad_sch \
tests/kicad6/kicad4-project/kicad4-project.pro-bak tests/kicad6/kicad4-project/rescue-backup/ \
tests/kicad6/kicad4-project/sym-lib-table
docker_shell:
docker run -it --rm -v $(CWD):$(CWD) --workdir="$(CWD)" \
-v /tmp/.X11-unix:/tmp/.X11-unix -e DISPLAY=$(DISPLAY) \
--user $(USER_ID):$(GROUP_ID) \
--volume="/etc/group:/etc/group:ro" \
--volume="/etc/passwd:/etc/passwd:ro" \
--volume="/etc/shadow:/etc/shadow:ro" \
--volume="/home/$(USER):/home/$(USER):rw" \
setsoft/kicad_auto_test:latest /bin/bash
docker_shell_ng:
docker run -it --rm -v $(CWD):$(CWD) --workdir="$(CWD)" \
-v /tmp/.X11-unix:/tmp/.X11-unix -e DISPLAY=$(DISPLAY) \
--user $(USER_ID):$(GROUP_ID) \
--volume="/etc/group:/etc/group:ro" \
--volume="/etc/passwd:/etc/passwd:ro" \
--volume="/etc/shadow:/etc/shadow:ro" \
--volume="/home/$(USER):/home/$(USER):rw" \
setsoft/kicad_auto_test:nightly /bin/bash
docker_deb_shell:
docker run -it --rm -v $(CWD):$(CWD) --workdir="$(CWD)" \
-v /tmp/.X11-unix:/tmp/.X11-unix -e DISPLAY=$(DISPLAY) \
--user $(USER_ID):$(GROUP_ID) \
--volume="/etc/group:/etc/group:ro" \
--volume="/etc/passwd:/etc/passwd:ro" \
--volume="/etc/shadow:/etc/shadow:ro" \
--volume="/home/$(USER):/home/$(USER):rw" \
setsoft/kicad_pybuild:latest /bin/bash
gen1_ref:
src/eeschema_do export --file_format ps --all $(GOOD_SCH) $(REFDIR)
sed -E -e 's/^%%CreationDate: .*/%%CreationDate: DATE/' -e 's/^%%Title: .*/%%Title: TITLE/' $(REFDIR)good-project.ps > $(REFDIR)good-project.ps.new
mv $(REFDIR)good-project.ps.new $(REFDIR)good-project.ps
sed -E -e 's/^%%CreationDate: .*/%%CreationDate: DATE/' -e 's/^%%Title: .*/%%Title: TITLE/' $(REFDIR)good-project-logic.ps > $(REFDIR)good-project-logic.ps.new
mv $(REFDIR)good-project-logic.ps.new $(REFDIR)good-project-logic.ps
sed -E -e 's/^%%CreationDate: .*/%%CreationDate: DATE/' -e 's/^%%Title: .*/%%Title: TITLE/' $(REFDIR)good-project-Power.ps > $(REFDIR)good-project-Power.ps.new
mv $(REFDIR)good-project-Power.ps.new $(REFDIR)good-project-Power.ps
gen_ref:
# Force using the default color scheme
if [ -e $(HOME)/.config/kicad/7.0/colors ] && [ -e output $(HOME)/.config/kicad/7.0/colors.ok ] ; then rm -rf $(HOME)/.config/kicad/7.0/colors.ok; fi
if [ -e $(HOME)/.config/kicad/7.0/colors ] ; then mv $(HOME)/.config/kicad/7.0/colors $(HOME)/.config/kicad/7.0/colors.ok; fi
# Reference outputs, must be manually inspected if regenerated
cp -a $(REFILL).refill $(REFILL)
src/pcbnew_do export --output_name zone-refill.pdf $(REFILL) $(REFDIR) F.Cu B.Cu Edge.Cuts
cp -a $(REFILL).ok $(REFILL)
src/pcbnew_do export --output_name good_pcb_with_dwg.pdf $(GOOD) $(REFDIR) F.Cu F.SilkS Dwgs.User Edge.Cuts
src/pcbnew_do export --output_name good_pcb_inners.pdf $(GOOD) $(REFDIR) F.Cu F.SilkS GND.Cu Signal1.Cu Signal2.Cu Power.Cu Edge.Cuts
src/pcbnew_do export --list $(GOOD) > $(REFDIR)good_pcb_layers.txt
src/pcbnew_do export --mirror --scaling 4 --pads 0 --no-title --monochrome --separate --output_name good_pcb_sep_bn.pdf $(GOOD) $(REFDIR) F.Cu F.SilkS Dwgs.User Edge.Cuts
src/pcbnew_do export --mirror --scaling 0 --pads 0 --no-title --monochrome --separate --output_name good_pcb_sep_bn_fit.pdf $(GOOD) $(REFDIR) F.Cu F.SilkS Dwgs.User Edge.Cuts
src/eeschema_do export --file_format pdf --all $(GOOD_SCH) $(REFDIR)
mv $(REFDIR)good-project.pdf $(REFDIR)good_sch_all.pdf
src/eeschema_do export --file_format pdf $(GOOD_SCH) $(REFDIR)
mv $(REFDIR)good-project.pdf $(REFDIR)good_sch_top.pdf
src/eeschema_do export --file_format svg --all $(GOOD_SCH) $(REFDIR)
# I really hate this, files has time stamps, 3 of them in fact, WHY ANOTHER INSIDE!!!
sed -E 's/date .* <\/title>/DATE <\/title>/' $(REFDIR)good-project.svg > $(REFDIR)good-project.svg.new
mv $(REFDIR)good-project.svg.new $(REFDIR)good-project.svg
sed -E 's/date .* <\/title>/DATE <\/title>/' $(REFDIR)good-project-logic.svg > $(REFDIR)good-project-logic.svg.new
mv $(REFDIR)good-project-logic.svg.new $(REFDIR)good-project-logic.svg
sed -E 's/date .* <\/title>/DATE <\/title>/' $(REFDIR)good-project-Power.svg > $(REFDIR)good-project-Power.svg.new
mv $(REFDIR)good-project-Power.svg.new $(REFDIR)good-project-Power.svg
src/eeschema_do export --file_format ps --all $(GOOD_SCH) $(REFDIR)
sed -E -e 's/^%%CreationDate: .*/%%CreationDate: DATE/' -e 's/^%%Title: .*/%%Title: TITLE/' $(REFDIR)good-project.ps > $(REFDIR)good-project.ps.new
mv $(REFDIR)good-project.ps.new $(REFDIR)good-project.ps
sed -E -e 's/^%%CreationDate: .*/%%CreationDate: DATE/' -e 's/^%%Title: .*/%%Title: TITLE/' $(REFDIR)good-project-logic.ps > $(REFDIR)good-project-logic.ps.new
mv $(REFDIR)good-project-logic.ps.new $(REFDIR)good-project-logic.ps
sed -E -e 's/^%%CreationDate: .*/%%CreationDate: DATE/' -e 's/^%%Title: .*/%%Title: TITLE/' $(REFDIR)good-project-Power.ps > $(REFDIR)good-project-Power.ps.new
mv $(REFDIR)good-project-Power.ps.new $(REFDIR)good-project-Power.ps
# Restore the colors scheme
mv $(HOME)/.config/kicad/7.0/colors.ok $(HOME)/.config/kicad/7.0/colors
t1k7: single_test
single_test:
-@rm .coverage
rm -rf pp
-$(PYTEST) --log-cli-level debug -k "$(SINGLE_TEST)" --test_dir pp
@echo "********************" Output
@cat pp/*/output.txt
@echo "********************" Error
@tail -n 30 pp/*/error.txt
-@rm -rf tests/kicad6/kicad4-project/kicad4-project-rescue.lib tests/kicad6/kicad4-project/kicad4-project.kicad_prl \
tests/kicad6/kicad4-project/kicad4-project.kicad_pro tests/kicad6/kicad4-project/kicad4-project.kicad_sch \
tests/kicad6/kicad4-project/kicad4-project.pro-bak tests/kicad6/kicad4-project/rescue-backup/ \
tests/kicad6/kicad4-project/sym-lib-table
.PHONY: deb deb_clean test lint test_local gen_ref test_docker_local single_test