Cleans library directory
This commit is contained in:
54
justfile
54
justfile
@@ -2,39 +2,39 @@ release := ""
|
||||
qemu_flags := ""
|
||||
cargo_flags := "" + if release != "" { "--release" } else { "" }
|
||||
bin_path := if release != "" { "target/riscv64/release" } else { "target/riscv64/debug" }
|
||||
GDB := "gf2"
|
||||
|
||||
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
|
||||
|
||||
sync_filesystem:
|
||||
sync
|
||||
mountpoint -q mnt || sudo mount -o umask=0022,gid=$(id -g),uid=$(id -u) disk.img mnt
|
||||
|
||||
update-std:
|
||||
@cd library/std && just update-std
|
||||
@cd library/std && {{ just_executable() }} update-std
|
||||
|
||||
build-sysroot:
|
||||
@cd library/std && just build-sysroot
|
||||
@cd library/std && {{ just_executable() }} build-sysroot
|
||||
|
||||
build_user_prog prog:
|
||||
RUSTFLAGS="-C relocation-model=pic -C link-arg=-pie --sysroot {{ justfile_directory() / "sysroot" }}" cargo b {{ cargo_flags }} --package {{ prog }}
|
||||
riscv64-elf-strip {{ bin_path / prog }}
|
||||
cp {{ bin_path / prog }} {{ "mnt/usr/bin" / prog }}
|
||||
RUSTFLAGS="-Clink-arg=-Tuser.ld -C relocation-model=pic -C link-arg=-pie --sysroot {{ justfile_directory() / "sysroot" }}" \
|
||||
cargo b {{ cargo_flags }} --package {{ prog }}
|
||||
cp {{ bin_path / prog }} {{ bin_path / prog + "-stripped" }}
|
||||
if command -v riscv64-elf-strip >/dev/null 2>&1; then \
|
||||
riscv64-elf-strip {{ bin_path / prog + "-stripped" }}; \
|
||||
fi
|
||||
cp {{ bin_path / prog + "-stripped" }} {{ "mnt/usr/bin" / prog }}
|
||||
|
||||
build: mount_filesystem (map_dir "user" f"just release=\"{{release}}\" cargo_flags=\"{{cargo_flags}}\" build_user_prog")
|
||||
build: mount_filesystem
|
||||
@for file in `ls user`; do \
|
||||
{{ just_executable() }} release="{{ release }}" cargo_flags="{{ cargo_flags }}" build_user_prog $file ; \
|
||||
done
|
||||
RUSTFLAGS="-Clink-arg=-Tilm.ld --sysroot {{ justfile_directory() / "sysroot" }}" cargo b {{ cargo_flags }}
|
||||
just sync_filesystem
|
||||
sync
|
||||
|
||||
run: build (runner f"{{bin_path / "kernel-rust"}}")
|
||||
|
||||
map_dir dir recipe:
|
||||
@for file in `ls {{ dir }}`; do \
|
||||
{{ recipe }} $file ; \
|
||||
done
|
||||
|
||||
qemu := f"qemu-system-riscv64 \
|
||||
QEMU := f"qemu-system-riscv64 \
|
||||
-machine virt \
|
||||
-serial mon:stdio \
|
||||
-device bochs-display \
|
||||
@@ -47,17 +47,25 @@ qemu := f"qemu-system-riscv64 \
|
||||
# -d guest_errors,unimp,int"
|
||||
|
||||
perf: build
|
||||
{{ qemu }} -perfmap -kernel {{ bin_path / "kernel-rust" }}&
|
||||
{{ QEMU }} -perfmap -kernel {{ bin_path / "kernel-rust" }}&
|
||||
perf record --output=/tmp/perf.data --call-graph=dwarf -F 999 -p $(pidof qemu-system-riscv64) -- sleep 20; exit 0
|
||||
cd /tmp && hotspot perf.data
|
||||
|
||||
gdb: build
|
||||
{{ qemu }} -s -S -kernel {{ bin_path / "kernel-rust" }}&
|
||||
gf2
|
||||
dbg: build
|
||||
{{ QEMU }} -s -S -kernel {{ bin_path / "kernel-rust" }}&
|
||||
{{ GDB }}
|
||||
|
||||
dbg-user prog addr: build
|
||||
{{ QEMU }} -s -S -kernel {{ bin_path / "kernel-rust" }}&
|
||||
{{ GDB }} -nx \
|
||||
-ex "target remote localhost:1234" \
|
||||
-ex "break *{{ addr }}" \
|
||||
-ex "add-symbol-file target/riscv64/debug/{{ prog }} {{ addr }}" \
|
||||
-ex "c"
|
||||
|
||||
runner args:
|
||||
{{ qemu }} -kernel {{ args }}
|
||||
{{ QEMU }} -kernel {{ args }}
|
||||
|
||||
clean:
|
||||
cd library && just clean
|
||||
cd library && {{ just_executable() }} clean
|
||||
cargo clean
|
||||
|
||||
Reference in New Issue
Block a user