1
0
Fork 0
mirror of https://git.sr.ht/~kivikakk/niar synced 2024-12-22 18:02:25 +00:00

build: use IL from plan, not on disk.

We haven't extracted it yet.
This commit is contained in:
Asherah Connor 2024-07-03 13:26:53 +03:00
parent 12dc846334
commit 8175fb5d0a
2 changed files with 18 additions and 9 deletions

View file

@ -76,7 +76,7 @@ def main(np: Project, args):
# The outf doesn't exist here; it's only used for the digest name basis.
cr.add_process(execute_build,
infs=[np.path.build(subdir, fn)],
infs=[{np.path.build(subdir, fn): plan.files[fn]}],
outf=np.path.build(subdir, np.name))
cr.run()

View file

@ -14,7 +14,7 @@ class CompilationUnit:
self.cmd = cmd
else:
self.cmd = [str(el) for el in cmd]
self.infs = [str(p) for p in infs]
self.infs = infs
self.outf = str(outf) if outf else None
self.chdir = chdir
@ -50,14 +50,12 @@ class CompilationUnit:
def digest_str(s):
digest_bytes(s.encode())
sorted_in_paths = list(self.infs)
sorted_in_paths.sort()
infs = self.process_infs()
digest_int(len(sorted_in_paths))
for in_path in sorted_in_paths:
digest_int(len(infs))
for in_path in sorted(infs.keys()):
digest_str(in_path)
with open(in_path, "rb") as f:
digest_bytes(f.read())
digest_bytes(infs[in_path])
if not inspect.isfunction(self.cmd):
digest_int(len(self.cmd))
@ -66,7 +64,18 @@ class CompilationUnit:
return m.hexdigest()
def process_infs(self):
r = {}
for inf in self.infs:
if isinstance(inf, dict):
for k, v in inf.items():
if isinstance(v, str):
v = v.encode()
r[str(k)] = v
else:
with open(inf, "rb") as f:
r[str(inf)] = f.read()
return r
class CommandRunner:
cus: list[CompilationUnit]