Documentation ¶
Overview ¶
Package kconfig implements parsing of the Linux kernel Kconfig and .config files and provides some algorithms to work with these files. For Kconfig reference see: https://www.kernel.org/doc/html/latest/kbuild/kconfig-language.html
Index ¶
Constants ¶
const ( Yes = "y" Mod = "m" No = "---===[[[is not set]]]===---" // to make it more obvious when some code writes it directly )
const CauseConfigFile = "cause.config"
Variables ¶
This section is empty.
Functions ¶
func FuzzParseConfig ¶
func FuzzParseExpr ¶
func FuzzParseKConfig ¶
Types ¶
type ConfigFile ¶
type ConfigFile struct { Configs []*Config Map map[string]*Config // duplicates Configs for convenience // contains filtered or unexported fields }
ConfigFile represents a parsed .config file. It should not be modified directly, only by means of calling methods. The only exception is Config.Value which may be modified directly. Note: config names don't include CONFIG_ prefix, here and in other public interfaces, users of this package should never mention CONFIG_. Use Yes/Mod/No consts to check for/set config to particular values.
func ParseConfig ¶
func ParseConfig(file string) (*ConfigFile, error)
func ParseConfigData ¶
func ParseConfigData(data []byte, file string) (*ConfigFile, error)
func (*ConfigFile) Clone ¶
func (cf *ConfigFile) Clone() *ConfigFile
func (*ConfigFile) ModToNo ¶
func (cf *ConfigFile) ModToNo()
func (*ConfigFile) ModToYes ¶
func (cf *ConfigFile) ModToYes()
func (*ConfigFile) Serialize ¶
func (cf *ConfigFile) Serialize() []byte
func (*ConfigFile) Set ¶
func (cf *ConfigFile) Set(name, val string)
Set changes config value, or adds it if it's not yet present.
func (*ConfigFile) Unset ¶
func (cf *ConfigFile) Unset(name string)
Unset sets config value to No, if it's present in the config.
func (*ConfigFile) Value ¶
func (cf *ConfigFile) Value(name string) string
Value returns config value, or No if it's not present at all.
type ConfigType ¶
type ConfigType int
const ( TypeBool ConfigType TypeTristate TypeString TypeInt TypeHex )
type KConfig ¶
type KConfig struct { Root *Menu // mainmenu Configs map[string]*Menu // only config/menuconfig entries }
KConfig represents a parsed Kconfig file (including includes).
func (*KConfig) Minimize ¶
func (kconf *KConfig) Minimize(base, full *ConfigFile, pred func(*ConfigFile) (bool, error), maxSteps int, dt debugtracer.DebugTracer) (*ConfigFile, error)
Minimize finds an equivalent with respect to the provided predicate, but smaller config. It accepts base (small) and full (large) config. It is assumed that the predicate returns true for the full config. It is also assumed that base and full are not just two completely arbitrary configs, but full it produced from base mostly by adding more configs. The minimization procedure thus consists of figuring out what set of configs that are present in full and are not present in base affect the predicate. If maxPredRuns is non-zero, minimization will stop after the specified number of runs.
type Menu ¶
type Menu struct { Kind MenuKind // config/menu/choice/etc Type ConfigType // tristate/bool/string/etc Name string // name without CONFIG_ Elems []*Menu // sub-elements for menus Parent *Menu // parent menu, non-nil for everythign except for mainmenu // contains filtered or unexported fields }
Menu represents a single hierarchical menu or config.