-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.sh
More file actions
executable file
·45 lines (33 loc) · 1.18 KB
/
Copy pathbuild.sh
File metadata and controls
executable file
·45 lines (33 loc) · 1.18 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
#!/bin/sh
KERNEL="src/kernel/kernel.c"
KERNEL_CC_OUT="kernel.o"
KERNEL_TARGET="data/kernel.bin"
KERNEL_LINKER="src/kernel/kernel.ld"
SOURCE="main.c"
TARGET="BOOTX64.EFI"
DISK_IMG_FOLDER="write_gpt"
DISK_IMG_PGM="write_gpt"
QEMU="./scripts/qemu.sh"
find . -name '*.c' -or -name '*.h' -or -name '*.sh' | xargs wc -l | grep 'total' | awk '{ SUM += $1; print $1} END { print "Total text lines",SUM }'
BOOT_CC="x86_64-w64-mingw32-gcc -Wl,--subsystem,10 -e efi_main -w"
KERNEL_CC="x86_64-w64-mingw32-gcc -Wl,--subsystem,10 -e kernel_main"
CFLAGS="-std=c17 -Wall -Wextra -Wpedantic -mno-red-zone -ffreestanding -nostdlib -fno-stack-protector -mno-stack-arg-probe"
if [ ! -f "$DISK_IMG_FOLDER/$DISK_IMG_PGM" ]; then
(cd "$DISK_IMG_FOLDER" && make)
fi
$KERNEL_CC $CFLAGS -o "$KERNEL_CC_OUT" "$KERNEL"
x86_64-w64-mingw32-objcopy -O binary "$KERNEL_CC_OUT" "$KERNEL_TARGET"
$BOOT_CC $CFLAGS -o "$TARGET" "$SOURCE"
cp "$TARGET" "$DISK_IMG_FOLDER"
cd "$DISK_IMG_FOLDER"
./"$DISK_IMG_PGM" -v -ae / ../data/kiwi.bmp -ad ../data/test.txt ../"$KERNEL_TARGET"
cd ..
$QEMU
cd "$DISK_IMG_FOLDER"
# clean up
rm -f "$TARGET"
rm -f "FILE.TXT"
cd ..
rm -f "$TARGET"
rm -f "$KERNEL_TARGET"
rm -f "$KERNEL_CC_OUT"