kconfig

package
v0.0.0-...-3ba885b Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 30, 2024 License: Apache-2.0 Imports: 12 Imported by: 0

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

View Source
const (
	Yes = "y"
	Mod = "m"
	No  = "---===[[[is not set]]]===---" // to make it more obvious when some code writes it directly

)
View Source
const CauseConfigFile = "cause.config"

Variables

This section is empty.

Functions

func FuzzParseConfig

func FuzzParseConfig(data []byte) int

func FuzzParseExpr

func FuzzParseExpr(data []byte) int

func FuzzParseKConfig

func FuzzParseKConfig(data []byte) int

Types

type Config

type Config struct {
	Name  string
	Value string
	// contains filtered or unexported fields
}

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 Parse

func Parse(target *targets.Target, file string) (*KConfig, error)

func ParseData

func ParseData(target *targets.Target, data []byte, file string) (*KConfig, error)

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 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.

func (m *Menu) DependsOn() map[string]bool

DependsOn returns all transitive configs this config depends on.

func (m *Menu) Prompt() string
type MenuKind int
const (
	MenuConfig MenuKind
	MenuGroup
	MenuChoice
	MenuComment
)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL