Repository navigation
Expand file tree
/
Copy pathMakefile
More file actions
491 lines (402 loc) · 20.2 KB
/
Copy pathMakefile
File metadata and controls
491 lines (402 loc) · 20.2 KB
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
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
# Top-level Makefile for SpinalVoodoo simulation + DE10 scaffolding
#
# Canonical command taxonomy:
# native/<runtime>/<action>[/<name>]
# dos/<runtime>/<action>[/<name>]
# tomb/<runtime>/<action>
# de10/<action>
.PHONY: all clean clean-sim clean-glide clean-tests native/help native/sim/build native/trace/build native/sim/run-all native/sim/check-all native/de10sim/check-all native/de10sim/check-image dos/help dos/sim/build dos/trace/build dos/dosbox tomb/help tomb/prepare tomb/sim/run tomb/sim/headless tomb/sim/capture tomb/sim/trace tomb/sim/trace/check tomb/trace/run tomb/trace/headless tomb/trace/check tomb/trace/profile de10/help de10/setup/program de10/setup/deploy de10/check/mmio de10/check/ddr-stress de10/report/ddr de10/run/tomb de10/run/tomb/vnc de10/trace/build de10/trace/run de10/plan de10/rtl de10/qsys de10/bitstream de10/ddrbench/rtl de10/ddrbench/bitstream de10/sync-sysroot de10/glide de10/glide-tests de10/glide-cross de10/glide-tests-cross FORCE
.PRECIOUS: dos/sim/build/% dos/trace/build/%
# Derive CXX32 from CC32 for sub-makefiles that need it
CC32 ?= gcc -m32
export CXX32 ?= $(shell d=$$(dirname "$(firstword $(CC32))") && [ -x "$$d/g++" ] && echo "$$d/g++" || echo "g++ -m32")
export CC32
export TRACE
export REF_TRACE
SIM_INTERFACE ?= core
SIM_MODEL = $(if $(filter de10,$(SIM_INTERFACE)),CoreDe10,CoreSim)
SIM_DIR = emu/sim
GLIDE_SRC_DIR = emu/glide/glide2x/sst1/glide/src
GLIDE_TST_DIR = emu/glide/glide2x/sst1/glide/tests
DOS_SDK_MAKEFILE = Makefile.sdkwat
DOS_TEST_MOUNT_DIR = $(GLIDE_TST_DIR)
# SpinalHDL sources — trigger sim rebuild when RTL changes
SCALA_SRCS := $(shell find src -name '*.scala') project.scala
# Stamp files — real build outputs used to avoid unnecessary sub-make invocations
SIM_STAMP = $(SIM_DIR)/obj_dir/V$(SIM_MODEL)__ALL.a
SIM_RTL = $(SIM_DIR)/rtl/$(SIM_MODEL).v
GLIDE_STAMP = emu/glide/glide2x/sst1/lib/sst1/libglide2x.so.2
OUTPUT_DIR = output
DE10_RTL_DIR = hw/de10/rtl
DE10_BUILD_SCRIPT = scripts/build-bitstream-de10
DE10_RTL_SCRIPT = scripts/gen-rtl-de10
DE10_QSYS_SCRIPT = scripts/gen-qsys-de10
DE10_PROGRAM_SCRIPT = scripts/program-de10
DE10_DEPLOY_SCRIPT = scripts/deploy-de10.sh
DE10_SYNC_SYSROOT_SCRIPT = scripts/sync-de10-sysroot
DE10_CROSS_GLIDE_SCRIPT = scripts/build-de10-glide-cross
DE10_MMIO_SMOKE_BIN = tools/de10-mmio-smoke
DE10_DDR_STRESS_BIN = tools/de10-ddr-stress
DE10_TRACE_REPLAY_BIN = output/de10/bin/de10-trace-replay
DE10_DDR_RBF = output/de10/bitstream/SpinalVoodoo_de10.rbf
DE10_HOST ?= debian-fpga.local
DE10_USER ?= fpga
DE10_TRACE_BUILD_REMOTE_DIR ?= /home/$(DE10_USER)/trace-replay-build
all: native/sim/build
native/help:
@echo "Native targets:"
@echo " runtimes: sim, trace"
@echo " make native/sim/build # build all Linux-hosted Glide test binaries"
@echo " make native/sim/build/test00 # build one Linux-hosted test binary"
@echo " make native/sim/run/test00 # run one Linux-hosted test with screenshot output"
@echo " make native/trace/build # build the trace-capture Glide runtime"
@echo " make native/trace/run/test00 # capture a trace from one Linux-hosted test"
@echo " make native/sim/check/test00 # replay an existing trace through the check pipeline"
@echo " make native/de10sim/check/test00 # replay an existing trace through the DE10 sim pipeline"
@echo " make native/sim/test/test00 # capture and check in one step"
@echo " make native/sim/check-all # replay every existing trace"
dos/help:
@echo "DOS targets:"
@echo " runtimes: sim, trace"
@echo " make dos/sim/build # build all DOS SDK-style test binaries"
@echo " make dos/sim/build/df00sdk # build one DOS SDK-style test binary"
@echo " make dos/sim/run/df00sdk # run one DOS SDK-style test in DOSBox-X"
@echo " make dos/sim/headless/df00sdk # run one DOS SDK-style test headlessly"
@echo " make dos/trace/run/df00sdk # run one DOS SDK-style test with trace runtime to traces/dos/df00sdk.bin"
@echo " make dos/trace/headless/df00sdk # run one DOS SDK-style test headlessly with trace runtime"
@echo " make dos/dosbox ARGS='...' # launch DOSBox-X with the sim Glide backend"
@echo " make tomb/help # print Tomb Raider setup requirements"
native/sim/build: $(GLIDE_STAMP)
$(MAKE) _glide_build_sim
$(MAKE) -C $(GLIDE_TST_DIR) -f Makefile.sim all SIM_INTERFACE=$(SIM_INTERFACE)
native/trace/build: $(SIM_DIR)/obj_dir/sim_trace_harness.o
$(MAKE) _glide_build_trace
dos/sim/build: $(GLIDE_STAMP)
$(MAKE) _glide_build_sim
$(MAKE) -C $(GLIDE_TST_DIR) -f $(DOS_SDK_MAKEFILE) all
dos/trace/build: native/trace/build
$(MAKE) -C $(GLIDE_TST_DIR) -f $(DOS_SDK_MAKEFILE) all
dos/dosbox:
$(MAKE) _glide_build_sim
bash ./scripts/run-dosboxx32-glide $(ARGS)
tomb/help:
@echo "Tomb Raider setup:"
@echo " 1) Prepare a source tree at DOSBOX_TOMB_SRC (default: /tmp/tr1-3dfx)"
@echo " 2) Easiest path: make tomb/prepare ARGS='--game-dir /path/to/TOMBRAID --patch /path/to/3dfx-patch.zip --iso /path/to/tr1disc01.iso'"
@echo " 3) The prepared tree must contain \$$DOSBOX_TOMB_GAME_DIR and usually \$$DOSBOX_TOMB_ISO"
@echo " 4) The runner copies that tree to DOSBOX_TOMB_STAGE_ROOT and disables bundled glide2x.ovl"
@echo " 5) Override paths with DOSBOX_TOMB_SRC, DOSBOX_TOMB_STAGE_ROOT, DOSBOX_TOMB_GAME_DIR, DOSBOX_TOMB_ISO, DOSBOX_TOMB_EXE"
@echo " 6) Pass --output PATH or --force through make tomb/prepare ARGS='...' when needed"
@echo " 7) Canonical runs are make tomb/sim/run, make tomb/sim/headless, make tomb/sim/capture, make tomb/sim/trace, make tomb/trace/run"
@echo " 8) Use make tomb/sim/trace/check to replay traces/tomb_live/trace.bin, tomb/trace/check for traces/tomb/trace.bin, and tomb/trace/profile for CoreDe10 perf profiling"
tomb/prepare:
bash ./scripts/prepare-tomb-glide-tree $(ARGS)
tomb/sim/run:
$(MAKE) _glide_build_sim
bash ./scripts/run-tomb-glide-live $(ARGS)
tomb/sim/headless:
$(MAKE) _glide_build_sim
bash ./scripts/run-tomb-glide-headless $(ARGS)
tomb/sim/capture:
$(MAKE) _glide_build_sim
bash ./scripts/capture-tomb-screenshot $(ARGS)
tomb/sim/trace:
@mkdir -p traces/tomb_live
$(MAKE) _glide_build_sim
SIM_TRACE_FILE=$(abspath traces)/tomb_live/trace.bin \
bash ./scripts/run-tomb-glide-live $(ARGS)
tomb/sim/trace/check: $(TRACE_TEST_BIN)
@mkdir -p output/tomb/trace_replay_live
$(TRACE_TEST_BIN) traces/tomb_live/trace.bin --output-dir output/tomb/trace_replay_live $(TRACE_TEST_ARGS)
tomb/trace/run: native/trace/build
@mkdir -p traces/tomb
SIM_TRACE_FILE=$(abspath traces)/tomb/trace.bin \
bash ./scripts/run-tomb-glide-live $(ARGS)
tomb/trace/headless: native/trace/build
@mkdir -p traces/tomb
SIM_TRACE_FILE=$(abspath traces)/tomb/trace.bin \
bash ./scripts/run-tomb-glide-headless $(ARGS)
tomb/trace/check: $(TRACE_TEST_BIN)
@mkdir -p output/tomb/trace_replay
$(TRACE_TEST_BIN) traces/tomb --output-dir output/tomb/trace_replay $(TRACE_TEST_ARGS)
native/de10sim/check/%: FORCE
$(MAKE) -C emu/test SIM_INTERFACE=de10 CORE_SIM_GEN_ARGS="$(CORE_SIM_GEN_ARGS)"
@mkdir -p test-output/$*-de10sim
@if [ -f traces/$*.bin ]; then \
src=traces/$*.bin; \
elif [ -d traces/$* ]; then \
src=traces/$*/; \
else \
echo "ERROR: neither traces/$*.bin nor traces/$*/ found. Run a trace capture first."; exit 1; \
fi; \
emu/test/obj_dir/trace_test "$$src" --output-dir test-output/$*-de10sim $(TRACE_TEST_ARGS)
native/de10sim/check-image/%: FORCE
$(MAKE) native/de10sim/check/$* TRACE_TEST_ARGS='$(TRACE_TEST_STRICT_ARGS)'
native/de10sim/check-all: FORCE
@for f in traces/*.bin; do \
[ -f "$$f" ] || continue; \
name="$${f##*/}"; name="$${name%.bin}"; \
$(MAKE) native/de10sim/check/$$name || exit 1; \
done; \
for d in traces/*; do \
[ -d "$$d" ] || continue; \
[ -f "$$d/trace.bin" ] || continue; \
name="$${d##*/}"; \
$(MAKE) native/de10sim/check/$$name || exit 1; \
done
tomb/trace/profile:
bash ./scripts/profile-trace-corede10 traces/tomb $(ARGS)
de10/help:
@echo "DE10 workflow targets:"
@echo " runtime: de10"
@echo " make de10/setup/program # program the FPGA on the board"
@echo " make de10/setup/deploy # deploy the board runtime bundle"
@echo " make de10/check/mmio # run the board MMIO smoke utility"
@echo " make de10/check/ddr-stress # build the DE10 DDR stress utility"
@echo " make de10/report/ddr # program board and collect DDR statistics tables"
@echo " make de10/run/dos/df00sdk # run one DOS workload from the board runtime dir"
@echo " make de10/run/tomb # run Tomb from a prepared remote Tomb tree"
@echo " make de10/run/tomb/vnc # run Tomb on the board under a VNC X server"
@echo " make de10/trace/build # build the DE10 board trace replay tool"
@echo " make de10/trace/run/tomb # replay traces/tomb on the board and dump a screenshot"
@echo " make native/de10sim/check/tomb # replay traces/tomb through the DE10 simulator backend"
@echo ""
@echo "Advanced DE10 targets:"
@echo " make de10/plan # open goals and bring-up docs"
@echo " make de10/rtl # generate DE10-targeted RTL"
@echo " make de10/qsys # generate Platform Designer system"
@echo " make de10/bitstream # run Quartus bitstream build flow"
@echo " make de10/ddrbench/rtl # generate DDR bench RTL as De10Top.v"
@echo " make de10/ddrbench/bitstream # build the DDR bench bitstream"
@echo " make de10/sync-sysroot # fetch DE10 userspace sysroot locally"
@echo " make de10/glide # build DE10-targeted Glide library"
@echo " make de10/glide-tests # build DE10-targeted Glide test binaries"
@echo " make de10/glide-cross # cross-build DE10 Glide library locally"
@echo " make de10/glide-tests-cross # cross-build DE10 Glide tests locally"
de10/setup/program:
$(DE10_PROGRAM_SCRIPT) $(ARGS)
de10/setup/deploy:
$(DE10_DEPLOY_SCRIPT) $(ARGS)
de10/check/mmio: $(DE10_MMIO_SMOKE_BIN)
de10/check/ddr-stress: $(DE10_DDR_STRESS_BIN)
de10/report/ddr: $(DE10_DDR_STRESS_BIN) $(DE10_DDR_RBF)
bash ./scripts/report-de10-ddr
de10/run/dos/%:
bash ./scripts/run-de10-dos-workload --exe $*.EXE $(ARGS)
de10/run/tomb:
bash ./scripts/run-de10-tomb-workload $(ARGS)
de10/run/tomb/vnc:
bash ./scripts/run-de10-tomb-vnc $(ARGS)
de10/trace/build: $(DE10_TRACE_REPLAY_BIN)
de10/trace/run: $(DE10_TRACE_REPLAY_BIN)
bash ./scripts/run-de10-trace-replay $(ARGS)
de10/trace/run/%: $(DE10_TRACE_REPLAY_BIN)
bash ./scripts/run-de10-trace-replay --input traces/$* --output-dir output/de10-board-trace/$* $(ARGS)
de10/plan:
@echo "See docs/DE10_MILESTONES.md"
@echo "See docs/DE10_BRINGUP_PLAN.md"
@echo "See docs/DE10_DEPLOYMENT.md"
de10/rtl:
@mkdir -p $(DE10_RTL_DIR)
$(DE10_RTL_SCRIPT)
de10/qsys:
$(DE10_QSYS_SCRIPT)
de10/bitstream:
$(DE10_BUILD_SCRIPT)
de10/ddrbench/rtl:
@mkdir -p $(DE10_RTL_DIR)
DE10_RTL_MAIN_CLASS=voodoo.de10.De10DdrBenchTopGen $(DE10_RTL_SCRIPT)
de10/ddrbench/bitstream: $(DE10_DDR_RBF)
$(DE10_DDR_RBF): $(SCALA_SRCS) hw/de10/quartus/De10PlatformTop.v hw/de10/qsys/create_de10_soc.tcl
DE10_RTL_MAIN_CLASS=voodoo.de10.De10DdrBenchTopGen $(DE10_BUILD_SCRIPT)
de10/sync-sysroot:
$(DE10_SYNC_SYSROOT_SCRIPT) $(ARGS)
de10/glide:
$(MAKE) -C emu/glide/glide2x/sst1/glide/src -f Makefile.de10 $(ARGS)
de10/glide-tests:
$(MAKE) -C emu/glide/glide2x/sst1/glide/src -f Makefile.de10
$(MAKE) -C emu/glide/glide2x/sst1/glide/tests -f Makefile.de10 $(ARGS)
de10/glide-cross:
$(DE10_CROSS_GLIDE_SCRIPT) --glide $(ARGS)
de10/glide-tests-cross:
$(DE10_CROSS_GLIDE_SCRIPT) --glide-tests $(ARGS)
$(DE10_MMIO_SMOKE_BIN): tools/de10-mmio-smoke.c
$(CC) -O2 -Wall -Wextra -o $@ $<
$(DE10_DDR_STRESS_BIN): tools/de10-ddr-stress.c
$(CC) -O2 -Wall -Wextra -o $@ $<
$(DE10_TRACE_REPLAY_BIN): tools/de10-trace-replay.cpp \
emu/trace/voodoo_trace_format.h \
emu/trace/trace_replay_backend.h \
emu/trace/trace_replay_image.h \
emu/trace/trace_replay_io.h \
emu/trace/trace_replay_runner.h \
emu/test/stb_image_write.h
@mkdir -p $(dir $@)
ssh $(DE10_USER)@$(DE10_HOST) "mkdir -p '$(DE10_TRACE_BUILD_REMOTE_DIR)'"
ssh $(DE10_USER)@$(DE10_HOST) "rm -f '$(DE10_TRACE_BUILD_REMOTE_DIR)/de10-trace-replay' '$(DE10_TRACE_BUILD_REMOTE_DIR)/de10-trace-replay.cpp' '$(DE10_TRACE_BUILD_REMOTE_DIR)/voodoo_trace_format.h' '$(DE10_TRACE_BUILD_REMOTE_DIR)/trace_replay_backend.h' '$(DE10_TRACE_BUILD_REMOTE_DIR)/trace_replay_image.h' '$(DE10_TRACE_BUILD_REMOTE_DIR)/trace_replay_io.h' '$(DE10_TRACE_BUILD_REMOTE_DIR)/trace_replay_runner.h' '$(DE10_TRACE_BUILD_REMOTE_DIR)/stb_image_write.h'"
scp tools/de10-trace-replay.cpp $(DE10_USER)@$(DE10_HOST):$(DE10_TRACE_BUILD_REMOTE_DIR)/de10-trace-replay.cpp
scp emu/trace/voodoo_trace_format.h $(DE10_USER)@$(DE10_HOST):$(DE10_TRACE_BUILD_REMOTE_DIR)/voodoo_trace_format.h
scp emu/trace/trace_replay_backend.h $(DE10_USER)@$(DE10_HOST):$(DE10_TRACE_BUILD_REMOTE_DIR)/trace_replay_backend.h
scp emu/trace/trace_replay_image.h $(DE10_USER)@$(DE10_HOST):$(DE10_TRACE_BUILD_REMOTE_DIR)/trace_replay_image.h
scp emu/trace/trace_replay_io.h $(DE10_USER)@$(DE10_HOST):$(DE10_TRACE_BUILD_REMOTE_DIR)/trace_replay_io.h
scp emu/trace/trace_replay_runner.h $(DE10_USER)@$(DE10_HOST):$(DE10_TRACE_BUILD_REMOTE_DIR)/trace_replay_runner.h
scp emu/test/stb_image_write.h $(DE10_USER)@$(DE10_HOST):$(DE10_TRACE_BUILD_REMOTE_DIR)/stb_image_write.h
ssh $(DE10_USER)@$(DE10_HOST) "g++ -O2 -std=c++17 -I'$(DE10_TRACE_BUILD_REMOTE_DIR)' -o '$(DE10_TRACE_BUILD_REMOTE_DIR)/de10-trace-replay' '$(DE10_TRACE_BUILD_REMOTE_DIR)/de10-trace-replay.cpp'"
scp $(DE10_USER)@$(DE10_HOST):$(DE10_TRACE_BUILD_REMOTE_DIR)/de10-trace-replay $@
# Internal sim build target: always recurse into sub-make
_sim_build:
$(MAKE) -C $(SIM_DIR) all SIM_INTERFACE=$(SIM_INTERFACE)
_glide_build_sim: _sim_build
$(MAKE) -C $(GLIDE_SRC_DIR) -f Makefile.sim clean
$(MAKE) -C $(GLIDE_SRC_DIR) -f Makefile.sim SIM_INTERFACE=$(SIM_INTERFACE)
_glide_build_trace: $(SIM_DIR)/obj_dir/sim_trace_harness.o
$(MAKE) -C $(GLIDE_SRC_DIR) -f Makefile.sim clean
$(MAKE) -C $(GLIDE_SRC_DIR) -f Makefile.sim TRACE_CAPTURE=1 SIM_INTERFACE=$(SIM_INTERFACE)
# Trace mode sentinel: force sim+glide rebuild when TRACE= setting changes.
# Updated at parse time via $(shell) so the timestamp only changes on real transitions.
TRACE_MODE_FILE = $(SIM_DIR)/obj_dir/.trace_mode
TRACE_MODE_VAL = $(if $(filter 1,$(TRACE)),trace,notrace)
$(shell mkdir -p $(dir $(TRACE_MODE_FILE)))
$(shell [ -f $(TRACE_MODE_FILE) ] && [ "$$(cat $(TRACE_MODE_FILE))" = "$(TRACE_MODE_VAL)" ] || echo "$(TRACE_MODE_VAL)" > $(TRACE_MODE_FILE))
$(SIM_DIR)/obj_dir/sim_trace_harness.o: FORCE
$(MAKE) -C $(SIM_DIR) trace-harness SIM_INTERFACE=$(SIM_INTERFACE)
# File-based build chain: only recurse when outputs are stale.
# The sub-makes handle fine-grained .c/.o dependency tracking internally.
$(SIM_STAMP): $(SCALA_SRCS) $(TRACE_MODE_FILE)
$(MAKE) -C $(SIM_DIR) all SIM_INTERFACE=$(SIM_INTERFACE)
# Always recurse so sub-make tracks .c → .o deps for Glide sources
$(GLIDE_STAMP): $(SIM_STAMP) FORCE
$(MAKE) -C $(GLIDE_SRC_DIR) -f Makefile.sim SIM_INTERFACE=$(SIM_INTERFACE)
# Build a single test exe (always recurse so sub-make tracks .c → .o deps)
$(GLIDE_TST_DIR)/%.exe: $(GLIDE_STAMP) FORCE
$(MAKE) -C $(GLIDE_TST_DIR) -f Makefile.sim $*.exe SIM_INTERFACE=$(SIM_INTERFACE)
# Run a single Linux-hosted test with the sim backend.
native/sim/run/%: $(GLIDE_TST_DIR)/%.exe scripts/srle2png
@rm -rf $(OUTPUT_DIR)/$*
@mkdir -p $(OUTPUT_DIR)/$*
@ln -sfn ../../$(SIM_RTL) $(OUTPUT_DIR)/$*/$(SIM_MODEL).v
cd $(GLIDE_TST_DIR) && \
$(if $(filter 1,$(TRACE)),SIM_FST=$(abspath $(OUTPUT_DIR))/$*/trace.fst) \
LD_LIBRARY_PATH=../../lib/sst1 \
./$*.exe -n 1 -d $(abspath $(OUTPUT_DIR))/$*/screenshot.srle < /dev/null
@for f in $(OUTPUT_DIR)/$*/screenshot*.srle; do \
[ -f "$$f" ] || continue; \
python3 scripts/srle2png "$$f" "$${f%.srle}.png" && rm -f "$$f"; \
done
# Build one Linux-hosted test binary.
native/sim/build/%: FORCE
$(MAKE) _glide_build_sim
$(MAKE) -C $(GLIDE_TST_DIR) -f Makefile.sim $*.exe SIM_INTERFACE=$(SIM_INTERFACE)
# Run all Linux-hosted screenshot tests.
native/sim/run-all: $(patsubst %,native/sim/run/%,test00 test01 test02 test03 test04 test05 test06 test07 test08 test09 test13 test16 test17 test18 test19)
# --------------------------------------------------------------------------
# Trace-based testing (C++ trace_test binary)
# --------------------------------------------------------------------------
TRACE_TEST_BIN = emu/test/obj_dir/trace_test
TRACE_TEST_ARGS ?=
TRACE_TEST_STRICT_ARGS ?= --max-mismatches 0 --max-sim-black-mismatches 0 --max-parity-mismatch-skew 0
STATE_ROUNDTRIP_BIN = emu/test/obj_dir/state_roundtrip_test
# Build trace_test binary (64-bit, independent of 32-bit Glide build).
# Always recurse — sub-make tracks Scala → Verilog → Verilator → binary deps.
$(TRACE_TEST_BIN): FORCE
$(MAKE) -C emu/test
$(STATE_ROUNDTRIP_BIN): FORCE
$(MAKE) -C emu/test state-roundtrip
native/sim/check/state-roundtrip: $(STATE_ROUNDTRIP_BIN)
$(STATE_ROUNDTRIP_BIN)
# Capture trace from a Linux-hosted Glide test.
native/trace/run/%: native/trace/build
$(MAKE) -C $(GLIDE_TST_DIR) -f Makefile.sim $*.exe TRACE_CAPTURE=1 SIM_INTERFACE=$(SIM_INTERFACE)
@mkdir -p traces
cd $(GLIDE_TST_DIR) && \
SIM_TRACE_FILE=$(abspath traces)/$*.bin \
LD_LIBRARY_PATH=../../lib/sst1 \
./$*.exe -n 1 < /dev/null
# Run one DOS SDK binary in DOSBox-X with the sim backend.
dos/sim/build/%:
$(MAKE) _glide_build_sim
$(MAKE) -C $(GLIDE_TST_DIR) -f $(DOS_SDK_MAKEFILE) $*.exe
dos/sim/run/%: dos/sim/build/%
bash ./scripts/run-dosboxx32-glide \
-c "mount c $(DOS_TEST_MOUNT_DIR)" \
-c "c:" \
-c "$*.exe" \
$(ARGS)
dos/sim/headless/%: dos/sim/build/%
DOSBOXX32_HEADLESS=1 bash ./scripts/run-dosboxx32-glide \
-c "mount c $(DOS_TEST_MOUNT_DIR)" \
-c "c:" \
-c "$*.exe" \
$(ARGS)
dos/trace/build/%: native/trace/build
$(MAKE) -C $(GLIDE_TST_DIR) -f $(DOS_SDK_MAKEFILE) $*.exe
dos/trace/run/%: dos/trace/build/%
@mkdir -p traces/dos
SIM_TRACE_FILE=$(abspath traces)/dos/$*.bin \
bash ./scripts/run-dosboxx32-glide \
-c "mount c $(DOS_TEST_MOUNT_DIR)" \
-c "c:" \
-c "$*.exe" \
$(ARGS)
dos/trace/headless/%: dos/trace/build/%
@mkdir -p traces/dos
DOSBOXX32_HEADLESS=1 SIM_TRACE_FILE=$(abspath traces)/dos/$*.bin \
bash ./scripts/run-dosboxx32-glide \
-c "mount c $(DOS_TEST_MOUNT_DIR)" \
-c "c:" \
-c "$*.exe" \
$(ARGS)
# Replay a .bin trace through both 86Box ref model and Verilator CoreSim.
# Produces _ref.png, _sim.png, _diff.png in test-output/<name>/.
native/sim/check/%: $(TRACE_TEST_BIN)
@mkdir -p test-output/$*
@if [ -f traces/$*.bin ]; then \
src=traces/$*.bin; \
elif [ -d traces/$* ]; then \
src=traces/$*/; \
else \
echo "ERROR: neither traces/$*.bin nor traces/$*/ found. Run 'make native/trace/run/$*' first."; exit 1; \
fi; \
extra_args=""; \
if [ "$*" = "screamer2" ]; then \
extra_args="--max-mismatches 500"; \
fi; \
if [ "$(REF_TRACE)" = "1" ]; then \
extra_args="$$extra_args --ref-trace-jsonl test-output/$*/ref_trace.jsonl"; \
fi; \
$(if $(filter 1,$(TRACE)),SIM_FST=$(abspath test-output)/$*/trace.fst) \
$(TRACE_TEST_BIN) "$$src" --output-dir test-output/$* $$extra_args
# Capture + check in one step (sequential: trace must finish before check starts)
native/sim/test/%:
$(MAKE) native/trace/run/$*
$(MAKE) native/sim/check/$*
# Replay all existing traces
native/sim/check-all: $(TRACE_TEST_BIN)
@for f in traces/*.bin; do \
[ -f "$$f" ] || continue; \
name=$$(basename $$f .bin); \
echo "=== $$name ==="; \
mkdir -p test-output/$$name; \
extra_args=""; \
if [ "$(REF_TRACE)" = "1" ]; then extra_args="--ref-trace-jsonl test-output/$$name/ref_trace.jsonl"; fi; \
$(TRACE_TEST_BIN) $$f --output-dir test-output/$$name $$extra_args || exit 1; \
done
@for d in traces/*/trace.bin; do \
[ -f "$$d" ] || continue; \
name=$$(basename $$(dirname $$d)); \
echo "=== $$name ==="; \
mkdir -p test-output/$$name; \
extra_args=""; \
if [ "$(REF_TRACE)" = "1" ]; then extra_args="--ref-trace-jsonl test-output/$$name/ref_trace.jsonl"; fi; \
$(TRACE_TEST_BIN) traces/$$name/ --output-dir test-output/$$name $$extra_args || exit 1; \
done
clean-trace-test:
$(MAKE) -C emu/test clean
# --------------------------------------------------------------------------
clean: clean-tests clean-glide clean-sim
clean-sim:
$(MAKE) -C $(SIM_DIR) clean
clean-glide:
$(MAKE) -C $(GLIDE_SRC_DIR) -f Makefile.sim clean
clean-tests:
$(MAKE) -C $(GLIDE_TST_DIR) -f Makefile.sim clean