idk, submodues dum

This commit is contained in:
OusmBlueNinja 2025-04-18 22:17:07 -05:00
parent cc12740994
commit 9fbe2eb35a

View File

@ -7,6 +7,12 @@ import time
import json
from remake_config import *
import threading
from concurrent.futures import ThreadPoolExecutor, as_completed
print_lock = threading.Lock()
# ========== COLOR UTILS ==========
class Colors:
HEADER = '\033[95m'
@ -148,16 +154,20 @@ def compile_source(source, obj, includes):
cmd = [compiler, *flags, *[f"-I{inc}" for inc in includes], "-MMD", "-MP", "-c", str(source), "-o", str(obj)]
try:
print(f"\r{color('🔨 Compiling:', Colors.OKCYAN)} {source}{' ' * 40}", end="", flush=True)
with print_lock:
print(f"\r{color('🔨 Compiling:', Colors.OKCYAN)} {source}{' ' * 40}", end="", flush=True)
subprocess.run(cmd, check=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
log(f"[COMPILE] {' '.join(cmd)}")
return True
except subprocess.CalledProcessError as e:
print() # move to new line before showing error
error(f"Failed to compile {source}")
print("🔧 Command:", " ".join(cmd))
print(e.stderr.decode())
with print_lock:
print() # move to new line before showing error
error(f"Failed to compile {source}")
print("🔧 Command:", " ".join(cmd))
print(e.stderr.decode())
log(f"[ERROR] {' '.join(cmd)}\n{e.stderr.decode()}")
sys.exit(1)
return False
@ -184,34 +194,42 @@ def build():
link_dirs, libs, extra_includes = resolve_packages()
all_includes = INCLUDE_DIRS + extra_includes
for source in cpp_files:
obj = obj_path(source)
dep = dep_path(obj)
obj_mtime = obj.stat().st_mtime if obj.exists() else 0
needs_build = not obj.exists() or source.stat().st_mtime > obj_mtime
compile_tasks = []
with ThreadPoolExecutor() as executor:
for source in cpp_files:
obj = obj_path(source)
dep = dep_path(obj)
obj_mtime = obj.stat().st_mtime if obj.exists() else 0
needs_build = not obj.exists() or source.stat().st_mtime > obj_mtime
if not needs_build and dep.exists():
for dep_file in parse_dep_file(dep):
try:
if Path(dep_file).exists() and Path(dep_file).stat().st_mtime > obj_mtime:
if not needs_build and dep.exists():
for dep_file in parse_dep_file(dep):
try:
if Path(dep_file).exists() and Path(dep_file).stat().st_mtime > obj_mtime:
needs_build = True
break
except Exception:
needs_build = True
break
except Exception:
needs_build = True
break
if needs_build:
compile_source(source, obj, all_includes)
else:
print(f"\r{color('👌 Up-to-date:', Colors.GRAY)} {source}{' ' * 20}", end="", flush=True)
if needs_build:
compile_tasks.append(executor.submit(compile_source, source, obj, all_includes))
else:
with print_lock:
print(f"\r{color('👌 Up-to-date:', Colors.GRAY)} {source}{' ' * 20}", end="", flush=True)
obj_files.append(obj)
for task in as_completed(compile_tasks):
if not task.result():
sys.exit(1)
obj_files.append(obj)
print()
link_objects(obj_files, link_dirs, libs)
banner("✅ Build Complete")
print(color(f"⏱ Build time: {time.time() - build_start:.2f}s", Colors.OKCYAN))
def run():
build()
if TARGET.exists():
@ -262,6 +280,8 @@ if __name__ == "__main__":
try:
if "clean" in sys.argv:
clean()
if "clear" in sys.argv:
clean()
elif "run" in sys.argv:
run()
else: