github.com/metux/go-metabuild@v0.0.0-20240118143255-d9ed5ab697f9/spec/buildconf/targetsys.go (about) 1 package buildconf 2 3 import ( 4 "github.com/metux/go-metabuild/spec/distro" 5 ) 6 7 // Keys underneath buildconf:: 8 const ( 9 KeyTargetDist = Key("@targetdist") 10 KeyTargetDistName = Key("@targetdistname") 11 KeyTargetDistArch = Key("@targetdistarch") 12 KeyTargetPlatform = Key("@target-platform") 13 ) 14 15 // store the probed target system 16 // FIXME: need to differenciate between host and build ? 17 func (bc BuildConf) SetTargetDist(dist string) { 18 bc.EntryPutStr(KeyTargetDistName, dist) 19 bc.EntryPutStr(KeyTargetDist, "${distro::"+dist+"}") 20 bc.EntryPutStr(KeyTargetPlatform, "${distro::"+dist+"::platform}") 21 22 // copy over install dirs 23 id := bc.EntrySpec(KeyInstallDirs) 24 id.CopyDefaultsFrom(bc.EntrySpec(KeyTargetDist.Append(KeyInstallDirs).MagicLiteralPost())) 25 } 26 27 func (bc BuildConf) SetTargetDistArch(arch string) { 28 bc.EntryPutStr(KeyTargetDistArch, arch) 29 } 30 31 // retrieve spec of the current target distro 32 func (bc BuildConf) TargetDistro() distro.Distro { 33 // explicitly giving the target dist name, since @@KEY won't work when using aliases 34 return distro.NewDistro(bc.EntrySpec(KeyTargetDist), bc.EntryStr(KeyTargetDistName)) 35 }