Repository navigation
Expand file tree
/
Copy pathMakefile
More file actions
518 lines (449 loc) · 20.4 KB
/
Copy pathMakefile
File metadata and controls
518 lines (449 loc) · 20.4 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
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
CLOSURE_DIR=closure-compiler
CLOSURE=$(CLOSURE_DIR)/compiler.jar
NASM_TEST_DIR=./tests/nasm
INSTRUCTION_TABLES=src/rust/gen/jit.rs src/rust/gen/jit0f.rs src/rust/gen/jit0f38.rs src/rust/gen/jit0f3a.rs \
src/rust/gen/jit64.rs src/rust/gen/jit64_0f.rs src/rust/gen/jit64_0f38.rs src/rust/gen/jit64_0f3a.rs \
src/rust/gen/jit64_wrappers.rs \
src/rust/gen/interpreter.rs src/rust/gen/interpreter0f.rs \
src/rust/gen/interpreter0f38.rs src/rust/gen/interpreter0f3a.rs \
src/rust/gen/analyzer.rs src/rust/gen/analyzer0f.rs src/rust/gen/analyzer0f38.rs src/rust/gen/analyzer0f3a.rs \
# Only the dependencies common to both generate_{jit,interpreter}.js
GEN_DEPENDENCIES=$(filter-out gen/generate_interpreter.js gen/generate_jit.js gen/generate_jit64.js gen/generate_analyzer.js, $(wildcard gen/*.js))
JIT_DEPENDENCIES=$(GEN_DEPENDENCIES) gen/generate_jit.js
JIT64_DEPENDENCIES=$(GEN_DEPENDENCIES) gen/generate_jit64.js
INTERPRETER_DEPENDENCIES=$(GEN_DEPENDENCIES) gen/generate_interpreter.js
ANALYZER_DEPENDENCIES=$(GEN_DEPENDENCIES) gen/generate_analyzer.js
STRIP_DEBUG_FLAG=
ifeq ($(STRIP_DEBUG),true)
STRIP_DEBUG_FLAG=--v86-strip-debug
endif
# Optimize the release wasm with binaryen's wasm-opt if it's installed (`make WASM_OPT=false` to skip)
WASM_OPT ?= $(if $(shell command -v wasm-opt),true,false)
WASM_OPT_FEATURES=--enable-bulk-memory --enable-multivalue --enable-simd --enable-sign-ext \
--enable-mutable-globals --enable-nontrapping-float-to-int
default: build/v86-debug.wasm
all: build/v86_all.js build/libv86.js build/libv86.mjs build/v86.wasm build/v86-mem64.wasm
all-debug: build/libv86-debug.js build/libv86-debug.mjs build/v86-debug.wasm
browser: build/v86_all.js
# Used for nodejs builds and in order to profile code.
# `debug` gives identifiers a readable name, make sure it doesn't have any side effects.
CLOSURE_READABLE=--formatting PRETTY_PRINT --debug
CLOSURE_SOURCE_MAP=\
--source_map_format V3\
--create_source_map '%outname%.map'
CLOSURE_FLAGS=\
--generate_exports\
--externs src/externs.js\
--warning_level VERBOSE\
--jscomp_error accessControls\
--jscomp_error checkRegExp\
--jscomp_error checkTypes\
--jscomp_error checkVars\
--jscomp_error conformanceViolations\
--jscomp_error const\
--jscomp_error constantProperty\
--jscomp_error deprecated\
--jscomp_error deprecatedAnnotations\
--jscomp_error duplicateMessage\
--jscomp_error es5Strict\
--jscomp_error externsValidation\
--jscomp_error globalThis\
--jscomp_error invalidCasts\
--jscomp_error misplacedTypeAnnotation\
--jscomp_error missingProperties\
--jscomp_error missingReturn\
--jscomp_error msgDescriptions\
--jscomp_error nonStandardJsDocs\
--jscomp_error suspiciousCode\
--jscomp_error strictModuleDepCheck\
--jscomp_error typeInvalidation\
--jscomp_error undefinedVars\
--jscomp_error unknownDefines\
--jscomp_error visibility\
--use_types_for_optimization\
--assume_function_wrapper\
--summary_detail_level 3\
--language_in ECMASCRIPT_2020\
--language_out ECMASCRIPT_2020
CARGO_FLAGS_SAFE=\
--target wasm32-unknown-unknown \
-- \
-C linker=tools/rust-lld-wrapper \
-C link-args="--import-table --global-base=4096 $(STRIP_DEBUG_FLAG)" \
-C link-args="build/softfloat.o" \
-C link-args="build/zstddeclib.o" \
--verbose
CARGO_FLAGS=$(CARGO_FLAGS_SAFE) -C target-feature=+bulk-memory -C target-feature=+multivalue -C target-feature=+simd128
CORE_FILES=cjs.js const.js io.js main.js lib.js buffer.js ide.js pci.js floppy.js \
dma.js pit.js vga.js ps2.js rtc.js uart.js parallel.js vmware.js \
acpi.js iso9660.js \
state.js ne2k.js sb16.js virtio.js virtio_console.js virtio_net.js virtio_balloon.js virtio_gpu.js \
bus.js log.js cpu.js \
elf.js kernel.js
LIB_FILES=9p.js filesystem.js marshall.js
BROWSER_FILES=screen.js gpu_screen.js keyboard.js mouse.js speaker.js serial.js \
network.js starter.js worker_bus.js dummy_screen.js ansi_screen.js \
inbrowser_network.js fake_network.js wisp_network.js fetch_network.js \
print_stats.js filestorage.js modem.js machines.js manager.js
RUST_FILES=$(shell find src/rust/ -name '*.rs') $(INSTRUCTION_TABLES)
CORE_FILES:=$(addprefix src/,$(CORE_FILES))
LIB_FILES:=$(addprefix lib/,$(LIB_FILES))
BROWSER_FILES:=$(addprefix src/browser/,$(BROWSER_FILES))
build/v86_all.js: $(CLOSURE) src/*.js src/browser/*.js lib/*.js
mkdir -p build
-ls -lh build/v86_all.js
java -jar $(CLOSURE) \
--js_output_file build/v86_all.js\
--define=DEBUG=false\
$(CLOSURE_SOURCE_MAP)\
$(CLOSURE_FLAGS)\
--compilation_level ADVANCED\
--js $(CORE_FILES)\
--js $(LIB_FILES)\
--js $(BROWSER_FILES)\
--js src/browser/main.js
ls -lh build/v86_all.js
build/v86_all_debug.js: $(CLOSURE) src/*.js src/browser/*.js lib/*.js
mkdir -p build
java -jar $(CLOSURE) \
--js_output_file build/v86_all_debug.js\
--define=DEBUG=true\
$(CLOSURE_SOURCE_MAP)\
$(CLOSURE_FLAGS)\
--compilation_level ADVANCED\
--js $(CORE_FILES)\
--js $(LIB_FILES)\
--js $(BROWSER_FILES)\
--js src/browser/main.js
build/libv86.js: $(CLOSURE) src/*.js lib/*.js src/browser/*.js
mkdir -p build
-ls -lh build/libv86.js
java -jar $(CLOSURE) \
--js_output_file build/libv86.js\
--define=DEBUG=false\
$(CLOSURE_FLAGS)\
--compilation_level SIMPLE\
--jscomp_off=missingProperties\
--output_wrapper ';(function(){%output%}).call(this);'\
--js $(CORE_FILES)\
--js $(BROWSER_FILES)\
--js $(LIB_FILES)
ls -lh build/libv86.js
build/libv86.mjs: $(CLOSURE) src/*.js lib/*.js src/browser/*.js
mkdir -p build
-ls -lh build/libv86.js
java -jar $(CLOSURE) \
--js_output_file build/libv86.mjs\
--define=DEBUG=false\
$(CLOSURE_FLAGS)\
--compilation_level SIMPLE\
--jscomp_off=missingProperties\
--output_wrapper ';let module = {exports:{}}; %output%; export default module.exports.V86; export let {V86, CPU} = module.exports;'\
--js $(CORE_FILES)\
--js $(BROWSER_FILES)\
--js $(LIB_FILES)\
--chunk_output_type=ES_MODULES\
--emit_use_strict=false
ls -lh build/libv86.mjs
build/libv86-debug.js: $(CLOSURE) src/*.js lib/*.js src/browser/*.js
mkdir -p build
java -jar $(CLOSURE) \
--js_output_file build/libv86-debug.js\
--define=DEBUG=true\
$(CLOSURE_FLAGS)\
$(CLOSURE_READABLE)\
--compilation_level SIMPLE\
--jscomp_off=missingProperties\
--output_wrapper ';(function(){%output%}).call(this);'\
--js $(CORE_FILES)\
--js $(BROWSER_FILES)\
--js $(LIB_FILES)
ls -lh build/libv86-debug.js
build/libv86-debug.mjs: $(CLOSURE) src/*.js lib/*.js src/browser/*.js
mkdir -p build
java -jar $(CLOSURE) \
--js_output_file build/libv86-debug.mjs\
--define=DEBUG=true\
$(CLOSURE_FLAGS)\
$(CLOSURE_READABLE)\
--compilation_level SIMPLE\
--jscomp_off=missingProperties\
--output_wrapper ';let module = {exports:{}}; %output%; export default module.exports.V86; export let {V86, CPU} = module.exports;'\
--js $(CORE_FILES)\
--js $(BROWSER_FILES)\
--js $(LIB_FILES)\
--chunk_output_type=ES_MODULES\
--emit_use_strict=false
ls -lh build/libv86-debug.mjs
src/rust/gen/jit.rs: $(JIT_DEPENDENCIES)
./gen/generate_jit.js --output-dir build/ --table jit
src/rust/gen/jit0f.rs: $(JIT_DEPENDENCIES)
./gen/generate_jit.js --output-dir build/ --table jit0f
src/rust/gen/jit0f38.rs: $(JIT_DEPENDENCIES)
./gen/generate_jit.js --output-dir build/ --table jit0f38
src/rust/gen/jit0f3a.rs: $(JIT_DEPENDENCIES)
./gen/generate_jit.js --output-dir build/ --table jit0f3a
src/rust/gen/jit64.rs: $(JIT64_DEPENDENCIES)
./gen/generate_jit64.js --output-dir build/ --table jit64
src/rust/gen/jit64_0f.rs: $(JIT64_DEPENDENCIES)
./gen/generate_jit64.js --output-dir build/ --table jit64_0f
src/rust/gen/jit64_0f38.rs: $(JIT64_DEPENDENCIES)
./gen/generate_jit64.js --output-dir build/ --table jit64_0f38
src/rust/gen/jit64_0f3a.rs: $(JIT64_DEPENDENCIES)
./gen/generate_jit64.js --output-dir build/ --table jit64_0f3a
src/rust/gen/jit64_wrappers.rs: $(JIT64_DEPENDENCIES)
./gen/generate_jit64.js --output-dir build/ --table jit64_wrappers
src/rust/gen/interpreter.rs: $(INTERPRETER_DEPENDENCIES)
./gen/generate_interpreter.js --output-dir build/ --table interpreter
src/rust/gen/interpreter0f.rs: $(INTERPRETER_DEPENDENCIES)
./gen/generate_interpreter.js --output-dir build/ --table interpreter0f
src/rust/gen/interpreter0f38.rs: $(INTERPRETER_DEPENDENCIES)
./gen/generate_interpreter.js --output-dir build/ --table interpreter0f38
src/rust/gen/interpreter0f3a.rs: $(INTERPRETER_DEPENDENCIES)
./gen/generate_interpreter.js --output-dir build/ --table interpreter0f3a
src/rust/gen/analyzer.rs: $(ANALYZER_DEPENDENCIES)
./gen/generate_analyzer.js --output-dir build/ --table analyzer
src/rust/gen/analyzer0f.rs: $(ANALYZER_DEPENDENCIES)
./gen/generate_analyzer.js --output-dir build/ --table analyzer0f
src/rust/gen/analyzer0f38.rs: $(ANALYZER_DEPENDENCIES)
./gen/generate_analyzer.js --output-dir build/ --table analyzer0f38
src/rust/gen/analyzer0f3a.rs: $(ANALYZER_DEPENDENCIES)
./gen/generate_analyzer.js --output-dir build/ --table analyzer0f3a
build/v86.wasm: $(RUST_FILES) build/softfloat.o build/zstddeclib.o Cargo.toml
mkdir -p build/
-BLOCK_SIZE=K ls -l build/v86.wasm
cargo rustc --release $(CARGO_FLAGS)
cp build/wasm32-unknown-unknown/release/v86_64.wasm build/v86.wasm
if $(WASM_OPT); then wasm-opt -O3 $(WASM_OPT_FEATURES) --strip-debug build/v86.wasm -o build/v86.wasm; fi
BLOCK_SIZE=K ls -l build/v86.wasm
build/v86-debug.wasm: $(RUST_FILES) build/softfloat.o build/zstddeclib.o Cargo.toml
mkdir -p build/
-BLOCK_SIZE=K ls -l build/v86-debug.wasm
cargo rustc $(CARGO_FLAGS)
cp build/wasm32-unknown-unknown/debug/v86_64.wasm build/v86-debug.wasm
BLOCK_SIZE=K ls -l build/v86-debug.wasm
# Guest RAM in a separate 64-bit memory, used for memory sizes above 3 GiB (see src/rust/cpu/guest.rs)
# wasm-opt runs after patch-mem64.mjs, so it can inline the guest memory accessors into their callers
build/v86-mem64.wasm: $(RUST_FILES) build/softfloat.o build/zstddeclib.o Cargo.toml tools/patch-mem64.mjs
mkdir -p build/
cargo rustc --release --features mem64 --target-dir build/mem64 $(CARGO_FLAGS)
cp build/mem64/wasm32-unknown-unknown/release/v86_64.wasm build/v86-mem64.wasm
./tools/patch-mem64.mjs build/v86-mem64.wasm build/v86-mem64.wasm
if $(WASM_OPT); then wasm-opt -O3 $(WASM_OPT_FEATURES) --enable-multimemory --enable-memory64 \
--strip-debug build/v86-mem64.wasm -o build/v86-mem64.wasm; fi
BLOCK_SIZE=K ls -l build/v86-mem64.wasm
build/v86-mem64-debug.wasm: $(RUST_FILES) build/softfloat.o build/zstddeclib.o Cargo.toml tools/patch-mem64.mjs
mkdir -p build/
cargo rustc --features mem64 --target-dir build/mem64 $(CARGO_FLAGS)
cp build/mem64/wasm32-unknown-unknown/debug/v86_64.wasm build/v86-mem64-debug.wasm
./tools/patch-mem64.mjs build/v86-mem64-debug.wasm build/v86-mem64-debug.wasm
BLOCK_SIZE=K ls -l build/v86-mem64-debug.wasm
build/v86-fallback.wasm: $(RUST_FILES) build/softfloat.o build/zstddeclib.o Cargo.toml
mkdir -p build/
cargo rustc --release $(CARGO_FLAGS_SAFE)
cp build/wasm32-unknown-unknown/release/v86_64.wasm build/v86-fallback.wasm || true
debug-with-profiler: $(RUST_FILES) build/softfloat.o build/zstddeclib.o Cargo.toml
mkdir -p build/
cargo rustc --features profiler $(CARGO_FLAGS)
cp build/wasm32-unknown-unknown/debug/v86_64.wasm build/v86-debug.wasm || true
with-profiler: $(RUST_FILES) build/softfloat.o build/zstddeclib.o Cargo.toml
mkdir -p build/
cargo rustc --release --features profiler $(CARGO_FLAGS)
cp build/wasm32-unknown-unknown/release/v86_64.wasm build/v86.wasm || true
watch:
cargo watch -x 'rustc $(CARGO_FLAGS)' -s 'cp build/wasm32-unknown-unknown/debug/v86_64.wasm build/v86-debug.wasm'
build/softfloat.o: lib/softfloat/softfloat.c
mkdir -p build
clang -c -Wall \
--target=wasm32 -O3 -flto -nostdlib -fvisibility=hidden -ffunction-sections -fdata-sections \
-DSOFTFLOAT_FAST_INT64 -DINLINE_LEVEL=5 -DSOFTFLOAT_FAST_DIV32TO16 -DSOFTFLOAT_FAST_DIV64TO32 \
-o build/softfloat.o \
lib/softfloat/softfloat.c
build/zstddeclib.o: lib/zstd/zstddeclib.c
mkdir -p build
clang -c -Wall \
--target=wasm32 -O3 -flto -nostdlib -fvisibility=hidden -ffunction-sections -fdata-sections \
-DZSTDLIB_VISIBILITY="" \
-o build/zstddeclib.o \
lib/zstd/zstddeclib.c
clean:
-rm build/libv86.js
-rm build/libv86.mjs
-rm build/libv86-debug.js
-rm build/libv86-debug.mjs
-rm build/v86_all.js
-rm build/v86.wasm
-rm build/v86-debug.wasm
-rm $(INSTRUCTION_TABLES)
-rm build/*.map
-rm build/*.wast
-rm build/*.o
$(MAKE) -C $(NASM_TEST_DIR) clean
run:
python3 -m http.server 2> /dev/null
tests/devices/virtio_gpu_kernel.bin: tests/devices/virtio_gpu_kernel.asm
nasm -f bin -o $@ $<
PORT ?= 8080
demo-gpu: build/libv86.js build/v86.wasm tests/devices/virtio_gpu_kernel.bin
@echo ""
@echo "virtio-gpu demo (WebGPU): http://localhost:$(PORT)/examples/virtio_gpu.html"
@echo ""
./tools/serve.mjs --port $(PORT)
demo-debian: PORT = 8081
demo-debian: build/libv86.js build/v86.wasm
@test -f images/debian-live/vmlinuz -a -f images/debian-live/initrd.img -a \
-f images/debian-live-testing-amd64-xfce.iso || { \
echo "Missing images. Expected:"; \
echo " images/debian-live-testing-amd64-xfce.iso"; \
echo " images/debian-live/{vmlinuz,initrd.img} (see examples/debian-live.html for extraction)"; \
exit 1; }
@echo ""
@echo "Debian live on virtio-gpu (WebGPU): http://localhost:$(PORT)/examples/virtio_gpu_linux.html?debian"
@echo ""
./tools/serve.mjs --port $(PORT)
update_version:
set -e ;\
COMMIT=`git log --format="%h" -n 1` ;\
DATE=`git log --date="format:%b %e, %Y %H:%m" --format="%cd" -n 1` ;\
SEARCH='<code>Version: <a id="version" href="https://github.com/copy/v86/commits/[a-f0-9]\+">[a-f0-9]\+</a> ([^(]\+)</code>' ;\
REPLACE='<code>Version: <a id="version" href="https://github.com/copy/v86/commits/'$$COMMIT'">'$$COMMIT'</a> ('$$DATE')</code>' ;\
sed -i "s@$$SEARCH@$$REPLACE@g" index.html ;\
SEARCH='<script src="build/v86_all.js?[a-f0-9]\+"></script>' ;\
REPLACE='<script src="build/v86_all.js?'$$COMMIT'"></script>' ;\
sed -i "s@$$SEARCH@$$REPLACE@g" index.html ;\
grep $$COMMIT index.html
$(CLOSURE):
mkdir -p $(CLOSURE_DIR)
# don't upgrade until https://github.com/google/closure-compiler/issues/3972 is fixed
wget -nv -O $(CLOSURE) https://repo1.maven.org/maven2/com/google/javascript/closure-compiler/v20210601/closure-compiler-v20210601.jar
build/integration-test-fs/fs.json: images/buildroot-bzimage68.bin
mkdir -p build/integration-test-fs/flat
cp images/buildroot-bzimage68.bin build/integration-test-fs/bzImage
touch build/integration-test-fs/initrd
cd build/integration-test-fs && tar cfv fs.tar bzImage initrd
./tools/fs2json.py build/integration-test-fs/fs.tar --out build/integration-test-fs/fs.json
./tools/copy-to-sha256.py build/integration-test-fs/fs.tar build/integration-test-fs/flat
rm build/integration-test-fs/fs.tar build/integration-test-fs/bzImage build/integration-test-fs/initrd
tests: build/v86-debug.wasm build/integration-test-fs/fs.json
LOG_LEVEL=3 ./tests/full/run.js
tests-release: build/libv86.js build/v86.wasm build/integration-test-fs/fs.json
TEST_RELEASE_BUILD=1 ./tests/full/run.js
nasmtests: build/v86-debug.wasm
$(NASM_TEST_DIR)/create_tests.js
$(NASM_TEST_DIR)/gen_fixtures.js
$(NASM_TEST_DIR)/run.js
nasmtests-force-jit: build/v86-debug.wasm
$(NASM_TEST_DIR)/create_tests.js
$(NASM_TEST_DIR)/gen_fixtures.js
$(NASM_TEST_DIR)/run.js --force-jit
fuzz-tests: build/v86-debug.wasm
./tests/fuzz/run.js
longmode-tests: build/v86-debug.wasm
./tests/longmode/run.js
JIT_THRESHOLD=1 ./tests/longmode/run.js
JIT_THRESHOLD=1 JIT64_CHAINING=0 ./tests/longmode/run.js
./tests/longmode/multiboot64.js
./tests/longmode/selfipi.js
JIT64_CHAINING=0 ./tests/longmode/selfipi.js
jitpagingtests: build/v86-debug.wasm
$(MAKE) -C tests/jit-paging test-jit test-jit-smc
./tests/jit-paging/run.js
./tests/jit-paging/run-smc.js
qemutests: build/v86-debug.wasm
$(MAKE) -C tests/qemu test-i386
LOG_LEVEL=3 ./tests/qemu/run.js build/qemu-test-result
./tests/qemu/run-qemu.js > build/qemu-test-reference
diff build/qemu-test-result build/qemu-test-reference
qemutests-release: build/libv86.mjs build/v86.wasm
$(MAKE) -C tests/qemu test-i386
TEST_RELEASE_BUILD=1 time ./tests/qemu/run.js build/qemu-test-result
./tests/qemu/run-qemu.js > build/qemu-test-reference
diff build/qemu-test-result build/qemu-test-reference
kvm-unit-test: build/v86-debug.wasm
tests/kvm-unit-tests/build.sh
tests/kvm-unit-tests/run.mjs tests/kvm-unit-tests/x86/taskswitch.flat
tests/kvm-unit-tests/run.mjs tests/kvm-unit-tests/x86/taskswitch2.flat
tests/kvm-unit-tests/run.mjs tests/kvm-unit-tests/x86/realmode.flat
tests/kvm-unit-tests/run.mjs tests/kvm-unit-tests/x86/nx.flat
tests/kvm-unit-tests/run.mjs tests/kvm-unit-tests/x86/pat.flat
kvm-unit-test-release: build/libv86.mjs build/v86.wasm
tests/kvm-unit-tests/build.sh
TEST_RELEASE_BUILD=1 tests/kvm-unit-tests/run.mjs tests/kvm-unit-tests/x86/taskswitch.flat
TEST_RELEASE_BUILD=1 tests/kvm-unit-tests/run.mjs tests/kvm-unit-tests/x86/taskswitch2.flat
TEST_RELEASE_BUILD=1 tests/kvm-unit-tests/run.mjs tests/kvm-unit-tests/x86/realmode.flat
TEST_RELEASE_BUILD=1 tests/kvm-unit-tests/run.mjs tests/kvm-unit-tests/x86/nx.flat
TEST_RELEASE_BUILD=1 tests/kvm-unit-tests/run.mjs tests/kvm-unit-tests/x86/pat.flat
expect-tests: build/v86-debug.wasm build/libwabt.cjs
make -C tests/expect/tests
./tests/expect/run.js
devices-test: build/v86-debug.wasm
./tests/devices/virtio_9p.js
./tests/devices/virtio_console.js
./tests/devices/virtio_gpu.js
./tests/devices/fetch_network.js
USE_VIRTIO=1 ./tests/devices/fetch_network.js
./tests/devices/fetch_network_post.js
./tests/devices/wisp_network.js
./tests/devices/virtio_balloon.js
rust-test: $(RUST_FILES)
env RUSTFLAGS="-D warnings" RUST_BACKTRACE=full RUST_TEST_THREADS=1 cargo test -- --nocapture
./tests/rust/verify-wasmgen-dummy-output.js
rust-test-intensive:
QUICKCHECK_TESTS=100000000 make rust-test
# Freestanding 32-bit guest payload used by tests/api/2g-mem.js. Compiles
# without cargo (needs `rustup target add i686-unknown-linux-musl`); the stock
# musl target pulls a crt that conflicts with the custom _start, so link the
# object ourselves with the bundled rust-lld.
# memhog: 32-bit payload of tests/api/2g-mem.js; memhog64: the same for 64-bit kernels
tests/api/memhog: MEMHOG_TARGET=i686-unknown-linux-musl
tests/api/memhog64: MEMHOG_TARGET=x86_64-unknown-linux-musl
tests/api/memhog tests/api/memhog64: tests/api/memhog.rs
rustc --edition 2021 -O --target $(MEMHOG_TARGET) -C panic=abort --emit=obj -o $@.o $<
SYSROOT=$$(rustc --print sysroot) && \
RUSTLIB=$$SYSROOT/lib/rustlib/$(MEMHOG_TARGET)/lib && \
$$SYSROOT/lib/rustlib/$$(rustc -vV | sed -n 's/^host: //p')/bin/rust-lld -flavor gnu -static \
-o $@ $@.o $$RUSTLIB/libcore-*.rlib $$RUSTLIB/libcompiler_builtins-*.rlib
rm $@.o
api-tests: build/v86-debug.wasm
./tests/api/clean-shutdown.js
./tests/api/state.js
./tests/api/reset.js
./tests/api/floppy.js
./tests/api/parallel.js
./tests/api/cdrom-insert-eject.js
./tests/api/iso9660.js
./tests/api/serial.js
./tests/api/reboot.js
#./tests/api/reboot-buildroot.js # https://github.com/copy/v86/issues/636
./tests/api/pic.js
all-tests: eslint kvm-unit-test qemutests qemutests-release jitpagingtests api-tests nasmtests nasmtests-force-jit fuzz-tests rust-test tests expect-tests
# Skipping:
# - devices-test (hangs)
eslint:
eslint src tests gen lib examples tools
rustfmt: $(RUST_FILES)
cargo fmt --all -- --check --config fn_single_line=true,control_brace_style=ClosingNextLine
build/capstone-x86.min.js:
mkdir -p build
wget -nv -P build https://github.com/AlexAltea/capstone.js/releases/download/v3.0.5-rc1/capstone-x86.min.js
build/libwabt.cjs:
mkdir -p build
wget -nv -P build https://github.com/WebAssembly/wabt/archive/1.0.6.zip
unzip -j -d build/ build/1.0.6.zip wabt-1.0.6/demo/libwabt.js
mv build/libwabt.js build/libwabt.cjs
rm build/1.0.6.zip
build/xterm.js:
curl https://cdn.jsdelivr.net/npm/xterm@5.2.1/lib/xterm.min.js > build/xterm.js
curl https://cdn.jsdelivr.net/npm/xterm@5.2.1/lib/xterm.js.map > build/xterm.js.map
curl https://cdn.jsdelivr.net/npm/xterm@5.2.1/css/xterm.css > build/xterm.css
update-package-json-version:
git describe --tags --exclude latest | sed 's/-/./' | tr - + | tee build/version
jq --arg version "$$(cat build/version)" '.version = $$version' package.json > package.json.tmp
mv package.json.tmp package.json
doc:
set -e ;\
COMMIT=`git log --format="%h" -n 1` ;\
npx typedoc --readme none --customFooterHtml "Commit: <a href='https://github.com/copy/v86/commits/$$COMMIT'><code>$$COMMIT</code></a>" --out ./docs/api ./v86.d.ts
denodoc:
deno doc --html --name="v86 API" --output=./docs/api ./v86.d.ts
.PHONY: tests