Refactor
This commit is contained in:
20
justfile
20
justfile
@@ -1,18 +1,20 @@
|
||||
release := ""
|
||||
cargo_flags := if release != "" { "--release" } else { "" }
|
||||
bin_path := if release != "" { "target/riscv64/release" } else { "target/riscv64/debug" }
|
||||
|
||||
default: run
|
||||
|
||||
mount_filesystem:
|
||||
# Add some permissions to be able to do next operations without sudo
|
||||
@mountpoint -q mnt || sudo mount -o umask=0022,gid=$(id -g $USER),uid=$(id -u $USER) disk.img mnt
|
||||
@# Add some permissions to be able to do next operations without sudo
|
||||
mountpoint -q mnt || sudo mount -o umask=0022,gid=$(id -g $USER),uid=$(id -u $USER) disk.img mnt
|
||||
|
||||
sync_filesystem:
|
||||
sync
|
||||
|
||||
build_user_prog prog:
|
||||
RUSTFLAGS="-C relocation-model=pic -C link-arg=-Tuser.ld" cargo b {{ cargo_flags }} --package {{ prog }}
|
||||
riscv64-elf-objcopy -O binary {{ "target/riscv64/debug" / prog }} {{ "mnt/usr/bin" / prog }}
|
||||
# cp {{ bin_path / prog }} {{ "mnt/usr/bin" / prog }}
|
||||
riscv64-elf-objcopy -O binary {{ bin_path / prog }} {{ "mnt/usr/bin" / prog }}
|
||||
|
||||
build: mount_filesystem (map_dir "user" "build_user_prog")
|
||||
cargo b {{ cargo_flags }}
|
||||
@@ -25,3 +27,15 @@ map_dir dir recipe:
|
||||
@for file in `ls {{ dir }}`; do \
|
||||
just cargo_flags="{{ cargo_flags }}" {{ recipe }} $file ; \
|
||||
done
|
||||
|
||||
qemu := "qemu-system-riscv64 -machine virt -device bochs-display -bios none -m 512M -device loader,file=disk.img,addr=0x90000000"
|
||||
|
||||
gdb: build
|
||||
{{ qemu }} -s -S -kernel {{ bin_path / "kernel-rust" }}&
|
||||
gf2
|
||||
|
||||
runner args:
|
||||
{{ qemu }} -kernel {{ args }}
|
||||
|
||||
clean:
|
||||
cargo clean
|
||||
|
||||
Reference in New Issue
Block a user