From 5c55be1ff90e8571c744f8e0d56ce71a4cc0fe06 Mon Sep 17 00:00:00 2001 From: Julia <145168563+julia-aph@users.noreply.github.com> Date: Fri, 10 May 2024 16:59:52 -0500 Subject: [PATCH] hhhj n --- build.py | 121 +++++++------------------ checksums.txt | 2 +- debug.exe | Bin 88287 -> 88287 bytes errors.txt | 2 +- objects/ctrl.o | Bin 2686 -> 2686 bytes objects/dictionary.o | Bin 2389 -> 2389 bytes objects/event.o | Bin 1458 -> 1458 bytes objects/fumocommon.o | Bin 1487 -> 1487 bytes objects/fumoengine.o | Bin 2397 -> 2397 bytes objects/fumotris.o | Bin 2075 -> 2075 bytes objects/input.o | Bin 3062 -> 3062 bytes objects/parseinput.o | Bin 1295 -> 1295 bytes objects/ringbuffer.o | Bin 2108 -> 2108 bytes objects/terminal.o | Bin 2764 -> 2764 bytes objects/tetr.o | Bin 2002 -> 2002 bytes objects/vector.o | Bin 1444 -> 1444 bytes objects/win.o | Bin 4094 -> 4094 bytes source/fumoengine/include/dictionary.c | 2 +- 18 files changed, 38 insertions(+), 89 deletions(-) diff --git a/build.py b/build.py index e89f450..d2a4572 100644 --- a/build.py +++ b/build.py @@ -1,28 +1,12 @@ -import hashlib import json -<<<<<<< HEAD import subprocess +from subprocess import PIPE +from hashlib import md5 from pathlib import Path GCC = "gcc" -ARGS = "-fdiagnostics-color -pthread -Wall -std=c17 -pedantic" -======= -import os -import subprocess -import sys - - -def walk_source_dir(path: str) -> tuple[list[str], list[str]]: - source_paths : list[str] = [] - subdirs = [] - - for dirpath, dirnames, filenames in os.walk(path): - source_paths += [os.path.join(dirpath, f) for f in filenames if f.endswith(".c")] - subdirs.append(dirpath) - - return (source_paths, subdirs) ->>>>>>> 41f57d5ba85e72cf801e8ee91afe55d40d535701 +ARGS = "-fdiagnostics-color -pthread -Wall -std=c17 -pedantic -g" SOURCE_DIR = Path("source/") @@ -34,59 +18,24 @@ CHECKSUMS = Path("checksums.txt") ERRORS = Path("errors.txt") -def disk_scan_chksms(sources: list[Path]) -> list[str]: - chksms: list[str] = [] - - for source in sources: - with open(source, "rb") as file: - raw = file.read() - chksms.append(hashlib.md5(raw).hexdigest()) - - return chksms +def scan_checksums(files: list[Path]) -> list[str]: + return (md5(file.read_bytes()).hexdigest() for file in files) -def disk_read_chksms(txt: Path) -> tuple[list[Path], list[str]]: - sources: list[Path] - chksms: list[str] - +def read_txt(txt: Path) -> any: if not txt.exists(): - return ([], []) - - with open(txt, "rb") as file: - zipped: dict[str, str] = json.loads(file.read()) - - sources, chksms = [Path(key) for key in zipped.keys()], zipped.values() - - return (sources, chksms) + return [] + + content = txt.read_text("utf-8") + return json.loads(content) if content else [] -<<<<<<< HEAD -def disk_write_chksms(txt: Path, sources: list[Path], chksms: list[str]) -> None: - zipped = {str(source): chksm for source, chksm in zip(sources, chksms)} -======= -def build(source_path, obj_path, out_path, recompile): - source_paths, subdirs = walk_source_dir(source_path) ->>>>>>> 41f57d5ba85e72cf801e8ee91afe55d40d535701 - - with open(txt, "w+") as file: - file.write(json.dumps(zipped)) +def write_txt(txt: Path, content) -> None: + txt.write_text(json.dumps(content)) -def filter_chksms(sources, chksms, old_chksms) -> list[Path]: - difs = set(chksms).difference(old_chksms) - return [sources[chksms.index(dif)] for dif in difs] - - -<<<<<<< HEAD -def scan_sources(source_dir: Path) -> tuple[list[Path], list[Path]]: - sources = [source for source in source_dir.rglob("*.c")] - chksms = disk_scan_chksms(sources) - - old_sources, old_chksms = disk_read_chksms(CHECKSUMS) - updated_sources = filter_chksms(sources, chksms, old_chksms) - - disk_write_chksms(CHECKSUMS, sources, chksms) - return (updated_sources, sources) +def difference(cur, old, vals): + return (vals[cur.index(i)] for i in set(cur) - set(old)) def clean_objects(object_dir: Path, sources: list[Path]) -> None: @@ -99,6 +48,16 @@ def clean_objects(object_dir: Path, sources: list[Path]) -> None: objects[object_stems.index(stem)].unlink() +def header_dependencies(sources): + tasks = [] + for source in sources: + task = subprocess.Popen(f"{GCC} -MMD {source} {ARGS} -o stdout", stdout=PIPE) + tasks.append(task) + + for task in tasks: + + + def compile(source: Path, includes: list[Path], object_dir: Path): include_arg: str = " ".join(f"-I {dir}" for dir in includes) output: Path = object_dir / source.with_suffix(".o").name @@ -108,19 +67,6 @@ def compile(source: Path, includes: list[Path], object_dir: Path): return subprocess.Popen(args, stderr=subprocess.PIPE) -def disk_read_errors(txt: Path) -> dict[str, str]: - if not txt.exists(): - return {} - - with open(txt, "rb") as file: - return json.loads(file.read()) - - -def disk_write_errors(txt: Path, errs: dict[str, str]): - with open(txt, "w+") as file: - file.write(json.dumps(errs)) - - def wait_compile_tasks(tasks, updated_sources) -> dict[str, str]: errors = disk_read_errors(ERRORS) @@ -136,13 +82,19 @@ def wait_compile_tasks(tasks, updated_sources) -> dict[str, str]: def link(object_dir: Path, output: Path) -> None: - subprocess.run(f"{GCC} -g {object_dir}/*.o {ARGS} -o {output}") + subprocess.run(f"{GCC} {object_dir}/*.o {ARGS} -o {output}") -def build(source_dir: Path, object_dir: Path, output: Path): - updated_sources, all_sources = scan_sources(source_dir) - includes = [path for path in source_dir.rglob("*") if path.is_dir()] +def build(src: Path, object_dir: Path, output: Path): + includes, headers, sources = zip(map(src.rglob, ["*/", "*.h", "*.c"])) + headers_cur, sources_cur = map(scan_checksums, (headers, sources)) + headers_old, sources_old = read_txt(CHECKSUMS) + + headers_updt = difference(headers_cur, headers_old, headers) + sources_updt = difference(sources_cur, sources_old, sources) + + dependencies = {} tasks = [] for source in updated_sources: @@ -159,7 +111,4 @@ def build(source_dir: Path, object_dir: Path, output: Path): if __name__ == "__main__": - build(SOURCE_DIR, OBJECT_DIR, OUTPUT) -======= -build("source/", "objects/", "debug", True) ->>>>>>> 41f57d5ba85e72cf801e8ee91afe55d40d535701 + build(SOURCE_DIR, OBJECT_DIR, OUTPUT) \ No newline at end of file diff --git a/checksums.txt b/checksums.txt index 42d39ab..136d8cd 100644 --- a/checksums.txt +++ b/checksums.txt @@ -1 +1 @@ -{"source\\fumoengine\\fumocommon.c": "3253ec40842eaf2b65cca13826e35118", "source\\fumoengine\\fumoengine.c": "e6c26dc323b01d0b8c2e7e2f64833eb7", "source\\fumoengine\\include\\dictionary.c": "aa85678a01e035d45c9f59b6fe917beb", "source\\fumoengine\\include\\event.c": "71e6818ecf285293cf01c791f13c4d00", "source\\fumoengine\\include\\ringbuffer.c": "306556649cea951ef769cdfc5ae2b60d", "source\\fumoengine\\include\\vector.c": "67e0cf60c3a359e6e8c8eb46e01e8513", "source\\fumoengine\\input\\ctrl.c": "87dbff7e38fc406cbf309717e63665ed", "source\\fumoengine\\input\\input.c": "5a57ebd313fc2fc0246a95ce6641e5e8", "source\\fumoengine\\input\\platforms\\parseinput.c": "c1562355adcec7d0dcb0a81e8d7ffcca", "source\\fumoengine\\input\\platforms\\win.c": "2014fc5cdb4c8770f510a63db779f8bf", "source\\fumoengine\\terminal\\terminal.c": "c213e73df14b8d5ebcf5f25d221c3fe6", "source\\fumotris\\fumotris.c": "defad533a34d69352e728dbda3306a79", "source\\fumotris\\tetr.c": "09dcf3a7119ccabe0cb69c0a8fd688e9"} \ No newline at end of file +{"source\\fumoengine\\fumocommon.c": "bdd12a9257829d191f57d442b068db37", "source\\fumoengine\\fumoengine.c": "f3097febe6401acf6d0d8b3032b2da68", "source\\fumotris\\fumotris.c": "1516eb830de511f7987507be279e6f02", "source\\fumotris\\tetr.c": "74901782ad0d235bb6b078d2bb6ef99e", "source\\fumoengine\\include\\dictionary.c": "c8f8e5f99965c5c82caf24790fed78e4", "source\\fumoengine\\include\\event.c": "140ba30120636d5d33875e43447e0642", "source\\fumoengine\\include\\ringbuffer.c": "0d552f9daeeebd7ef23f4aaa7ae3e022", "source\\fumoengine\\include\\vector.c": "3f2ccd6831013ac0428446c776891503", "source\\fumoengine\\input\\ctrl.c": "6113d9b6cbcef5daed308f96a0a96f18", "source\\fumoengine\\input\\input.c": "7004fde9604dd57325d623cf9775b33c", "source\\fumoengine\\terminal\\terminal.c": "42b3d4217c15403b6dd079cee4a68186", "source\\fumoengine\\input\\platforms\\parseinput.c": "e23dafd399743096db434a9869b3b47e", "source\\fumoengine\\input\\platforms\\win.c": "f52c9c1bab5d1f05d78f0420780d486a"} \ No newline at end of file diff --git a/debug.exe b/debug.exe index 15cf36511b81ad10f0f9d85c466178d678a6faa1..7710785d4387715ef62cd59c1a9e71e646013a39 100644 GIT binary patch delta 1222 zcmcb=k@fyY)(IUV5lVJx467Iz_OLTBd|*&x;AUddnmEUX>F~LYx0Xcm=qMDKYAP5S z>lx`8Oty-085I}}k0F^HSU@Rx^Mdqvrp=65Wj2gPn-f_&7&ooB#?I(Hx$%*u&1i@PR>%ft!g*bK)EuCbu6OZ!L-B&{Qxq)-%#G zm~0lM#+;j+HaRg$fzuc+Y7wO}Dhdo8T;bq`9Dp7plY>3oP&Z_-*s(dVBa&$|V^*0B zqv7U6mJY^EE3UCKx=(JrB)R#+`XWX~&xwkn)9vIKc{jIi+z8}?Wdb&@fH8%(+Q66@ z+d%5U3chUjgE3=vYQdNbcEPnJ?SX6Cu@|n*Wj|a2+d;VKq(gAEFAm>>8TQ~PPyyJX zlXH&Gg0d7&Kv|owoM3}Ve>n*gTybg}6I5lzS(u>CIiLd}J}x*9V@}?30VbbuQ34{r z8LG28P9xSeY3;Cr{=$1OU28PXk%nukDJtyn4HUj{`PYHwo diff --git a/objects/fumocommon.o b/objects/fumocommon.o index d921a204b7cb230d5aed52bff3c675e3fb6b8c08..11ad76f7825e2e576dcf8503f2c4494cf7a876fa 100644 GIT binary patch delta 41 xcmX@leV%&*4>M~)esN~SWPWA^PE$<NOaa@u4;W(96zO$9?^JtI8>28PX6%vwy0o)aBKCs(nC0sz~_3DE!m diff --git a/objects/fumoengine.o b/objects/fumoengine.o index 068ab6909ca87e49f0a0397fcb98940f50aeea0b..059f6f61e375dcbd8588b7bfab819591f0893a9f 100644 GIT binary patch delta 66 zcmcaBbXRCY0*hWjesN}nZgFacjzUstW=@GhQl)}ZQEGBVi9&E28PXjEJv6aJvRrlb1?w`>of{q diff --git a/objects/fumotris.o b/objects/fumotris.o index 96eb26bfc024b0d15ee39779859bf3152fcf6a49..be7b2bdb7dfd37fea900f3512b453a3f321e6252 100644 GIT binary patch delta 42 ycmbO&Fk4{54`$Ya{Nl`t$-kKuI88Mb42|`S^b9tuvB)todQU7A-5kYskP!eZ!VJj( delta 42 ycmbO&Fk4{54`$}vgU>Ufl03*zc{l(w>ULJMgU>Ufr&XcIc@S)CIxO|O$9?^JtI8>28PZ5m<};AdQLvb;s*fcrVEDv diff --git a/objects/ringbuffer.o b/objects/ringbuffer.o index 4c928c27e9df791b8aa5dbfbec95f6c6f61e090f..2b6f44277e7df153bff014737b0ca0e3b64a34ac 100644 GIT binary patch delta 38 ucmdlZut#9S6&BWl{Nl`t$=6vFI88Mb42|`S^b9sLv9>TVdQWa=-wFW!*bDLi delta 38 ucmdlZut#9S6&B{)TVdQNU<-wFWg&kFMZ diff --git a/objects/terminal.o b/objects/terminal.o index 6d644b5e9a177f9414679a6a49016f6816cba33c..8d4b93e24c75fbb0379746f31533d40b14b24cca 100644 GIT binary patch delta 38 ucmX>jdPa1E3_EKjdPa1E3_Ejfa@u4?b_H%@O$9?^JtI8>28PXE?B|#mJts?YZ3Y0#1_{~# diff --git a/objects/tetr.o b/objects/tetr.o index 8551cfb8449d5f8d1bdc578ca37fbda3dd80d071..cf44bcc917b08ebc1a94ec0676e70487bd04a0af 100644 GIT binary patch delta 38 ucmcb_e~Ev?4;I#f{Nl`t$-h|?I88Mb42|`S^b9tuv5GMDGIRw diff --git a/objects/vector.o b/objects/vector.o index afd86cd86282b0a83a838d24aa6864c51fa28d91..ce95fa7fd46334c86f8f647309600b9770a82795 100644 GIT binary patch delta 38 ucmZ3&y@Y$i8z$C*{Nl`t$?usII88Mb42|`S^b9sjF~4GD^q$PhIv)W2(F?@@ delta 38 ucmZ3&y@Y$i8z$!5X?VVB#?!!d(}(R=e!o=9c@1kDV< delta 33 pcmew-|4)9y33le(capacity; void *bkt = probe_empty_bkt(T, dict, index, key); - if (*get_key(T, bkt) == 0) + if (*get_key(T, bkt) == 0) set_bkt(T, bkt, key, val); return bkt;