kconfig

package
v0.5.0-115-g8d4f1a1 Latest Latest
Warning

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

Go to latest
Published: Apr 27, 2023 License: BSD-3-Clause Imports: 8 Imported by: 1

Documentation

Index

Constants

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

Variables

This section is empty.

Functions

This section is empty.

Types

type ConfigType

type ConfigType int
const (
	TypeBool ConfigType
	TypeTristate
	TypeString
	TypeInt
	TypeHex
)

type DotConfigFile

type DotConfigFile struct {
	Slice []*KeyValue
	Map   KeyValueMap // duplicates Configs for convenience
	// contains filtered or unexported fields
}

DotConfigFile 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) (*DotConfigFile, error)

func ParseConfigData

func ParseConfigData(data []byte, file string) (*DotConfigFile, error)

func (*DotConfigFile) Clone

func (cf *DotConfigFile) Clone() *DotConfigFile

func (*DotConfigFile) ModToNo

func (cf *DotConfigFile) ModToNo()

func (*DotConfigFile) ModToYes

func (cf *DotConfigFile) ModToYes()

func (*DotConfigFile) Serialize

func (cf *DotConfigFile) Serialize() []byte

func (*DotConfigFile) Set

func (cf *DotConfigFile) Set(name, val string)

Set changes config value, or adds it if it's not yet present.

func (*DotConfigFile) Unset

func (cf *DotConfigFile) Unset(name string)

Unset sets config value to No, if it's present in the config.

func (*DotConfigFile) Value

func (cf *DotConfigFile) Value(name string) string

Value returns config value, or No if it's not present at all.

type KConfigFile

type KConfigFile struct {
	Root    *KConfigMenu            // mainmenu
	Configs map[string]*KConfigMenu // only config/menuconfig entries
}

KConfigFile represents a parsed Kconfig file (including includes).

func Parse

func Parse(file string, env ...*KeyValue) (*KConfigFile, error)

func ParseData

func ParseData(data []byte, file string, extra ...*KeyValue) (*KConfigFile, error)

type KConfigMenu

type KConfigMenu struct {
	Kind   MenuKind       // config/menu/choice/etc
	Type   ConfigType     // tristate/bool/string/etc
	Name   string         // name without CONFIG_
	Elems  []*KConfigMenu // sub-elements for menus
	Parent *KConfigMenu   // parent menu, non-nil for everythign except for mainmenu
	// contains filtered or unexported fields
}

Menu represents a single hierarchical menu or config.

func (*KConfigMenu) DependsOn

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

DependsOn returns all transitive configs this config depends on.

func (*KConfigMenu) Prompt

func (m *KConfigMenu) Prompt() string

type KeyValue added in v0.4.0

type KeyValue struct {
	Key   string
	Value string
	// contains filtered or unexported fields
}

KeyValue represents a KConfig option with its name and its value.

func NewKeyValue added in v0.5.0

func NewKeyValue(line string) (string, *KeyValue)

NewKeyValue returns a populated KeyValue by parsing the input line

func (KeyValue) String added in v0.5.0

func (kv KeyValue) String() string

String implements fmt.Stringer

type KeyValueMap added in v0.4.0

type KeyValueMap map[string]*KeyValue

KeyValueMap is a map of KeyValues

func NewKeyValueMapFromFile added in v0.5.0

func NewKeyValueMapFromFile(file string) (KeyValueMap, error)

NewKConfigValuesFromFile build a KConfigValues from a provided file path

func NewKeyValueMapFromMap added in v0.4.0

func NewKeyValueMapFromMap(values map[string]interface{}) KeyValueMap

NewKeyValueMapFromMap build a new Mapping from a set of KEY=VALUE strings

func NewKeyValueMapFromSlice added in v0.4.0

func NewKeyValueMapFromSlice(values ...interface{}) KeyValueMap

NewKeyValueMapFromSlice build a new Mapping from a set of KEY=VALUE strings

func (KeyValueMap) Get added in v0.5.0

func (kvm KeyValueMap) Get(key string) (*KeyValue, bool)

Get returns a KeyValue based on a key and a boolean result value if the entries was resolvable.

func (KeyValueMap) Override added in v0.4.0

func (kvm KeyValueMap) Override(extra ...*KeyValue) KeyValueMap

Override accepts a list of key value pairs and overrides the key in the map

func (KeyValueMap) OverrideBy added in v0.4.0

func (kvm KeyValueMap) OverrideBy(other KeyValueMap) KeyValueMap

OverrideBy update KeyValueMap with values from another KeyValueMap

func (KeyValueMap) RemoveEmpty added in v0.4.0

func (kvm KeyValueMap) RemoveEmpty() KeyValueMap

RemoveEmpty excludes keys that are not associated with a value

func (KeyValueMap) Resolve added in v0.4.0

func (kvm KeyValueMap) Resolve(lookupFn func(string) (string, bool)) KeyValueMap

Resolve update a KConfig for keys without value (`key`, but not `key=`)

func (KeyValueMap) Set added in v0.4.0

func (kvm KeyValueMap) Set(key, value string) KeyValueMap

Set a new key with specified value

func (KeyValueMap) Slice added in v0.4.0

func (kvm KeyValueMap) Slice() []*KeyValue

Slice returns the map as a slice

func (KeyValueMap) String added in v0.4.0

func (kvm KeyValueMap) String() string

String returns the serialized string representing a .config file

func (KeyValueMap) Unset added in v0.4.0

func (kvm KeyValueMap) Unset(key string) KeyValueMap

Unset a specific key

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