-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
48 lines (38 loc) · 1.73 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
# Flags for the binary and all transitive compilation units (such as libcore).
ROOT = $(PWD)
BUILD_DIR = $(ROOT)/build
CARGO_BUILD_STD_FLAGS = -Z build-std=core,alloc,compiler_builtins -Z build-std-features=compiler-builtins-mem
PHIPSBOOT_SRC = $(ROOT)/phipsboot
PHIPSBOOT_RUSTFLAGS = -C target-cpu=x86-64
PHIPSBOOT_RUST_TARGET = x86_64-unknown-none-static
PHIPSBOOT_RUST_TARGET_FILE = $(PHIPSBOOT_SRC)/bin/$(PHIPSBOOT_RUST_TARGET).json
PHIPSBOOT_CARGO_FLAGS = --verbose --target $(PHIPSBOOT_RUST_TARGET_FILE) $(CARGO_BUILD_STD_FLAGS)
PHIPSBOOT_CARGO_ARTIFACT = $(PHIPSBOOT_SRC)/target/$(PHIPSBOOT_RUST_TARGET)/release/phipsboot
.PHONY: default
default: phipsboot
.PHONY: build_dir
build_dir:
mkdir -p ./build
.PHONY: phipsboot
phipsboot: build_dir phipsboot_cargo
objcopy -O elf32-i386 $(PHIPSBOOT_CARGO_ARTIFACT) $(BUILD_DIR)/phipsboot.elf32
cp $(PHIPSBOOT_CARGO_ARTIFACT) $(BUILD_DIR)/phipsboot.elf64
.PHONY: phipsboot_cargo
phipsboot_cargo:
cd phipsboot && RUSTFLAGS="$(PHIPSBOOT_RUSTFLAGS)" cargo build $(PHIPSBOOT_CARGO_FLAGS)
cd phipsboot && RUSTFLAGS="$(PHIPSBOOT_RUSTFLAGS)" cargo build $(PHIPSBOOT_CARGO_FLAGS) --release
grub-file --is-x86-multiboot "$(PHIPSBOOT_CARGO_ARTIFACT)"
grub-file --is-x86-multiboot2 "$(PHIPSBOOT_CARGO_ARTIFACT)"
grub-file --is-x86-xen-dom0 "$(PHIPSBOOT_CARGO_ARTIFACT)" # Xen PVH
.PHONY: test
test:
cd phipsboot && cargo nextest run --lib
.PHONY: integration-test
integration-test: phipsboot
cd integration-test && ./build_bootable_img.sh --phipsboot="$(BUILD_DIR)/phipsboot.elf64" --out-path="$(BUILD_DIR)"
cd integration-test && ./run_iso_in_qemu.sh --iso="$(BUILD_DIR)/phipsboot.grub-mb2.iso"
# TODO add targets for qemu and cloud hypervisor
.PHONY: clean
clean:
cd phipsboot && cargo clean
rm -rf ./build