-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.py
31 lines (20 loc) · 842 Bytes
/
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
import os,datetime,math
def escape_shell_string(input_str):
# Escape single quotes and double quotes by adding backslashes
return input_str.replace('"', '\\"')
os.system(f"make -Bs")
with open("Makefile","r") as f:
data = f.read().split("\n")
constants = {
"CONST_VERSION":"\"indev-2024-11-23\""
}
# dynamic constants
constants["CONST_COMPDATE"] = "\"" + datetime.datetime.now().strftime("%a. %B %d, %Y @ %I:%M %p") + "\""
constants["CONST_KERNELSIZE"] = str(round((os.path.getsize("bin/paranoia.bin")*2)/512))
# manipulate constants
constants = [f"-D{i}='{v}'" for i,v in constants.items()]
constants = " ".join(constants)
constants = "CONST=\"" + escape_shell_string(constants) + "\""
print("\n\n\nCONSTANTS:",constants,"\n\n\n")
print()
os.system(f"make -B {constants} && qemu-system-i386 -cdrom paranoia.iso -boot d")