1
+ #! /bin/bash
2
+
3
+ source func.sh
4
+
1
5
# Display the welcome
2
6
tis=$( date +%s%N)
3
7
echo " ________ __ ______ "
@@ -11,140 +15,36 @@ echo -e " A \e[0;35mMain Menu\e[0;34m aka \e[0;35mcorigan01\e[0;34m p
11
15
echo
12
16
13
17
14
- addToBuild () {
15
- # add one to the build number
16
- echo " ---------------- ADDING TO BUILD ----------------"
17
- awk ' {if ($1 == $1) print $1, $2, $3 + 1;}' Kernal/BUILD.h > temp.txt
18
- cp temp.txt Kernal/BUILD.h
19
- rm temp.txt
20
- printf " %s" " $( < Kernal/BUILD.h) "
21
- echo
22
- }
23
-
24
- addToBuild &
25
-
26
-
27
-
28
- # clean up files
29
- clean () {
30
- echo -e " \e[0;33m---------------- CLEANED UP FILES ---------------"
31
- rm -r isodir & > /dev/null
32
- rm FluxedOS.* & > /dev/null
33
- rm G++OUTPUT.txt & > /dev/null
34
- rm $( find ./ -type f -iregex ' .*/.*\.\(gch\)$' ) & > /dev/null
35
- rm * .o & > /dev/null
36
- rm boot/boot.o & > /dev/null
37
- rm -r obj & > /dev/null
38
-
39
- }
40
18
41
- # assemble boot.s file
42
- compilea () {
43
- OUTPUT=" $1 "
44
19
45
- if nasm -f elf $OUTPUT .s -o boot.o & > " log/A++OUTPUT.txt" ; then
46
- echo -e " $OUTPUT \t\t\t\t \e[0;32mDONE\e[0;34m"
47
- else
20
+ addToBuild
48
21
49
- # ouput the errors
50
- echo -e " \e[0;31m ------------------ ASM FAILED! ------------------ "
51
- printf " %s" " $( < log/A++OUTPUT.txt) "
52
- echo " "
53
- echo -e " \e[0;31m ------------------- ASM DONE! ------------------- "
54
- # rm temp.txt
55
22
56
- clean
57
23
58
- exit
59
- fi
60
24
61
- }
62
25
26
+ # compile .c , .cpp , and .h file
27
+ mkdir obj & > /dev/null
63
28
64
29
echo " ---------------- BUILDING ASM -------------------"
65
30
# Compile the asm files
66
- compilea boot/boot
67
-
68
- compileProc () {
69
- OUTPUT=" $1 "
70
- OUTNAME=" $2 "
71
-
72
- mkdir log & > /dev/null
73
-
74
- if g++ -m32 -elf_i386 -nostdinc -nostartfiles -lgcc_s $OUTPUT -o " $FILES .exc" -ffreestanding -O2 -Wall -Wextra -fdiagnostics-color=always -lstdc++ & > " log/G++OUTPUT.txt" ; then
75
- printf " %-40s%-4s\e[0;32mDONE\e[0;34m\n" " ${OUTPUT: 0: 40} " " "
76
- else
77
-
78
- # ouput the errors
79
- echo -e " \e[0;31m ------------------ CPP FAILED! ------------------ "
80
- printf " %s" " $( < log/G++OUTPUT.txt) "
81
- echo " "
82
- echo -e " \e[0;31m ------------------- CPP DONE! ------------------- "
83
- # rm temp.txt
84
-
85
- clean
86
-
87
- exit
88
- fi
89
-
90
- mv " $FILES .exc" ../../bin/
91
- }
92
-
93
- # compile the given file with g++
94
- compilec_ () {
95
- OUTPUT=" $1 "
96
-
97
- mkdir log & > /dev/null
98
- local ts=$( date +%s%N)
99
-
100
- if gcc -m32 -elf_i386 -Wall -O -fstrength-reduce -fomit-frame-pointer -finline-functions -nostdinc -fno-builtin -c $OUTPUT -fdiagnostics-color=always & > " log/G++COUTPUT.txt" ; then
101
- local PFD=$(( ($(date +% s% N) - $ts )/ 1000000 ))
102
- printf " %-40s%-4s\e[0;32mDONE - $PFD ms\e[0;34m\n" " ${OUTPUT: 0: 40} " " "
103
- else
104
-
105
- # ouput the errors
106
- echo -e " \e[0;31m ------------------ C FAILED! -------------------- "
107
- printf " %s" " $( < log/G++COUTPUT.txt) "
108
- echo " "
109
- echo -e " \e[0;31m ------------------- C DONE! --------------------- "
110
- # rm temp.txt
111
-
112
- clean
113
-
114
- exit
115
- fi
116
- }
31
+ cd boot
32
+ for OUTPUT in $( find ./ -type f -iregex ' .*/.*\.\(s\)$' )
33
+ do
34
+ compilea $OUTPUT
35
+ done
36
+ mv * .o ../obj
37
+ cd ..
117
38
118
- # compile the given file with g++
119
- compilec () {
120
- OUTPUT=" $1 "
121
39
122
- mkdir log & > /dev/null
123
- local ts=$( date +%s%N)
124
40
125
- if g++ -m32 -elf_i386 -O -fstrength-reduce -fomit-frame-pointer -finline-functions -nostdinc -fno-builtin -c $OUTPUT -fdiagnostics-color=always & > " log/G++OUTPUT.txt" ; then
126
- local PFD=$(( ($(date +% s% N) - $ts )/ 1000000 ))
127
- printf " %-40s%-4s\e[0;32mDONE - $PFD ms\e[0;34m\n" " ${OUTPUT: 0: 40} " " "
128
- else
129
- printf " %-40s%-4s\e[0;31mFAILED\e[0;34m\n" " ${OUTPUT: 0: 40} " " "
130
- # ouput the errors
131
41
132
- g++ -m32 -elf_i386 -O -fstrength-reduce -fomit-frame-pointer -finline-functions -nostdinc -fno-builtin -c $OUTPUT -fdiagnostics-color=always & > " log/G++OUTPUT.txt"
133
- printf " %s" " $( < log/G++OUTPUT.txt) "
134
- echo " "
135
- # rm temp.txt
136
42
137
- clean
138
43
139
- exit
140
-
141
- fi
142
- }
143
44
144
45
echo " ---------------- BUILDING PROC ------------------"
145
46
146
- # compile .c , .cpp , and .h file
147
- mkdir obj & > /dev/null
47
+
148
48
149
49
cd Proc
150
50
for FILES in $( dir)
@@ -186,15 +86,15 @@ wait
186
86
187
87
echo " ---------------- LINKING BUILDS -----------------"
188
88
189
- TEx= " Moving object files"
190
- printf " %-40s%-4s\e[0;32mDONE\e[0;34m\n " " ${TEx : 0 : 40} " " "
89
+ DisDone " Moving object files"
90
+
191
91
mv * .o obj/ > /dev/null
192
92
rm temp.txt & > /dev/null
193
93
194
94
ts=$( date +%s%N)
195
95
# linking the kernel with kernel.o and boot.o files
196
96
if g++ -m32 -lstdc++ -nostartfiles -T linker.ld obj/* .o -o FluxedOS.bin & > " log/LINKOUTPUT.txt" ; then
197
- TEx= " Linking FluxedOS.bin"
97
+ DisDone " Linking FluxedOS.bin"
198
98
PFD=$(( ($(date +% s% N) - $ts )/ 1000000 ))
199
99
printf " %-40s%-4s\e[0;32mDONE - $PFD ms\e[0;34m\n" " ${TEx: 0: 40} " " "
200
100
else
215
115
echo " ---------------- BUILDING ISO -------------------"
216
116
# check FluxedOS.bin file is x86 multiboot file or not
217
117
if grub-file --is-x86-multiboot FluxedOS.bin & > " log/GRUB.txt" ; then
218
- TEx= " Generating grub files"
219
- printf " %-40s%-4s\e[0;32mDONE\e[0;34m\n " " ${TEx : 0 : 40} " " "
118
+ DisDone " Generating grub files"
119
+
220
120
else
221
121
222
122
# ouput the errors
233
133
234
134
235
135
# building the iso file
236
- TEx=" Making boot/grub"
237
- printf " %-40s%-4s\e[0;32mDONE\e[0;34m\n" " ${TEx: 0: 40} " " "
136
+ DisDone " Making boot/grub"
238
137
mkdir -p isodir/boot/grub & > " log/isoLOG.txt"
239
- TEx=" Making boot/programs"
240
- printf " %-40s%-4s\e[0;32mDONE\e[0;34m\n" " ${TEx: 0: 40} " " "
138
+ DisDone " Making boot/programs"
241
139
mkdir -p isodir/programs & > " log/isoLOG.txt"
242
- TEx=" Moving programs"
243
- printf " %-40s%-4s\e[0;32mDONE\e[0;34m\n" " ${TEx: 0: 40} " " "
140
+ DisDone " Moving programs"
244
141
cp bin/* isodir/programs & > " log/isoLOG.txt"
245
- TEx=" Moving FluxedOS.bin"
246
- printf " %-40s%-4s\e[0;32mDONE\e[0;34m\n" " ${TEx: 0: 40} " " "
142
+ DisDone " Moving FluxedOS.bin"
247
143
cp FluxedOS.bin isodir/boot/FluxedOS.bin & >> " log/isoLOG.txt"
248
- TEx=" Copying grub.cfg"
249
- printf " %-40s%-4s\e[0;32mDONE\e[0;34m\n" " ${TEx: 0: 40} " " "
144
+ DisDone " Copying grub.cfg"
250
145
cp grub.cfg isodir/boot/grub/grub.cfg & >> " log/isoLOG.txt"
251
- TEx=" Generating ISO"
252
- printf " %-40s%-4s\e[0;32mDONE\e[0;34m\n" " ${TEx: 0: 40} " " "
146
+ DisDone " Generating ISO"
253
147
grub-mkrescue -o FluxedOS.iso isodir & >> " log/isoLOG.txt"
254
148
255
149
256
- TEx= " Moving ISO to ISO/"
257
- printf " %-40s%-4s\e[0;32mDONE\e[0;34m\n " " ${TEx : 0 : 40} " " "
150
+ DisDone " Moving ISO to ISO/"
151
+
258
152
mkdir ../ISO/ & > /dev/null &
259
153
cp FluxedOS.iso ../ISO/ &
260
154
261
155
echo " BUILD IN $(( ($(date +% s% N) - $tis )/ 1000000 )) ms" &
262
156
# run
263
157
echo " ---------------- RUNNING BUILD ------------------"
264
- qemu-system-x86_64 -cdrom FluxedOS.iso -vga std -display gtk
265
- printf " %-40s%-4s\e[0;32mDONE\e[0;34m\n" " ${TEx: 0: 40} " " "
158
+ qemu-img create Diskimg.img 50m & > " log/imgcreate.txt"
159
+ DisDone " Creating Diskimg.img"
160
+
161
+
162
+ qemu-system-x86_64 -cdrom FluxedOS.iso -vga std -display gtk -drive file=Diskimg.img,if=ide,format=raw
163
+ DisDone " Running qemu"
164
+ rm -r Diskimg.img
165
+
166
+ DisDone " Removing Diskimg.img"
167
+
266
168
267
169
268
170
0 commit comments