-
Notifications
You must be signed in to change notification settings - Fork 0
Description
Motivation
libiui currently uses GNU make combined with a customized Kconfiglib to manage configuration and conditional compilation. While this setup is functional, it has accumulated complexity in the Makefiles and limits extensibility, portability, and tooling integration.
This issue proposes migrating the build system to Meson, using muon as the implementation, while preserving Kconfiglib as the single source of truth for configuration.
The goal is a cleaner, more maintainable build system with minimal dependencies and no loss of configurability.
Why Meson + muon
Meson provides a well defined, declarative build description with strong support for:
- Cross compilation
- Feature detection
- Out of tree builds
muon is a lightweight, C99 implementation of Meson:
- Minimal dependencies
- Fast startup
Suitable for systems programming projects
The Meson language maps well to libiui’s current needs (static library, optional components, platform dependent sources)
Key Design Constraint: Keep Kconfiglib
Kconfig remains essential for libiui:
- Existing
.Kconfigfiles encode domain knowledge - Users are already familiar with
menuconfigstyle workflows - Feature selection logic should not be duplicated in Meson options
Therefore:
- Kconfiglib continues to generate configuration output
- Meson consumes generated artifacts instead of reimplementing configuration logic
Proposed Migration Strategy
1. Kconfiglib as a Pre Build Step
- Keep existing
Kconfigfiles unchanged - Run Kconfiglib before invoking Meson to produce:
config.h- Optionally a
config.mkorconfig.jsonstyle file
- Meson reads the generated outputs
Example flow:
$ python3 scripts/kconfig.py
$ muon setup build
$ muon compile -C build
2. Mapping Kconfig Symbols to Meson
Two practical approaches:
Option A: config.h only
- Meson builds all sources
- Conditional compilation handled via
#ifdef CONFIG_* - Simplest and lowest risk
Option B: Structured config export
- Kconfiglib exports a machine readable config file
- Meson selectively includes source files using
if get_option()style logic - Better build graph clarity, but more integration work
Initial migration can start with Option A and evolve later.
3. Meson Build Layout
Proposed minimal structure:
meson.build
meson_options.txt
src/meson.build
include/
scripts/
kconfig.py
Kconfig
meson.builddefines the library targetsrc/meson.buildlists all potential sources- Generated
config.hadded to include paths - Installation rules mirror current Makefile behavior
4. Toolchain and Cross Compilation
- Meson cross files replace Makefile toolchain variables
- Kconfiglib remains agnostic of compiler and linker
- This cleanly separates configuration from build mechanics
Benefits
- Reduced Makefile complexity
- Clear separation of:
- Configuration (Kconfig)
- Build description (Meson)
- Improved cross compilation support
- Faster iteration using muon
- Easier future integration with IDEs and static analysis tools
Non Goals
- No rewrite of Kconfig files
- No removal of menuconfig style workflows
- No dependency on Python at build time beyond existing Kconfiglib usage