forked from f4pga/prjxray
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
235 lines (177 loc) · 7.13 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
SHELL = bash
ALL_EXCLUDE = third_party .git env build docs/env
# Check if root
ifeq ($(shell id -u),0)
$(error ERROR: Running as ID 0)
endif
# Tools + Environment
IN_ENV = if [ -e env/bin/activate ]; then . env/bin/activate; fi; source utils/environment.python.sh;
env:
virtualenv --python=python3 env
# Install prjxray
ln -sf $(PWD)/prjxray env/lib/python3.*/site-packages/
$(IN_ENV) python -c "import prjxray"
# Install fasm from third_party
$(IN_ENV) pip install --upgrade -e third_party/fasm
# Install sdfparse form third party
$(IN_ENV) pip install --upgrade -e third_party/python-sdf-timing
# Install project dependencies
$(IN_ENV) pip install -r requirements.txt
# Install project's documentation dependencies
$(IN_ENV) pip install -r docs/requirements.txt
# Check fasm library was installed
$(IN_ENV) python -c "import fasm"
$(IN_ENV) python -c "import fasm.output"
# Check sdfparse lib was installed
$(IN_ENV) python -c "import sdf_timing"
$(IN_ENV) python -c "import sdf_timing.sdfparse"
# Check YAML is installed
$(IN_ENV) python -c "import yaml" || (echo "Unable to find python-yaml" && exit 1)
build:
git submodule update --init --recursive
mkdir -p build
cd build; cmake ..; $(MAKE)
.PHONY: env build
# Run tests of code.
# ------------------------
TEST_EXCLUDE = $(foreach x,$(ALL_EXCLUDE) docs fuzzers minitests experiments,--ignore $(x))
test: test-py test-cpp
@true
test-py:
$(IN_ENV) which py.test; py.test $(TEST_EXCLUDE) --doctest-modules --junitxml=build/py_test_results.xml
test-cpp:
mkdir -p build
cd build && cmake -DPRJXRAY_BUILD_TESTING=ON ..
cd build && $(MAKE) -s
cd build && ctest --no-compress-output -T Test -C RelWithDebInfo --output-on-failure
xsltproc .github/kokoro/ctest2junit.xsl build/Testing/*/Test.xml > build/cpp_test_results.xml
.PHONY: test test-py test-cpp
# Run HTML test
# ------------------------
test-htmlgen:
cd htmlgen && source htmlgen.sh
.PHONY: test-htmlgen
# Auto formatting of code.
# ------------------------
FORMAT_EXCLUDE = $(foreach x,$(ALL_EXCLUDE),-and -not -path './$(x)/*') -and -not -name *.bit
CLANG_FORMAT ?= clang-format-5.0
format-cpp:
find . -name \*.cc $(FORMAT_EXCLUDE) -print0 | xargs -0 -P $$(nproc) ${CLANG_FORMAT} -style=file -i
find . -name \*.h $(FORMAT_EXCLUDE) -print0 | xargs -0 -P $$(nproc) ${CLANG_FORMAT} -style=file -i
format-docs:
./.github/update-contributing.py
PYTHON_FORMAT ?= yapf
format-py:
$(IN_ENV) find . -name \*.py $(FORMAT_EXCLUDE) -print0 | xargs -0 -P $$(nproc) yapf -p -i
TCL_FORMAT ?= utils//tcl-reformat.sh
format-tcl:
find . -name \*.tcl $(FORMAT_EXCLUDE) -print0 | xargs -0 -P $$(nproc) -n 1 $(TCL_FORMAT)
# Command to find and replace trailing whitespace in-place using `sed` (This is
# placed inside quotes later so need to escape the "'")
WS_CMD = sed -i '\''s@\s\+$$@@g'\''
# File filter for files to fix trailing whitespace in, this is just a couple of
# chained bash conditionals ensuring that the file (indicated by {}, provided by
# xargs later) is a file, and not a directory or link. Also filters out .bit
# files as these are the only binary files currently tracked by Git and we don't
# want to inadvertently change these at all.
WS_FILTER = [ -f {} -a ! -L {} ] && [[ {} != *.bit ]]
# For every file piped to $(WS_FORMAT) apply the filter and perform the command,
# if a file does not match the filter, just returns true.
WS_FORMAT = xargs -P $$(nproc) -n 1 -I{} bash -c '$(WS_FILTER) && $(WS_CMD) {} || true'
format-trailing-ws:
# Use `git ls-files` to give us a complete list of tracked files to fix
# whitespace in; there is no point spending time processing anything that is
# not known to Git.
git ls-files | $(WS_FORMAT)
# Additionally fix untracked (but not ignored) files.
git ls-files -o --exclude-standard | $(WS_FORMAT)
format: format-cpp format-docs format-py format-tcl format-trailing-ws
@true
.PHONY: format format-cpp format-py format-tcl format-trailing-ws
# Targets related to Project X-Ray databases
# ------------------------
DATABASES=artix7 kintex7 zynq7
define database
# $(1) - Database name
db-$(1):
+source settings/$(1).sh && $$(MAKE) -C fuzzers
db-check-$(1):
@echo
@echo "Checking $(1) database"
@echo "============================"
@$(IN_ENV) python3 utils/checkdb.py
db-format-$(1):
@echo
@echo "Formatting $(1) database"
@echo "============================"
@$(IN_ENV) cd database/$(1); python3 ../../utils/sort_db.py
@if [ -e database/Info.md ]; then $(IN_ENV) ./utils/info_md.py --keep; fi
.PHONY: db-$(1) db-check-$(1) db-format-$(1) db-extras-$(1) db-extras-$(1)-parts db-extras-$(1)-harness
db-extras-$(1): db-extras-$(1)-parts db-extras-$(1)-harness
db-$(1)-all: db-$(1) db-extras-$(1)-parts
# Build harnesses after database is complete
$$(MAKE) db-extras-$(1)-harness
db-check: db-check-$(1)
db-format: db-format-$(1)
endef
$(foreach DB,$(DATABASES),$(eval $(call database,$(DB))))
# Targets related to Project X-Ray parts
# --------------------------------------
ARTIX_PARTS=artix7_200t artix7_100t
ZYNQ_PARTS=zynq7010
KINTEX_PARTS=kintex70t
XRAY_PARTS=${ARTIX_PARTS} ${ZYNQ_PARTS} ${KINTEX_PARTS}
define multiple-parts
# $(1): PART to be used
db-part-only-$(1):
+source settings/$(1).sh && $$(MAKE) -C fuzzers part_only
endef
$(foreach PART,$(XRAY_PARTS),$(eval $(call multiple-parts,$(PART))))
db-extras-artix7-parts: $(addprefix db-part-only-,$(ARTIX_PARTS))
db-extras-artix7-harness:
+XRAY_PIN_00=J13 XRAY_PIN_01=J14 XRAY_PIN_02=K15 XRAY_PIN_03=K16 \
XRAY_PART=xc7a35tftg256-1 XRAY_EQUIV_PART=xc7a50tfgg484-1 $(MAKE) -C fuzzers roi_only
+source settings/artix7_100t.sh && \
XRAY_PIN_00=N15 XRAY_PART=xc7a100tcsg324-1 XRAY_EQUIV_PART=xc7a100tfgg676-1 \
$(MAKE) -C fuzzers roi_only
+source settings/artix7_200t.sh && \
XRAY_PIN_00=V10 XRAY_PIN_01=W10 XRAY_PIN_02=Y11 XRAY_PIN_03=Y12 \
XRAY_PART=xc7a200tsbg484-1 XRAY_EQUIV_PART=xc7a200tffg1156-1 \
$(MAKE) -C fuzzers roi_only
+source minitests/roi_harness/basys3-swbut.sh && $(MAKE) -C fuzzers roi_only
+source minitests/roi_harness/arty-uart.sh && $(MAKE) -C fuzzers roi_only
+source minitests/roi_harness/basys3-swbut.sh && \
$(MAKE) -C minitests/roi_harness \
HARNESS_DIR=$(XRAY_DATABASE_DIR)/artix7/harness/basys3/swbut copy
+source minitests/roi_harness/basys3-swbut.sh && \
$(MAKE) -C minitests/roi_harness \
XRAY_ROIV=../roi_base_div2.v \
HARNESS_DIR=$(XRAY_DATABASE_DIR)/artix7/harness/basys3/swbut_50 copy
+source minitests/roi_harness/arty-uart.sh && \
$(MAKE) -C minitests/roi_harness \
HARNESS_DIR=$(XRAY_DATABASE_DIR)/artix7/harness/arty-a7/uart copy
+source minitests/roi_harness/arty-pmod.sh && \
$(MAKE) -C minitests/roi_harness \
HARNESS_DIR=$(XRAY_DATABASE_DIR)/artix7/harness/arty-a7/pmod copy
+source minitests/roi_harness/arty-swbut.sh && \
$(MAKE) -C minitests/roi_harness \
HARNESS_DIR=$(XRAY_DATABASE_DIR)/artix7/harness/arty-a7/swbut copy
db-extras-kintex7-parts:
@true
db-extras-kintex7-harness:
@true
db-extras-zynq7-parts: $(addprefix db-part-only-,$(ZYNQ_PARTS))
db-extras-zynq7-harness:
@true
db-check:
@true
db-format:
@true
db-info:
$(IN_ENV) ./utils/info_md.py
.PHONY: db-check db-format
clean:
$(MAKE) -C database clean
$(MAKE) -C fuzzers clean
rm -rf build
.PHONY: clean