improved build system

This commit is contained in:
Maxim Devaev
2025-02-08 15:38:11 +02:00
parent dd7701be38
commit a2b8b35070
7 changed files with 43 additions and 54 deletions

View File

@@ -16,20 +16,12 @@ def _find_sources() -> list[str]:
def _find_flags() -> dict[str, bool]:
return {
key: bool(int(value))
key[3:]: (value.strip().lower() in ["true", "on", "1"])
for (key, value) in sorted(os.environ.items())
if key.startswith("WITH_")
if key.startswith("MK_WITH_")
}
def _make_d_flags(flags: dict[str, bool]) -> list[str]:
return [
f"-D{key}"
for (key, value) in flags.items()
if value
]
def _make_d_features(flags: dict[str, bool]) -> str:
features = " ".join([
f"{key}={int(value)}"
@@ -54,7 +46,6 @@ def main() -> None:
extra_compile_args=[
"-std=c17", "-D_GNU_SOURCE",
_make_d_features(flags),
*_make_d_flags(flags),
],
undef_macros=["NDEBUG"],
sources=_find_sources(),