github.com/metux/go-metabuild@v0.0.0-20240118143255-d9ed5ab697f9/spec/buildconf/kconf.go (about) 1 package buildconf 2 3 // kernel/kconf style .config 4 5 import ( 6 "fmt" 7 ) 8 9 const ( 10 KeyKConf = Key("kconf") 11 ) 12 13 func (bc BuildConf) KConfUndef(sym string) { 14 if sym != "" { 15 bc.EntryStrListAppend(KeyKConf, fmt.Sprintf("# CONFIG_%s is not defined", sym)) 16 } 17 } 18 19 func (bc BuildConf) KConfRaw(sym string, val string) { 20 if sym != "" { 21 bc.EntryStrListAppend(KeyKConf, fmt.Sprintf("CONFIG_%s=%s", sym, val)) 22 } 23 } 24 25 func (bc BuildConf) KConfBool(sym string, val bool) { 26 if val { 27 bc.KConfRaw(sym, "y") 28 } else { 29 bc.KConfUndef(sym) 30 } 31 } 32 33 func (bc BuildConf) KConfStr(sym string, val string) { 34 if val != "" { 35 bc.KConfRaw(sym, val) 36 } else { 37 bc.KConfUndef(sym) 38 } 39 } 40 41 func (bc BuildConf) KConfLines() []string { 42 return bc.EntryStrList(KeyKConf) 43 }