github.com/metux/go-metabuild@v0.0.0-20240118143255-d9ed5ab697f9/spec/buildconf/ac.go (about) 1 package buildconf 2 3 // autoconf style config.h 4 5 import ( 6 "fmt" 7 "strconv" 8 ) 9 10 const ( 11 KeyConfigH = Key("config.h") 12 ) 13 14 func (bc BuildConf) ACundef(sym string) { 15 if sym != "" { 16 bc.EntryStrListAppend(KeyConfigH, fmt.Sprintf("#undef CONFIG_%s", sym)) 17 } 18 } 19 20 func (bc BuildConf) ACraw(sym string, val string) { 21 if sym != "" { 22 bc.EntryStrListAppend(KeyConfigH, fmt.Sprintf("#define CONFIG_%s %s", sym, val)) 23 } 24 } 25 26 func (bc BuildConf) ACBool(sym string, val bool) { 27 if val { 28 bc.ACraw(sym, "1") 29 } else { 30 bc.ACundef(sym) 31 } 32 } 33 34 func (bc BuildConf) ACStr(sym string, val string) { 35 bc.ACraw(sym, strconv.Quote(val)) 36 } 37 38 func (bc BuildConf) ACLines() []string { 39 return bc.EntryStrList(KeyConfigH) 40 }