diff --git a/internal/rosa/rosa.go b/internal/rosa/rosa.go index e9e720f..1e02fac 100644 --- a/internal/rosa/rosa.go +++ b/internal/rosa/rosa.go @@ -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" }