diff --git a/.vscode/tasks.json b/.vscode/tasks.json new file mode 100644 index 0000000..a785b23 --- /dev/null +++ b/.vscode/tasks.json @@ -0,0 +1,37 @@ +{ + "tasks": [ + { + "type": "cppbuild", + "label": "C/C++: gcc.exe build active file", + "command": "C:/mingw64/bin/gcc.exe", + "args": [ + "-fdiagnostics-color=always", + "-g", + "${file}", + "-o", + "${fileDirname}\\${fileBasenameNoExtension}.exe" + ], + "options": { + "cwd": "C:/mingw64/bin" + }, + "problemMatcher": [ + "$gcc" + ], + "group": { + "kind": "build", + "isDefault": true + }, + "detail": "Task generated by Debugger." + }, + { + "type": "shell", + "label": "Fumo build script", + "command": "python build.py", + "group": { + "kind": "build", + "isDefault": true + }, + } + ], + "version": "2.0.0" +} \ No newline at end of file diff --git a/build.py b/build.py index b509c0d..e89f450 100644 --- a/build.py +++ b/build.py @@ -1,11 +1,28 @@ import hashlib import json +<<<<<<< HEAD import subprocess 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 SOURCE_DIR = Path("source/") @@ -43,8 +60,13 @@ def disk_read_chksms(txt: Path) -> tuple[list[Path], list[str]]: return (sources, chksms) +<<<<<<< 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)) @@ -55,6 +77,7 @@ def filter_chksms(sources, chksms, old_chksms) -> list[Path]: 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) @@ -136,4 +159,7 @@ def build(source_dir: Path, object_dir: Path, output: Path): if __name__ == "__main__": - build(SOURCE_DIR, OBJECT_DIR, OUTPUT) \ No newline at end of file + build(SOURCE_DIR, OBJECT_DIR, OUTPUT) +======= +build("source/", "objects/", "debug", True) +>>>>>>> 41f57d5ba85e72cf801e8ee91afe55d40d535701 diff --git a/test.exe b/test.exe new file mode 100644 index 0000000..cd52a73 Binary files /dev/null and b/test.exe differ