-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
97 lines (82 loc) · 3.68 KB
/
Copy pathMakefile
File metadata and controls
97 lines (82 loc) · 3.68 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
.PHONY: run clean repro debug release qemu
TARGET:=debug
SOURCES=Cargo.toml $(wildcard src/*.rs) $(wildcard resources/*)
DIFFOSCOPE := $(shell command -v diffoscope 2> /dev/null)
debug: target/x86_64-unknown-uefi/debug/uefi_hotkey_app.efi
@ls -lh $<
# Delete binaries to force a partial rebuild.
# If you actually want a clean build, run `cargo clean`.
clean:
rm -f target/x86_64-unknown-uefi/debug/uefi_hotkey_*.efi
rm -f target/x86_64-unknown-uefi/release/uefi_hotkey_*.efi
# Seems this is necessary sometimes, otherwise the linker timestamp won't get updated
rm -f target/x86_64-unknown-uefi/debug/deps/uefi_hotkey_*-*.efi
rm -f target/x86_64-unknown-uefi/release/deps/uefi_hotkey_*-*.efi
qemu: $(SOURCES)
cargo build --target x86_64-unknown-uefi --features qemu --bin uefi_hotkey_app
target/x86_64-unknown-uefi/debug/uefi_hotkey_app.efi: $(SOURCES)
cargo build --target x86_64-unknown-uefi --bin uefi_hotkey_app
target/x86_64-unknown-uefi/debug/uefi_hotkey_driver.efi: $(SOURCES)
cargo build --target x86_64-unknown-uefi --bin uefi_hotkey_driver
release: target/x86_64-unknown-uefi/release/uefi_hotkey_driver.efi target/x86_64-unknown-uefi/release/uefi_hotkey_app.efi
@ls -lh $^
@sha256sum $^
target/x86_64-unknown-uefi/release/uefi_hotkey_app.efi: $(SOURCES)
cargo build --target x86_64-unknown-uefi --release --bin uefi_hotkey_app
target/x86_64-unknown-uefi/release/uefi_hotkey_driver.efi: $(SOURCES)
cargo build --target x86_64-unknown-uefi --release --bin uefi_hotkey_driver
clippy:
cargo clippy --target x86_64-unknown-uefi
# Automatically get OVMF from system path
OVMF_CODE.fd:
cp /usr/share/OVMF/OVMF_CODE.fd .
OVMF_VARS.fd:
cp /usr/share/OVMF/OVMF_VARS.fd .
run: OVMF_CODE.fd OVMF_VARS.fd target/x86_64-unknown-uefi/$(TARGET)/uefi_hotkey_app.efi target/x86_64-unknown-uefi/$(TARGET)/uefi_hotkey_driver.efi
mkdir -p esp/efi/boot
cp target/x86_64-unknown-uefi/$(TARGET)/uefi_hotkey_app.efi esp/
cp target/x86_64-unknown-uefi/$(TARGET)/uefi_hotkey_driver.efi esp/
sudo qemu-system-x86_64 \
-enable-kvm \
-M q35 \
-m 1024 \
-net none \
-serial stdio \
-debugcon file:debug.log -global isa-debugcon.iobase=0x402 \
-usb -device usb-hub\
-device qemu-xhci \
-device usb-host,vendorid=0x32AC,productid=0x0012 \
-device usb-host,vendorid=0x32AC,productid=0x0013 \
-device usb-host,vendorid=0x32AC,productid=0x0014 \
-device usb-host,vendorid=0x32AC,productid=0x0018 \
-device usb-host,vendorid=0x32AC,productid=0x0019 \
-drive if=pflash,format=raw,readonly=on,file=ovmf/OVMF_CODE.fd \
-drive if=pflash,format=raw,readonly=off,file=ovmf/OVMF_VARS.fd \
-drive format=raw,file=fat:rw:esp
# -device usb-host,vendorid=0x32AC \
# -device usb-host,bus=ehci.0,hostbus=3,hostport=2
# Build release build twice and check if the binaries are the same
# Basic reproducibility check only.
repro:
@$(MAKE) -s clean
@$(MAKE) -s target/x86_64-unknown-uefi/release/uefi_hotkey_driver.efi
@cp target/x86_64-unknown-uefi/release/uefi_hotkey_driver.efi uefi_hotkey_driver_first.efi
@sleep 2 # Wait a bit to make sure timestamps are different
@$(MAKE) -s clean
@cargo clean
@$(MAKE) -s target/x86_64-unknown-uefi/release/uefi_hotkey_driver.efi
mv uefi_hotkey_driver_first.efi target/x86_64-unknown-uefi/release/
@echo ""
@echo "------------------"
@echo Compare both builds
sha256sum target/x86_64-unknown-uefi/release/uefi_hotkey_driver*.efi
@echo ""
@echo "------------------"
@echo Check embedded strings for absolute paths to the home directory
strings target/x86_64-unknown-uefi/release/uefi_hotkey_driver.efi | grep 'home'
@echo ""
ifdef DIFFOSCOPE
diffoscope target/x86_64-unknown-uefi/release/uefi_hotkey_driver*.efi
else
cmp target/x86_64-unknown-uefi/release/uefi_hotkey_driver*.efi
endif