internal/rosa: make helper
All checks were successful
Test / Create distribution (push) Successful in 1m0s
Test / Sandbox (push) Successful in 2m43s
Test / Hakurei (push) Successful in 3m52s
Test / ShareFS (push) Successful in 3m59s
Test / Hpkg (push) Successful in 4m25s
Test / Sandbox (race detector) (push) Successful in 5m1s
Test / Hakurei (race detector) (push) Successful in 5m57s
Test / Flake checks (push) Successful in 1m58s
All checks were successful
Test / Create distribution (push) Successful in 1m0s
Test / Sandbox (push) Successful in 2m43s
Test / Hakurei (push) Successful in 3m52s
Test / ShareFS (push) Successful in 3m59s
Test / Hpkg (push) Successful in 4m25s
Test / Sandbox (race detector) (push) Successful in 5m1s
Test / Hakurei (race detector) (push) Successful in 5m57s
Test / Flake checks (push) Successful in 1m58s
This change only migrates artifacts that remain unchanged under the helper, so this change should not cause any rebuilds. Signed-off-by: Ophestra <cat@gensokyo.uk>
This commit is contained in:
@@ -1,6 +1,11 @@
|
||||
package rosa
|
||||
|
||||
import "hakurei.app/internal/pkg"
|
||||
import (
|
||||
"slices"
|
||||
"strings"
|
||||
|
||||
"hakurei.app/internal/pkg"
|
||||
)
|
||||
|
||||
func (t Toolchain) newMake() pkg.Artifact {
|
||||
const (
|
||||
@@ -23,3 +28,105 @@ cd "$(mktemp -d)"
|
||||
)))
|
||||
}
|
||||
func init() { artifactsF[Make] = Toolchain.newMake }
|
||||
|
||||
// MakeAttr holds the project-specific attributes that will be applied to a new
|
||||
// [pkg.Artifact] compiled via [Make].
|
||||
type MakeAttr struct {
|
||||
// Mount the source tree writable.
|
||||
Writable bool
|
||||
|
||||
// Do not include default extras.
|
||||
OmitDefaults bool
|
||||
|
||||
// Additional environment variables.
|
||||
Env []string
|
||||
// Runs before cmake.
|
||||
ScriptEarly string
|
||||
// Runs after cmake.
|
||||
Script string
|
||||
|
||||
// Flags passed to the configure script.
|
||||
Configure [][2]string
|
||||
// Target triple, zero value is equivalent to the Rosa OS triple.
|
||||
Build string
|
||||
// Whether to skip the check target.
|
||||
SkipCheck bool
|
||||
|
||||
// Suffix appended to the source pathname.
|
||||
SourceSuffix string
|
||||
|
||||
// Passed through to [Toolchain.New].
|
||||
Flag int
|
||||
}
|
||||
|
||||
// NewViaMake returns a [pkg.Artifact] for compiling and installing via [Make].
|
||||
func (t Toolchain) NewViaMake(
|
||||
name, version string,
|
||||
source pkg.Artifact,
|
||||
attr *MakeAttr,
|
||||
extra ...pkg.Artifact,
|
||||
) pkg.Artifact {
|
||||
if name == "" || version == "" {
|
||||
panic("names must be non-empty")
|
||||
}
|
||||
if attr == nil {
|
||||
attr = new(MakeAttr)
|
||||
}
|
||||
build := `"${ROSA_TRIPLE}"`
|
||||
if attr.Build != "" {
|
||||
build = attr.Build
|
||||
}
|
||||
|
||||
var configureFlags string
|
||||
if len(attr.Configure) > 0 {
|
||||
const sep = " \\\n\t"
|
||||
configureFlags += sep + strings.Join(
|
||||
slices.Collect(func(yield func(string) bool) {
|
||||
for _, v := range attr.Configure {
|
||||
s := v[0]
|
||||
if v[1] == "" || (v[0] != "" &&
|
||||
v[0][0] >= 'a' &&
|
||||
v[0][0] <= 'z') {
|
||||
s = "--" + s
|
||||
}
|
||||
if v[1] != "" {
|
||||
s += "=" + v[1]
|
||||
}
|
||||
if !yield(s) {
|
||||
return
|
||||
}
|
||||
}
|
||||
}),
|
||||
sep,
|
||||
)
|
||||
}
|
||||
|
||||
defaults := []pkg.Artifact{
|
||||
t.Load(Make),
|
||||
}
|
||||
if attr.OmitDefaults || attr.Flag&TEarly == 0 {
|
||||
defaults = append(defaults,
|
||||
t.Load(Gawk),
|
||||
t.Load(Coreutils),
|
||||
)
|
||||
}
|
||||
|
||||
var makeSuffix string
|
||||
if !attr.SkipCheck {
|
||||
makeSuffix += " check"
|
||||
}
|
||||
|
||||
return t.New(name+"-"+version, attr.Flag, stage3Concat(t,
|
||||
defaults,
|
||||
extra...,
|
||||
), nil, attr.Env, attr.ScriptEarly+`
|
||||
cd "$(mktemp -d)"
|
||||
/usr/src/`+name+`/configure \
|
||||
--prefix=/system \
|
||||
--build=`+build+configureFlags+`
|
||||
make "-j$(nproc)"`+makeSuffix+`
|
||||
make DESTDIR=/work install
|
||||
`+attr.Script, pkg.Path(AbsUsrSrc.Append(
|
||||
name+attr.SourceSuffix,
|
||||
), attr.Writable, source))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user