internal/rosa/cmake: optional variant string
All checks were successful
Test / Create distribution (push) Successful in 1m1s
Test / Sandbox (push) Successful in 2m35s
Test / Hakurei (push) Successful in 3m55s
Test / ShareFS (push) Successful in 4m11s
Test / Hpkg (push) Successful in 4m39s
Test / Sandbox (race detector) (push) Successful in 5m3s
Test / Hakurei (race detector) (push) Successful in 6m1s
Test / Flake checks (push) Successful in 1m44s

This improves consistency with other helpers and removes the usually unnecessary variant suffix.

Signed-off-by: Ophestra <cat@gensokyo.uk>
This commit is contained in:
2026-02-16 12:30:04 +09:00
parent a58c9258cc
commit 74dee11822
3 changed files with 15 additions and 5 deletions

View File

@@ -42,6 +42,9 @@ func init() { artifactsF[CMake] = Toolchain.newCMake }
// CMakeAttr holds the project-specific attributes that will be applied to a new
// [pkg.Artifact] compiled via [CMake].
type CMakeAttr struct {
// Joined with name with a dash if non-empty.
Variant string
// Path elements joined with source.
Append []string
// Use source tree as scratch space.
@@ -69,12 +72,12 @@ type CMakeAttr struct {
// NewViaCMake returns a [pkg.Artifact] for compiling and installing via [CMake].
func (t Toolchain) NewViaCMake(
name, version, variant string,
name, version string,
source pkg.Artifact,
attr *CMakeAttr,
extra ...pkg.Artifact,
) pkg.Artifact {
if name == "" || version == "" || variant == "" {
if name == "" || version == "" {
panic("names must be non-empty")
}
if attr == nil {
@@ -98,8 +101,13 @@ func (t Toolchain) NewViaCMake(
prefix = AbsSystem
}
rname := name
if attr.Variant != "" {
rname += "-" + attr.Variant
}
sourcePath := AbsUsrSrc.Append(name)
return t.New(name+"-"+variant+"-"+version, attr.Flag, stage0Concat(t, extra,
return t.New(rname+"-"+version, attr.Flag, stage0Concat(t, extra,
t.Load(CMake),
t.Load(Ninja),
), nil, slices.Concat([]string{