summaryrefslogtreecommitdiff
path: root/salis.py
diff options
context:
space:
mode:
Diffstat (limited to 'salis.py')
-rwxr-xr-xsalis.py29
1 files changed, 14 insertions, 15 deletions
diff --git a/salis.py b/salis.py
index 0497ee4..e13af4c 100755
--- a/salis.py
+++ b/salis.py
@@ -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,14 +263,14 @@ 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_build = Build(arch_inst_path, is_library=True, flags=["-Icore"])
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
+inst_count = 0x80 # must match ARCH_INST_COUNT in core/arch_inst.h
# ------------------------------------------------------------------------------
# [section] assemble ancestor
@@ -286,17 +286,16 @@ 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(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)}",
@@ -326,16 +325,16 @@ 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}'")
-with open(f"{ui_path}/links.json", "r") as f:
- ui_links = json.load(f)
+with open(f"{ui_path}/opts.json", "r") as f:
+ ui_opts = json.load(f)
-ui_links += ["-lsqlite3", "-lz"]
+ui_flags = ui_opts["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 = ui_opts["defines"] + general_defines + logger_defines
+ui_links = ui_opts["links"] + ["-lsqlite3", "-lz"]
ui_build = Build(f"{ui_path}/ui.c", flags=ui_flags, defines=ui_defines, links=ui_links)
ui_build.build()
ui_build.log(log)