-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.py
executable file
·62 lines (41 loc) · 1.79 KB
/
build.py
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
#!/usr/bin/python3
CFLAGS='-m32 -c -nostdlib -nostdinc -fno-builtin -fno-stack-protector -nostartfiles -nodefaultlibs -I include '
ASFLAGS='-f elf '
csources = []
ssources = []
import fnmatch
import os
for root, dirnames, filenames in os.walk('.'):
for filename in fnmatch.filter(filenames, '*.c'):
if "apps" not in os.path.join(root, filename) and "clib" not in os.path.join(root, filename):
csources.append(os.path.join(root, filename))
for root, dirnames, filenames in os.walk('.'):
for filename in fnmatch.filter(filenames, '*.asm'):
if "apps" not in os.path.join(root, filename) and "clib" not in os.path.join(root, filename):
ssources.append(os.path.join(root, filename))
for i in range(len(csources)):
c = csources[i]
os.system("mkdir -p build/" + c)
print("[" + str(i + 1) + "/" + str(len(csources)) + "] " + "Compiling: [" + c + "]")
os.system("gcc " + CFLAGS + c + " -o build/" + c + ".o")
for i in range(len(ssources)):
s = ssources[i]
os.system("mkdir -p build/" + s)
print("[" + str(i + 1) + "/" + str(len(ssources)) + "] "+ "Compiling: [" + s + "]")
os.system("nasm " + ASFLAGS + s + " -o build/" + s + ".o")
total = ""
os.system("mkdir -p build/iso/boot/grub/")
for c in csources:
total += "build/"
total += c
total += ".o "
for s in ssources:
total += "build/"
total += s
total += ".o "
print("\nLinking kernel...\n")
os.system("ld -m elf_i386 -Tconfig/linker.ld -o build/iso/boot/kernel.elf " + total)
os.system("cp -f config/grub.cfg build/iso/boot/grub/")
os.system("grub-mkrescue -o build/quantumos.iso build/iso")
print("Done!\nRunning kernel...")
os.system("qemu-system-x86_64 -cdrom ./build/quantumos.iso -drive file=ext2.img,format=raw -m 3G -vga vmware -serial stdio -device ac97")