36 lines
1.3 KiB
Python
Executable File
36 lines
1.3 KiB
Python
Executable File
#!/usr/bin/env python3
|
|
|
|
import os
|
|
import subprocess
|
|
|
|
source_path = "./source/"
|
|
cache_path = "./cache/"
|
|
|
|
if not(os.path.exists(cache_path)):
|
|
os.mkdir(cache_path)
|
|
|
|
compile_command = f"clang++ -g -std=c++20 -fno-exceptions -fmodules -fprebuilt-module-path=./cache"
|
|
object_file_paths = []
|
|
|
|
def compile_module(source_file_path, module_identifier) -> None:
|
|
output_path = os.path.join(cache_path, module_identifier)
|
|
|
|
subprocess.run(f"{compile_command} -Xclang -emit-module-interface -c {source_file_path} -o {output_path}.pcm", shell=True, check=True)
|
|
subprocess.run(f"{compile_command} -c {source_file_path} -o {output_path}.o", shell=True, check=True)
|
|
object_file_paths.append(f"{output_path}.o")
|
|
|
|
def compile_package(root_module_name: str) -> None:
|
|
root_module_source_path = os.path.join(source_path, root_module_name)
|
|
|
|
compile_module(f"{root_module_source_path}.cpp", root_module_name)
|
|
|
|
if os.path.isdir(root_module_source_path):
|
|
for file_name in os.listdir(root_module_source_path):
|
|
compile_module(os.path.join(root_module_source_path, file_name), f"{root_module_name}.{os.path.splitext(file_name)[0]}")
|
|
|
|
compile_package("core")
|
|
compile_package("app")
|
|
compile_package("kym")
|
|
compile_package("runtime")
|
|
subprocess.run(f"{compile_command} {' '.join(object_file_paths)} -o ./runtime -lSDL2", shell=True, check=True)
|