1+ #! /bin/bash
2+
3+ source func.sh
4+
15# Display the welcome
26tis=$( date +%s%N)
37echo " ________ __ ______ "
@@ -11,140 +15,36 @@ echo -e " A \e[0;35mMain Menu\e[0;34m aka \e[0;35mcorigan01\e[0;34m p
1115echo
1216
1317
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- }
4018
41- # assemble boot.s file
42- compilea () {
43- OUTPUT=" $1 "
4419
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
4821
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
5522
56- clean
5723
58- exit
59- fi
6024
61- }
6225
26+ # compile .c , .cpp , and .h file
27+ mkdir obj & > /dev/null
6328
6429echo " ---------------- BUILDING ASM -------------------"
6530# 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 ..
11738
118- # compile the given file with g++
119- compilec () {
120- OUTPUT=" $1 "
12139
122- mkdir log & > /dev/null
123- local ts=$( date +%s%N)
12440
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
13141
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
13642
137- clean
13843
139- exit
140-
141- fi
142- }
14344
14445echo " ---------------- BUILDING PROC ------------------"
14546
146- # compile .c , .cpp , and .h file
147- mkdir obj & > /dev/null
47+
14848
14949cd Proc
15050for FILES in $( dir)
@@ -186,15 +86,15 @@ wait
18686
18787echo " ---------------- LINKING BUILDS -----------------"
18888
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+
19191mv * .o obj/ > /dev/null
19292rm temp.txt & > /dev/null
19393
19494ts=$( date +%s%N)
19595# linking the kernel with kernel.o and boot.o files
19696if 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"
19898 PFD=$(( ($(date +% s% N) - $ts )/ 1000000 ))
19999 printf " %-40s%-4s\e[0;32mDONE - $PFD ms\e[0;34m\n" " ${TEx: 0: 40} " " "
200100else
215115echo " ---------------- BUILDING ISO -------------------"
216116# check FluxedOS.bin file is x86 multiboot file or not
217117if 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+
220120else
221121
222122 # ouput the errors
233133
234134
235135# 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"
238137mkdir -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"
241139mkdir -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"
244141cp 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"
247143cp 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"
250145cp 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"
253147grub-mkrescue -o FluxedOS.iso isodir & >> " log/isoLOG.txt"
254148
255149
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+
258152mkdir ../ISO/ & > /dev/null &
259153cp FluxedOS.iso ../ISO/ &
260154
261155echo " BUILD IN $(( ($(date +% s% N) - $tis )/ 1000000 )) ms" &
262156# run
263157echo " ---------------- 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+
266168
267169
268170
0 commit comments