WKern
Loading...
Searching...
No Matches
build.py
Go to the documentation of this file.
1#!/usr/bin/env python3
2
3
19
20import sys
21import os
22from bfiles.brules import *
23from bfiles.files import *
24from bfiles.frules import *
25import time
26
27
38def build():
39 start_time = time.time()
40 fmt()
41 compileasm()
42 compilec()
43 partial_link()
44 link()
45 iso()
46 chkm()
47 end_time = time.time()
48 elapsed = end_time - start_time
49 print(f"\n\033[36mFinished in {elapsed:.2f} seconds\033[0m")
50
51
55def clean():
56 for file in CLEANTARGS:
57 try:
58 os.remove(file)
59 except FileNotFoundError:
60 pass
61 try:
62 shutil.rmtree("__pycache__")
63 except FileNotFoundError:
64 pass
65 try:
66 shutil.rmtree("bfiles/__pycache__")
67 except FileNotFoundError:
68 pass
69
70
81def main():
82 if (len(sys.argv) == 1):
83 if os.path.isfile('./didconf'):
84 build()
85 else:
86 subprocess.run(["./configure.py"])
87 build()
88 elif (sys.argv[1] == "-clean"):
89 clean()
90 elif (sys.argv[1] == "-git"):
91 clean()
92 git()
93 elif (sys.argv[1] == "-run"):
94 run()
95 elif (sys.argv[1] == "-test"):
96 try:
97 subprocess.run(["./configure.py"], check=True)
98 except subprocess.CalledProcessError as e:
99 print(f"Check exited with code {e.returncode}")
100 sys.exit(1)
101 elif (sys.argv[1] == "-loc"):
102 subprocess.run(["./loc.sh"])
103 elif (sys.argv[1] == "-mkd"):
104 subprocess.run(["dd", "if=/dev/zero", "of=fat16.img", "bs=1M", "count=64"])
105 subprocess.run(["mkfs.fat", "-F", "16", "fat16.img"])
106
107
108# === Script entry point ===
109if __name__ == "__main__":
110 main()
Definition build.py:1
main()
CLI entrypoint for build.py.
Definition build.py:81
build()
Main build routine.
Definition build.py:38
clean()
Remove build output files and Python caches.
Definition build.py:55