internal/rosa: toolchain type methods
All checks were successful
Test / Create distribution (push) Successful in 1m0s
Test / Sandbox (push) Successful in 2m39s
Test / Hakurei (push) Successful in 3m49s
Test / ShareFS (push) Successful in 4m4s
Test / Hpkg (push) Successful in 4m30s
Test / Sandbox (race detector) (push) Successful in 5m7s
Test / Hakurei (race detector) (push) Successful in 5m56s
Test / Flake checks (push) Successful in 1m44s

This improves readability for toolchain-specific checks.

Signed-off-by: Ophestra <cat@gensokyo.uk>
This commit is contained in:
2026-02-11 18:18:11 +09:00
parent 430e099556
commit 59ff6db7ec

View File

@@ -137,10 +137,40 @@ const (
_toolchainEnd
)
// isStage0 returns whether t is a stage0 toolchain.
func (t Toolchain) isStage0() bool {
switch t {
case toolchainGentoo, toolchainStage0:
return true
default:
return false
}
}
// isIntermediate returns whether t is an intermediate toolchain.
func (t Toolchain) isIntermediate() bool {
switch t {
case toolchainIntermediateGentoo, toolchainIntermediate:
return true
default:
return false
}
}
// isStd returns whether t is considered functionally equivalent to [Std].
func (t Toolchain) isStd() bool {
switch t {
case toolchainStdGentoo, Std:
return true
default:
return false
}
}
// stage0Concat concatenates s and values. If the current toolchain is
// toolchainStage0, stage0Concat returns s as is.
func stage0Concat[S ~[]E, E any](t Toolchain, s S, values ...E) S {
if t == toolchainStage0 || t == toolchainGentoo {
if t.isStage0() {
return s
}
return slices.Concat(s, values)
@@ -149,7 +179,7 @@ func stage0Concat[S ~[]E, E any](t Toolchain, s S, values ...E) S {
// stage0ExclConcat concatenates s and values. If the current toolchain is not
// toolchainStage0, stage0ExclConcat returns s as is.
func stage0ExclConcat[S ~[]E, E any](t Toolchain, s S, values ...E) S {
if t == toolchainStage0 || t == toolchainGentoo {
if t.isStage0() {
return slices.Concat(s, values)
}
return s
@@ -269,7 +299,7 @@ mkdir -vp /work/system/bin
case toolchainIntermediateGentoo, toolchainStdGentoo,
toolchainIntermediate, Std:
if t == toolchainIntermediateGentoo || t == toolchainIntermediate {
if t.isIntermediate() {
name += "-std"
}