Config/ Kconfig support (config)

Description

The config module provides access to config properties and the config database.

You may get access to the database by cogeno.configs().

Cogeno invocation options

--config:db FILE

Write or read config database to/ from FILE.

--config:file FILE

Read configuration variables from this FILE.

--config:kconfig-file FILE

Top-level Kconfig FILE (default: Kconfig).

--config:kconfig-srctree DIR

Kconfig files are looked up relative to the srctree DIR (unless absolute paths are used), and .config files are looked up relative to the srctree DIR if they are not found in the current directory.

--config:kconfig-defines DEFINE [DEFINE ...]

Define variable to Kconfig. We allow multiple.

--config:inputs FILE [FILE ...]

Read configuration file fragment from FILE. We allow multiple.

Code generation functions

There are convenience functions to access the config properties:

cogeno::stdmodules::StdModulesMixin.configs(self, force_extract=False)

Get the configuration variables database.

Return

Configuration variables database.

cogeno::stdmodules::StdModulesMixin.config_properties(self)

Get all config properties.

The property names are the ones config file.

Return

A dictionary of config properties.

cogeno::stdmodules::StdModulesMixin.config_property(self, property_name, default="<unset>")

Get the value of a configuration property fromthe config file.

If property_name is not given in .config the default value is returned.

Return

property value

Parameters
  • property_name: Name of the property

  • default: Property value to return per default.

The config database itself provides a more rich set of methods for configuration access:

cogeno.modules.config.ConfigDB : public object

Public Functions

generate(self, config_kconfig_file, config_kconfig_srctree, config_kconfig_defines=None, config_inputs=None, config_file=None)

Generate config database.

Parameters
  • config_kconfig_file: path of top-level Kconfig file

  • config_kconfig_srctree: path for relative lookup of files

  • config_kconfig_defines: optional, dictionary of variables to be defined to Kconfig

  • config_inputs: optional, list of configuration fragment file pathes

  • config_file: optional, config file path

load(self, file_path)

Load config database from JSON database file.

Parameters
  • file_path: Path of JSON file

save(self, file_path)

Save config database to JSON database file.

Parameters
  • file_path: Path of JSON file

extract(self, config_file)

Extract config database from config file.

The config file does not provide symbol information. symbols(), symbol_info() and kconfig_files() will not work on a database that was extracted from a config file.

Parameters
  • config_file: Path of config file

property(self, property_name, default='<unset>')

Get the value of a configuration property from .config.

If property_name is not given in the database the default value is returned.

Return

property value

Parameters
  • property_name: Name of the property (aka. symbol)

  • default: Property value to return per default.

properties(self)

Get all config properties.

The property names are the ones that are in the database.

Return

A dictionary of config properties.

symbols(self)

Get all config symbols.

Return

A dictionary of config symbols.

symbol_info(self, symbol_name, default='<unknown>')

Get the info of a configuration symbol.

If symbol_name is not available or Kconfig was not processed the default value is returned.

Return

symbol info

Parameters
  • symbol_name: Name of the configuration symbol

  • default: Symbol info to return per default.

kconfig_files(self)

Get all Kconfig files.

Get all Kconfig files used to generate() the database.

Return

A list of kconfig file pathes.