From cc5fb242ec625f4a5ec70d6f48a3ab0e0884df35 Mon Sep 17 00:00:00 2001 From: OusmBlueNinja <89956790+OusmBlueNinja@users.noreply.github.com> Date: Wed, 16 Apr 2025 15:04:34 -0500 Subject: [PATCH] Update remake_config.py --- remake/remake_config.py | 55 ++++++++++++++++++++++------------------- 1 file changed, 30 insertions(+), 25 deletions(-) diff --git a/remake/remake_config.py b/remake/remake_config.py index 5871301..e57d738 100644 --- a/remake/remake_config.py +++ b/remake/remake_config.py @@ -46,7 +46,7 @@ lib_dirs: build_dir: build target: build/app.exe log_file: remake/build.log -cache_file: remake/.remake_cache.json + # C compiler and flags cc: gcc @@ -83,32 +83,37 @@ if config is None: die("remake.yaml is empty or invalid YAML. Please fix the file.") # Validate fields -def get_field(name, expected_type): - try: - val = config[name] - if not isinstance(val, expected_type): - raise TypeError(f"Expected {expected_type.__name__}, got {type(val).__name__}") - return val - except KeyError: - die(f"Missing required field: {Style.BOLD}{name}{Style.END}") - except TypeError as e: - die(f"{name} -> {e}") +def get_field(name, expected_type, default=None): + val = config.get(name, default) + if val is None: + warn(f"Missing field '{name}', using default: {default}") + return default + if not isinstance(val, expected_type): + die(f"{name} -> Expected {expected_type.__name__}, got {type(val).__name__}") + return val -# Extract values safely -SRC_DIRS = get_field("src_dirs", list) -INCLUDE_DIRS = get_field("include_dirs", list) -LIB_DIRS = get_field("lib_dirs", list) -BUILD_DIR = Path(get_field("build_dir", str)) -TARGET = Path(get_field("target", str)) -LOG_FILE = Path(get_field("log_file", str)) -CACHE_FILE = Path(get_field("cache_file", str)) -CC = get_field("cc", str) -CFLAGS = get_field("cflags", list) -CXX = get_field("cxx", str) -CXXFLAGS = get_field("cxxflags", list) -AUTO_LIBS = get_field("auto_libs", list) -AUTO_INCLUDES = get_field("auto_includes", list) + +SRC_DIRS = get_field("src_dirs", list, ["src"]) +INCLUDE_DIRS = get_field("include_dirs", list, ["include", "C:/msys64/mingw64/include"]) +LIB_DIRS = get_field("lib_dirs", list, ["C:/msys64/mingw64/lib", "C:/libs"]) + +BUILD_DIR = Path(get_field("build_dir", str, "build")) +TARGET = Path(get_field("target", str, "build/app.exe")) +LOG_FILE = Path(get_field("log_file", str, "remake/build.log")) +CACHE_FILE = Path(get_field("cache_file", str, "remake/.remake_cache.json")) + +CC = get_field("cc", str, "gcc") +CFLAGS = get_field("cflags", list, ["-std=c99", "-Wall"]) + +CXX = get_field("cxx", str, "g++") +CXXFLAGS = get_field("cxxflags", list, ["-std=c++20", "-Wall"]) + +AUTO_LIBS = get_field("auto_libs", list, []) +AUTO_INCLUDES = get_field("auto_includes", list, []) + + +