11CARGO? =cargo
2- MULTIBOOT2_TARGET? =multiboot2_target
32BUILD_TYPE? =release
4- DOCKER_IMAGE =adamschwalm/hypervisor-build:10
3+ DOCKER_IMAGE =adamschwalm/hypervisor-build:12
54
6- multiboot2_binary = target/$( MULTIBOOT2_TARGET ) /$(BUILD_TYPE ) /mythril_multiboot2
7- mythril_src = $(shell find mythril_ * -type f -name '* .rs' -or -name '* .S' -or -name '* .ld' \
5+ mythril_binary = mythril/ target/mythril_target /$(BUILD_TYPE ) /mythril
6+ mythril_src = $(shell find mythril * -type f -name '* .rs' -or -name '* .S' -or -name '* .ld' \
87 -name 'Cargo.toml')
98kernel = linux/arch/x86_64/boot/bzImage
109seabios = seabios/out/bios.bin
@@ -16,22 +15,24 @@ ifneq (,$(filter qemu%, $(firstword $(MAKECMDGOALS))))
1615 $(eval $(QEMU_EXTRA ) :;@:)
1716endif
1817
18+ CARGO_MANIFEST? =--manifest-path mythril/Cargo.toml
19+
1920ifeq ($(BUILD_TYPE ) , release)
20- CARGO_FLAGS := --release
21+ CARGO_BUILD_FLAGS := --release
2122endif
2223
2324.PHONY : all
24- all : multiboot2 $(seabios ) $(kernel )
25+ all : mythril $(seabios ) $(kernel )
2526
26- .PHONY : multiboot2
27- multiboot2 : $(multiboot2_binary )
27+ .PHONY : mythril
28+ mythril : $(mythril_binary )
2829
29- .PHONY : multiboot2 -debug
30- multiboot2 -debug : BUILD_TYPE=debug
31- multiboot2 -debug : $(multiboot2_binary )
30+ .PHONY : mythril -debug
31+ mythril -debug : BUILD_TYPE=debug
32+ mythril -debug : $(mythril_binary )
3233
3334docker-% :
34- docker run --rm -w $(CURDIR ) -v $(CURDIR ) :$(CURDIR ) \
35+ docker run --privileged -it -- rm -w $(CURDIR ) -v $(CURDIR ) :$(CURDIR ) \
3536 -u $(shell id -u) :$(shell id -g) $(DOCKER_IMAGE ) \
3637 /bin/bash -c ' $(MAKE) $*'
3738
@@ -44,35 +45,38 @@ $(kernel):
4445 make -C linux bzImage
4546
4647.PHONY : qemu
47- qemu : multiboot2 $(seabios ) $(kernel )
48- ./scripts/mythril-run.sh $(multiboot2_binary ) $(QEMU_EXTRA )
48+ qemu : mythril $(seabios ) $(kernel )
49+ ./scripts/mythril-run.sh $(mythril_binary ) $(QEMU_EXTRA )
4950
5051.PHONY : qemu-debug
51- qemu-debug : multiboot2 -debug $(seabios ) $(kernel )
52- ./scripts/mythril-run.sh $(multiboot2_binary ) \
52+ qemu-debug : mythril -debug $(seabios ) $(kernel )
53+ ./scripts/mythril-run.sh $(mythril_binary ) \
5354 -gdb tcp::1234 -S $(QEMU_EXTRA )
5455
55- $(multiboot2_binary ) : $(mythril_src )
56- $(CARGO ) build $(CARGO_FLAGS ) -Z build-std=core,alloc \
57- --target mythril_multiboot2/$(MULTIBOOT2_TARGET ) .json \
58- --manifest-path mythril_multiboot2/Cargo.toml
56+ $(mythril_binary ) : $(mythril_src )
57+ $(CARGO ) build $(CARGO_BUILD_FLAGS ) $(CARGO_MANIFEST ) \
58+ -Z build-std=core,alloc \
59+ --target mythril/mythril_target.json \
60+
61+ .PHONY : check-fmt
62+ check-fmt :
63+ $(CARGO ) fmt $(CARGO_MANIFEST ) --all -- --check
5964
6065.PHONY : fmt
6166fmt :
62- $(CARGO ) fmt --all -- --check
67+ $(CARGO ) fmt $( CARGO_MANIFEST ) --all
6368
6469.PHONY : test_core
65- test_core :
66- $(CARGO ) test \
67- --manifest-path mythril_core/Cargo.toml \
68- --lib
70+ test_common :
71+ $(CARGO ) test $(CARGO_MANIFEST ) --lib \
72+ --features=test \
6973
7074.PHONY : test
71- test : test_core
75+ test : test_common
7276
7377.PHONY : clean
7478clean :
75- $(CARGO ) clean
79+ $(CARGO ) clean $( CARGO_MANIFEST )
7680 make -C seabios clean
7781 make -C linux clean
7882
@@ -89,7 +93,8 @@ $(git_hooks): $(git_hooks_src)
8993help :
9094 @echo " Make Targets:"
9195 @echo " all build everything to run mythril, but do not start qemu"
92- @echo " fmt run rustfmt"
96+ @echo " check-fmt run cargo fmt --check"
97+ @echo " fmt run cargo fmt"
9398 @echo " qemu run mythril in a VM"
9499 @echo " qemu-debug run mythril in a VM, but halt for a debugger connection"
95100 @echo " test run the mythril tests"
0 commit comments