diff options
| author | Ophestra <cat@gensokyo.uk> | 2026-02-11 18:18:11 +0900 |
|---|---|---|
| committer | Ophestra <cat@gensokyo.uk> | 2026-02-11 18:18:11 +0900 |
| commit | 59ff6db7ec627bd8237b9508ef78c65204971cfc (patch) | |
| tree | f09b398f675086a5238d4742b1c7d80754a9eb34 /internal | |
| parent | 430e099556655f4db36f22f4597051d910bd39c1 (diff) | |
internal/rosa: toolchain type methods
This improves readability for toolchain-specific checks.
Signed-off-by: Ophestra <cat@gensokyo.uk>
Diffstat (limited to 'internal')
| -rw-r--r-- | internal/rosa/rosa.go | 36 |
1 files changed, 33 insertions, 3 deletions
diff --git a/internal/rosa/rosa.go b/internal/rosa/rosa.go index e9e720fa..1e02fac2 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" } |
