diff options
Diffstat (limited to 'salis.py')
| -rwxr-xr-x | salis.py | 24 |
1 files changed, 12 insertions, 12 deletions
@@ -14,7 +14,7 @@ # [section] entry-point; source options # [section] load instruction set # [section] assemble ancestor -# [section] defines +# [section] general defines # [section] build and launch # ------------------------------------------------------------------------------ @@ -175,9 +175,9 @@ logger_dll = ctypes.CDLL(logger_shared.binfile) # Pull in logging functions from C # This way there's just a single logging system to care about log = SimpleNamespace() -log.trace = lambda msg: logger_dll.log_trace(msg.encode()) -log.info = lambda msg: logger_dll.log_info(msg.encode()) -log.attention = lambda msg: logger_dll.log_attention(msg.encode()) +log.trace = lambda msg: logger_dll.log_trace_to_stdout(msg.encode()) +log.info = lambda msg: logger_dll.log_info_to_stdout(msg.encode()) +log.attention = lambda msg: logger_dll.log_attention_to_stdout(msg.encode()) logger_shared.log(log) # ------------------------------------------------------------------------------ @@ -263,12 +263,12 @@ if args.command == "load": # [section] load instruction set # ------------------------------------------------------------------------------ arch_inst_path = f"arch/{args.vm_arch}/arch_inst.c" -arch_build = Build(arch_inst_path, is_library=True) +arch_inst_count = 0x80 # used to set ARCH_INST_COUNT macro on all builds +arch_build = Build(arch_inst_path, is_library=True, flags=["-Icore"], defines=[f"-DARCH_INST_COUNT={arch_inst_count}"]) arch_build.build() arch_build.log(log) arch_dll = ctypes.CDLL(arch_build.binfile) -arch_dll.arch_inst_cap.restype = ctypes.c_int arch_dll.arch_inst_mnemonic.argtypes = [ctypes.c_uint8] arch_dll.arch_inst_mnemonic.restype = ctypes.c_char_p @@ -286,21 +286,21 @@ with open(anc_path, "r") as f: lines = filter(lambda line: line and not line.startswith(";") and not line.isspace(), lines) lines = map(lambda line: tuple(line.split()), lines) -inst_cap = arch_dll.arch_inst_cap() -mnemo_map = {tuple(arch_dll.arch_inst_mnemonic(byte).decode().split()): byte for byte in range(inst_cap)} +mnemo_map = {tuple(arch_dll.arch_inst_mnemonic(byte).decode().split()): byte for byte in range(arch_inst_count)} anc_bytes = [mnemo_map[line] for line in lines] anc_repr = f"{{{",".join(map(str, anc_bytes))}}}" log.info(f"Compiled ancestor file '{anc_path}' into byte array: {anc_repr}") # ------------------------------------------------------------------------------ -# [section] defines +# [section] general defines # ------------------------------------------------------------------------------ -defines = [ +general_defines = [ f"-DANC=\"{args.anc}\"", f"-DANC_BYTES={anc_repr}", f"-DANC_SIZE={len(anc_bytes)}", f"-DARCH=\"{args.vm_arch}\"", + f"-DARCH_INST_COUNT={arch_inst_count}", f"-DAUTOSAVE_INTERVAL={2 ** args.auto_save_pow}ul", f"-DAUTOSAVE_NAME_LEN={len(paths.sim_path) + 18}", f"-DCLONES={args.clones}", @@ -326,8 +326,6 @@ defines = [ # [section] build and launch # ------------------------------------------------------------------------------ ui_path = f"{args.ui_path}/{args.ui}" -ui_flags = [f"-Iarch/{args.vm_arch}", "-Icore", f"arch/{args.vm_arch}/arch.c", arch_inst_path, "core/compress.c", "core/logger.c", "core/salis.c", "core/sql.c"] -ui_defines = defines + logger_defines if not os.path.isdir(ui_path): raise RuntimeError(f"UI not found at '{ui_path}'") @@ -335,6 +333,8 @@ if not os.path.isdir(ui_path): with open(f"{ui_path}/links.json", "r") as f: ui_links = json.load(f) +ui_flags = [f"-Iarch/{args.vm_arch}", "-Icore", f"arch/{args.vm_arch}/arch.c", arch_inst_path, "core/compress.c", "core/logger.c", "core/salis.c", "core/sql.c", "core/timer.c"] +ui_defines = general_defines + logger_defines ui_links += ["-lsqlite3", "-lz"] ui_build = Build(f"{ui_path}/ui.c", flags=ui_flags, defines=ui_defines, links=ui_links) ui_build.build() |
