-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.sh
More file actions
executable file
·123 lines (103 loc) · 2.76 KB
/
build.sh
File metadata and controls
executable file
·123 lines (103 loc) · 2.76 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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
#!/bin/bash
set -e
# set -x
SCRIPT_PATH=`realpath "$0"`
SCRIPT_DIR=`dirname "$SCRIPT_PATH"`
_print() {
echo "[DEBUG] $@"
}
build() {
if [ ! -d "$SCRIPT_DIR/deps/stivale" ]; then
_print "Fetching stivale"
git clone -b master https://github.com/stivale/stivale.git deps/stivale
fi
if [ ! -d "$SCRIPT_DIR/deps/limine" ]; then
_print "Fetching limine"
git clone -b v3.0-branch-binary https://github.com/limine-bootloader/limine.git deps/limine
make -C deps/limine
fi
if [ ! -d "$SCRIPT_DIR/build" ]; then
_print "Creating build folder"
mkdir -p "$SCRIPT_DIR/build"
fi
cd "$SCRIPT_DIR/build"
cmake --fresh .. -G "Unix Makefiles" -DARCH=x86_64 #--debug-output
time make
}
clean() {
if [ -d "$SCRIPT_DIR/build" ]; then
_print "Removing build folder"
rm -rf "$SCRIPT_DIR/build"
fi
if [ -d "$SCRIPT_DIR/iso_root" ]; then
_print "Removing ISO folder"
rm -rf "$SCRIPT_DIR/iso_root"
fi
if [ -f "$SCRIPT_DIR/barebones.iso" ]; then
_print "Removing barebones.iso"
rm -rf "$SCRIPT_DIR/barebones.iso"
fi
}
clean_deps() {
if [ -d "$SCRIPT_DIR/deps/stivale" ]; then
_print "Cleaning stivale"
rm -rf "$SCRIPT_DIR/deps/stivale"
fi
if [ -d "$SCRIPT_DIR/deps/limine" ]; then
_print "Cleaning limine"
rm -rf "$SCRIPT_DIR/deps/limine"
fi
}
iso() {
_print "Creating ISO"
rm -rf "$SCRIPT_DIR/iso_root"
mkdir -p "$SCRIPT_DIR/iso_root"
cp "$SCRIPT_DIR/build/kernel.elf" "$SCRIPT_DIR/limine.cfg" "$SCRIPT_DIR/deps/limine/limine.sys" "$SCRIPT_DIR/deps/limine/limine-cd.bin" "$SCRIPT_DIR/deps/limine/limine-cd-efi.bin" "$SCRIPT_DIR/iso_root/"
xorriso -as mkisofs -b limine-cd.bin \
-no-emul-boot -boot-load-size 4 -boot-info-table \
--efi-boot limine-cd-efi.bin \
-efi-boot-part --efi-boot-image --protective-msdos-label \
"$SCRIPT_DIR/iso_root" -o "$SCRIPT_DIR/barebones.iso"
"$SCRIPT_DIR/deps/limine/limine-deploy" "$SCRIPT_DIR/barebones.iso"
rm -rf "$SCRIPT_DIR/iso_root"
}
run() {
_print "Run in QEMU"
qemu-system-x86_64 -m 2G -cdrom "$SCRIPT_DIR/barebones.iso"
}
__exit()
{
cd "$SCRIPT_DIR" || return
}
trap __exit EXIT
if [ "$#" == 0 ]; then
build
else
while test $# -gt 0; do
case "$1" in
clean)
clean
;;
fullclean)
clean
clean_deps
;;
build)
build
;;
iso)
iso
;;
run)
run
;;
all)
clean
build
iso
run
;;
esac
shift
done
fi