Get library compilation flags as a dict. Combines [all] + [library] + [build_modes. ]. If library_flags exists in build mode, it replaces both [library].compiler_flags and [build_modes].flags (allows per-mode library flag overrides, e.g. no LTO). Returns: {"define
(mode: str = "quick")
| 79 | |
| 80 | |
| 81 | def get_lib_compile_flags_dict(mode: str = "quick") -> dict[str, list[str]]: |
| 82 | """ |
| 83 | Get library compilation flags as a dict. |
| 84 | |
| 85 | Combines [all] + [library] + [build_modes.<mode>]. |
| 86 | If library_flags exists in build mode, it replaces both [library].compiler_flags |
| 87 | and [build_modes].flags (allows per-mode library flag overrides, e.g. no LTO). |
| 88 | |
| 89 | Returns: |
| 90 | {"defines": [...], "compiler_flags": [...]} |
| 91 | """ |
| 92 | config = _load_toml() |
| 93 | |
| 94 | defines = list(config.get("all", {}).get("defines", [])) |
| 95 | compiler_flags = list(config.get("all", {}).get("compiler_flags", [])) |
| 96 | |
| 97 | defines.extend(config.get("library", {}).get("defines", [])) |
| 98 | |
| 99 | build_mode_config = config.get("build_modes", {}).get(mode, {}) |
| 100 | # Use library-specific flags if available, otherwise fall back to |
| 101 | # [library].compiler_flags + build mode flags |
| 102 | library_mode_flags = build_mode_config.get("library_flags") |
| 103 | if library_mode_flags is not None: |
| 104 | compiler_flags.extend(library_mode_flags) |
| 105 | else: |
| 106 | compiler_flags.extend(config.get("library", {}).get("compiler_flags", [])) |
| 107 | compiler_flags.extend(build_mode_config.get("flags", [])) |
| 108 | |
| 109 | compiler_flags.extend(_lib_dwarf_prefix_map_flags(config, mode)) |
| 110 | |
| 111 | return {"defines": defines, "compiler_flags": compiler_flags} |
| 112 | |
| 113 | |
| 114 | def get_sketch_compile_flags_dict(mode: str = "quick") -> dict[str, list[str]]: |
no test coverage detected