tree: a4ff92645b3438f3129bc466eed4ab83dc949091 [path history] [tgz]
  1. BUILD.bazel
  2. debug.cc
  3. debug.conf
  4. nodebug.conf
  5. README.md
examples/hello_kconfig/README.md

Kconfig flag generation and usage

This example shows how Bazel flags can be generated from Kconfig values and used in conditional compilation. This relies on the root MODULE.bazel using the libkconfig and libproject_configs module extensions. libproject_configs is used to generate two repositories corresponding to examples/hello_kconfig:debug.conf and examples/hello_kconfig:nodebug.conf, respectively. The names of the generated repositories are @debug and @nodebug, coming from the project conf filename.

To use the generated Bazel flags, we load KCONFIG_FLAGS from @debug and @nodebug, respectively. This example provides two platforms, one with the debug flag and one without the debug flag.

To see the effect in conditional compilation, try these:

bazelisk build --verbose_failures --platforms=//examples/hello_kconfig:sample_platform_debug //exampl
es/hello_kconfig:debug
bazelisk build --verbose_failures --platforms=//examples/hello_kconfig:sample_platform_nodebug //exampl
es/hello_kconfig:debug

The first build will compile debug.cc while the second will not.