aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorOphestra <cat@gensokyo.uk>2026-05-19 19:28:18 +0900
committerOphestra <cat@gensokyo.uk>2026-05-19 19:28:18 +0900
commit548c96c7ec4a8c7c5abb4df1dac3d4a8671e2171 (patch)
treea6f586def327ab9c434bd6ef3a083d3cc1605b88
parent6e8bfa6c4c963ff6c7d417a1cc703e4504e1fb9d (diff)
internal/rosa/package: migrate make
This also introduces the generic helper for unusual build scripts. Signed-off-by: Ophestra <cat@gensokyo.uk>
-rw-r--r--internal/rosa/make.go32
-rw-r--r--internal/rosa/package/make.az26
-rw-r--r--internal/rosa/rosa.go50
-rw-r--r--internal/rosa/state.go17
-rw-r--r--internal/rosa/state_native.go1
5 files changed, 95 insertions, 31 deletions
diff --git a/internal/rosa/make.go b/internal/rosa/make.go
index 5803150e..eb7d7016 100644
--- a/internal/rosa/make.go
+++ b/internal/rosa/make.go
@@ -3,38 +3,10 @@ package rosa
import (
"slices"
"strings"
-
- "hakurei.app/internal/pkg"
)
-func (t Toolchain) newMake() (pkg.Artifact, string) {
- const (
- version = "4.4.1"
- checksum = "YS_B07ZcAy9PbaK5_vKGj64SrxO2VMpnMKfc9I0Q9IC1rn0RwOH7802pJoj2Mq4a"
- )
- return t.New("make-"+version, TEarly, nil, nil, nil, `
-cd "$(mktemp -d)"
-/usr/src/make/configure \
- --prefix=/system \
- --build="${ROSA_TRIPLE}" \
- --disable-dependency-tracking
-./build.sh
-./make DESTDIR=/work install
-`, pkg.Path(AbsUsrSrc.Append("make"), false, newTar(
- "https://ftpmirror.gnu.org/gnu/make/make-"+version+".tar.gz",
- checksum,
- pkg.TarGzip,
- ))), version
-}
-func init() {
- native.mustRegister(Toolchain.newMake, &Metadata{
- Name: "make",
- Description: "a tool which controls the generation of executables and other non-source files",
- Website: "https://www.gnu.org/software/make/",
-
- ID: 1877,
- })
-}
+// Make is the build system used by [MakeHelper].
+var Make = H("make")
// MakeHelper is the [Make] build system helper.
type MakeHelper struct {
diff --git a/internal/rosa/package/make.az b/internal/rosa/package/make.az
new file mode 100644
index 00000000..9d685a44
--- /dev/null
+++ b/internal/rosa/package/make.az
@@ -0,0 +1,26 @@
+package make {
+ description = "a tool which controls the generation of executables and other non-source files";
+ website = "https://www.gnu.org/software/make";
+ anitya = 1877;
+
+ version* = "4.4.1";
+ source = remoteTar {
+ url = "https://ftpmirror.gnu.org/gnu/make/make-"+version+".tar.gz";
+ checksum = "YS_B07ZcAy9PbaK5_vKGj64SrxO2VMpnMKfc9I0Q9IC1rn0RwOH7802pJoj2Mq4a";
+ compress = gzip;
+ };
+
+ toyboxEarly = true;
+
+ exec = generic {
+ mktemp = true;
+ build = `/usr/src/make/configure \
+ --prefix=/system \
+ --build="${ROSA_TRIPLE}" \
+ --disable-dependency-tracking
+./build.sh
+`;
+ // test suite wants perl
+ install = "./make DESTDIR=/work install\n";
+ };
+}
diff --git a/internal/rosa/rosa.go b/internal/rosa/rosa.go
index 44a463af..584678f5 100644
--- a/internal/rosa/rosa.go
+++ b/internal/rosa/rosa.go
@@ -544,6 +544,56 @@ cd '/usr/src/` + name + `/'
)
}
+// GenericHelper directly passes build script segments for invocations of
+// one-off build scripts too specific to fit into any other [Helper]
+// implementation, but can still benefit from [Toolchain.NewPackage].
+type GenericHelper struct {
+ // Whether to create and enter a directory in TMPDIR.
+ EnterTemp bool
+
+ // Concatenated for [Toolchain].
+ Build, Check, Install string
+}
+
+var _ Helper = new(GenericHelper)
+
+// extra is a noop.
+func (*GenericHelper) extra(int) P { return nil }
+
+// wantsChmod returns false.
+func (*GenericHelper) wantsChmod() bool { return false }
+
+// wantsWrite returns false.
+func (*GenericHelper) wantsWrite() bool { return false }
+
+// scriptEarly returns the zero value.
+func (*GenericHelper) scriptEarly() string { return "" }
+
+// createDir returns false.
+func (*GenericHelper) createDir() bool { return false }
+
+// wantsDir requests a new directory in TMPDIR, or the source directory otherwise.
+func (attr *GenericHelper) wantsDir() string {
+ if attr != nil && attr.EnterTemp {
+ return `"$(mktemp -d)"`
+ }
+ return ""
+}
+
+// script concatenates specified segments.
+func (attr *GenericHelper) script(t Toolchain, _ string) string {
+ if attr == nil {
+ attr = new(GenericHelper)
+ }
+
+ script := attr.Build
+ if t.opts&OptSkipCheck == 0 {
+ script += attr.Check
+ }
+ script += attr.Install
+ return script
+}
+
const (
// jobsE is expression for preferred job count set by [pkg].
jobsE = `"$` + pkg.EnvJobs + `"`
diff --git a/internal/rosa/state.go b/internal/rosa/state.go
index 87e27456..78da6817 100644
--- a/internal/rosa/state.go
+++ b/internal/rosa/state.go
@@ -624,6 +624,23 @@ func (s *S) getFrame() azalea.Frame {
// high-level helpers
+ k("generic"): {F: func(
+ args azalea.FArgs,
+ ) (v any, set bool, err error) {
+ var attr GenericHelper
+ if err = args.Apply(map[unique.Handle[azalea.Ident]]any{
+ k("mktemp"): &attr.EnterTemp,
+ k("build"): &attr.Build,
+ k("check"): &attr.Check,
+ k("install"): &attr.Install,
+ }); err != nil {
+ return
+ }
+ v = &attr
+ set = true
+ return
+ }},
+
k("make"): {F: func(
args azalea.FArgs,
) (v any, set bool, err error) {
diff --git a/internal/rosa/state_native.go b/internal/rosa/state_native.go
index 431b97cd..14e343de 100644
--- a/internal/rosa/state_native.go
+++ b/internal/rosa/state_native.go
@@ -101,7 +101,6 @@ var (
M4 = H("m4")
MPC = H("mpc")
MPFR = H("mpfr")
- Make = H("make")
Mesa = H("mesa")
Mksh = H("mksh")
MuslFts = H("musl-fts")