Kconfig Support in build2
Posted on 19 Jan 2021
by
Boris Kolpackov
with comments on r/cpp/
The build2
toolchain now includes a build system module that
allows using the Linux kernel configuration system (Kconfig) to configure
build2
-based projects.
What is Kconfig?
Kconfig is the configuration system of the Linux kernel. Over the years it has evolved into a sophisticated variability modeling language and a toolset that are used by the Linux kernel to manage over ten thousand configuration options. It is also increasingly being used by other projects that need to manage complex configurations.
The Kconfig language defines a hierarchy of menus containing configuration options as well as relationships between them. For example:
config FANCY bool "Fancy options" help Enable more fancy configuration options. config GREETING string "Custom greeting" default "Hello" depends on FANCY help Custom string to use as a greeting.
To create and manage configurations, the Kconfig system includes a number of tools called configurators. These provide both interactive (terminal and graphical) and non-interactive (default, random, etc) configuration methods, support for updating old configurations to new definitions (both interactively and non), as well as other configuration management facilities (creation of default configurations, etc).
See What is Kconfig for a more detailed overview and examples.
What is build2
Kconfig module?
The build2
Kconfig module acts as a second-level
configuration mechanism to the builtin configuration support. Specifically,
it integrates the execution of one of the Kconfig configurators into the
build2
configure
meta-operation and loads the
resulting configuration file presenting its values as kconfig.*
variables. We can then use these kconfig.*
values to make
decisions in buildfiles
, testscripts
, and/or
propagate them to our source code, similar to the config.*
values (Project
Configuration).
See What
is build2
Kconfig module for a more detailed overview and
examples.
How to Try
The Kconfig functionality is available on all the supported platforms
(including Windows). The kconfig
module is part of the standard
pre-installed build2
modules and is available starting with
build2
version 0.14.0
. If you would like to try it
before 0.14.0
is released, use the staged version of the
toolchain.
To get started, refer to the Introduction
in The
build2
Kconfig Module manual as well as the kconfig-hello
example. See Kconfig
Language for the description of the language.