Update remake_config.py

This commit is contained in:
OusmBlueNinja 2025-04-16 15:04:34 -05:00
parent 32c5e4c8fc
commit cc5fb242ec

View File

@ -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]
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):
raise TypeError(f"Expected {expected_type.__name__}, got {type(val).__name__}")
die(f"{name} -> 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}")
# 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, [])