/
Makefile
112 lines (86 loc) · 2.63 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
# -- Variables -----------------------------------------------------------------
OUTPUT_DIRECTORY := Bookdown
INDEX_FILE := Documentation/Introduction.md
OUTPUT_NAME := Documentation
PDF_FILE := $(OUTPUT_DIRECTORY)/$(OUTPUT_NAME).pdf
EPUB_FILE := $(OUTPUT_DIRECTORY)/$(OUTPUT_NAME).epub
HTML_FILE := $(OUTPUT_DIRECTORY)/$(OUTPUT_NAME).html
ifeq ($(OS), Windows_NT)
OPERATING_SYSTEM := windows
# Disable Prysk Pytest plugin
export PYTEST_DISABLE_PLUGIN_AUTOLOAD := ""
else
OS_NAME := $(shell uname -s)
ifeq ($(OS_NAME), Linux)
OPERATING_SYSTEM := linux
else
OPERATING_SYSTEM := mac
endif
endif
# -- Rules ---------------------------------------------------------------------
run: check test hardware-test
# =========
# = Tests =
# =========
check:
flake8
mypy mytoolit
pylint mytoolit
.PHONY: test
test: pytest-test
test-no-hardware: pytest-test-no-hardware
# ----------
# - Pytest -
# ----------
pytest-test:
pytest
pytest-test-no-hardware:
pytest --ignore-glob='*network.py' \
--ignore-glob='*commander.py' \
--ignore-glob='*measure.t'
# ------------------
# - Hardware Tests -
# ------------------
hardware-test: run-hardware-test open-test-report-$(OPERATING_SYSTEM)
run-hardware-test:
test-sth -v
test-stu -k eeprom -k connection
open-test-report-windows:
@powershell -c "Invoke-Item (Join-Path $$PWD 'STH Test.pdf')"
@powershell -c "Invoke-Item (Join-Path $$PWD 'STU Test.pdf')"
open-test-report-mac:
@open 'STH Test.pdf' 'STU Test.pdf'
open-test-report-linux:
@if [ -z "$(DISPLAY)" ]; \
then \
printf "Please check the files “STH Test.pdf” and “STU Test.pdf”\n"; \
else \
xdg-open 'STH Test.pdf'; \
xdg-open 'STU Test.pdf'; \
fi
# =================
# = Documentation =
# =================
doc: init $(EPUB_FILE) $(HTML_FILE) $(PDF_FILE) cleanup
# Copy pictures to repository root and create diagrams
init:
Rscript -e "dir.create('Pictures')"
Rscript -e "file.copy('Documentation/Pictures', '.', recursive=T)"
# Remove pictures from repository root
cleanup:
Rscript -e "unlink('Pictures', recursive = TRUE)"
epub: init $(EPUB_FILE) cleanup
html: init $(HTML_FILE) cleanup
pdf: init $(PDF_FILE) cleanup
# Generate EPUB document
$(EPUB_FILE):
Rscript -e "bookdown::render_book('$(INDEX_FILE)', 'bookdown::epub_book')"
# Generate (GitBook) HTML document
$(HTML_FILE):
Rscript -e "bookdown::render_book('$(INDEX_FILE)', 'bookdown::gitbook')"
Rscript -e "file.rename('$(HTML_FILE)', '$(OUTPUT_DIRECTORY)/index.html')"
# Generate PDF
$(PDF_FILE):
Rscript -e "bookdown::render_book('$(INDEX_FILE)', 'bookdown::pdf_book')"
clean: cleanup
Rscript -e "unlink('$(OUTPUT_DIRECTORY)', recursive = TRUE)"