internal/rosa/meson: migrate to helper interface
All checks were successful
Test / Create distribution (push) Successful in 57s
Test / Sandbox (push) Successful in 2m57s
Test / Hakurei (push) Successful in 4m4s
Test / ShareFS (push) Successful in 4m21s
Test / Sandbox (race detector) (push) Successful in 5m15s
Test / Hakurei (race detector) (push) Successful in 6m12s
Test / Flake checks (push) Successful in 1m26s

This change also removes some unused options.

Signed-off-by: Ophestra <cat@gensokyo.uk>
This commit is contained in:
2026-03-02 14:07:16 +09:00
parent 145ccd1c92
commit 04d9984da0
6 changed files with 123 additions and 124 deletions

View File

@@ -7,28 +7,27 @@ func (t Toolchain) newDTC() pkg.Artifact {
version = "1.7.2" version = "1.7.2"
checksum = "vUoiRynPyYRexTpS6USweT5p4SVHvvVJs8uqFkkVD-YnFjwf6v3elQ0-Etrh00Dt" checksum = "vUoiRynPyYRexTpS6USweT5p4SVHvvVJs8uqFkkVD-YnFjwf6v3elQ0-Etrh00Dt"
) )
return t.NewViaMeson("dtc", version, t.NewPatchedSource( return t.NewPackage("dtc", version, pkg.NewHTTPGetTar(
"dtc", version, pkg.NewHTTPGetTar( nil, "https://git.kernel.org/pub/scm/utils/dtc/dtc.git/snapshot/"+
nil, "https://git.kernel.org/pub/scm/utils/dtc/dtc.git/snapshot/"+ "dtc-v"+version+".tar.gz",
"dtc-v"+version+".tar.gz", mustDecode(checksum),
mustDecode(checksum), pkg.TarGzip,
pkg.TarGzip, ), &PackageAttr{
), false,
), &MesonAttr{
// works around buggy test: // works around buggy test:
// fdtdump-runtest.sh /usr/src/dtc/tests/fdtdump.dts // fdtdump-runtest.sh /usr/src/dtc/tests/fdtdump.dts
Writable: true, Writable: true,
Chmod: true,
Configure: [][2]string{ }, &MesonHelper{
Setup: [][2]string{
{"Dyaml", "disabled"}, {"Dyaml", "disabled"},
{"Dstatic-build", "true"}, {"Dstatic-build", "true"},
}, },
}, },
t.Load(Flex), Flex,
t.Load(Bison), Bison,
t.Load(M4), M4,
t.Load(Coreutils), Coreutils,
t.Load(Diffutils), Diffutils,
) )
} }
func init() { artifactsF[DTC] = Toolchain.newDTC } func init() { artifactsF[DTC] = Toolchain.newDTC }

View File

@@ -7,13 +7,13 @@ func (t Toolchain) newFuse() pkg.Artifact {
version = "3.18.1" version = "3.18.1"
checksum = "COb-BgJRWXLbt9XUkNeuiroQizpMifXqxgieE1SlkMXhs_WGSyJStrmyewAw2hd6" checksum = "COb-BgJRWXLbt9XUkNeuiroQizpMifXqxgieE1SlkMXhs_WGSyJStrmyewAw2hd6"
) )
return t.NewViaMeson("fuse", version, pkg.NewHTTPGetTar( return t.NewPackage("fuse", version, pkg.NewHTTPGetTar(
nil, "https://github.com/libfuse/libfuse/releases/download/"+ nil, "https://github.com/libfuse/libfuse/releases/download/"+
"fuse-"+version+"/fuse-"+version+".tar.gz", "fuse-"+version+"/fuse-"+version+".tar.gz",
mustDecode(checksum), mustDecode(checksum),
pkg.TarGzip, pkg.TarGzip,
), &MesonAttr{ ), nil, &MesonHelper{
Configure: [][2]string{ Setup: [][2]string{
{"Ddefault_library", "both"}, {"Ddefault_library", "both"},
{"Dtests", "true"}, {"Dtests", "true"},
{"Duseroot", "false"}, {"Duseroot", "false"},
@@ -22,15 +22,15 @@ func (t Toolchain) newFuse() pkg.Artifact {
ScriptCompiled: "python3 -m pytest test/", ScriptCompiled: "python3 -m pytest test/",
// this project uses pytest // this project uses pytest
SkipCheck: true, SkipTest: true,
}, },
t.Load(IniConfig), IniConfig,
t.Load(Packaging), Packaging,
t.Load(Pluggy), Pluggy,
t.Load(Pygments), Pygments,
t.Load(PyTest), PyTest,
t.Load(KernelHeaders), KernelHeaders,
) )
} }
func init() { artifactsF[Fuse] = Toolchain.newFuse } func init() { artifactsF[Fuse] = Toolchain.newFuse }

View File

@@ -12,21 +12,13 @@ func (t Toolchain) newGLib() pkg.Artifact {
version = "2.86.4" version = "2.86.4"
checksum = "AfTjBrrxtXXPL6dFa1LfTe40PyPSth62CoIkM5m_VJTUngGLOFHw6I4XE7RGQE8G" checksum = "AfTjBrrxtXXPL6dFa1LfTe40PyPSth62CoIkM5m_VJTUngGLOFHw6I4XE7RGQE8G"
) )
return t.NewViaMeson("glib", version, pkg.NewHTTPGet( return t.NewPackage("glib", version, pkg.NewHTTPGet(
nil, "https://download.gnome.org/sources/glib/"+ nil, "https://download.gnome.org/sources/glib/"+
strings.Join(strings.SplitN(version, ".", 3)[:2], ".")+ strings.Join(strings.SplitN(version, ".", 3)[:2], ".")+
"/glib-"+version+".tar.xz", "/glib-"+version+".tar.xz",
mustDecode(checksum), mustDecode(checksum),
), &MesonAttr{ ), &PackageAttr{
SourceSuffix: ".tar.xz", SourceKind: sourceTarXZ,
ScriptEarly: `
cd /usr/src/
tar xf glib.tar.xz
mv glib-` + version + ` glib
`,
Configure: [][2]string{
{"Ddefault_library", "both"},
},
Paths: []pkg.ExecPath{ Paths: []pkg.ExecPath{
pkg.Path(fhs.AbsEtc.Append( pkg.Path(fhs.AbsEtc.Append(
@@ -42,14 +34,18 @@ mv glib-` + version + ` glib
[]byte("fefefefefefefefefefefefefefefefe\n"), []byte("fefefefefefefefefefefefefefefefe\n"),
)), )),
}, },
}, &MesonHelper{
Setup: [][2]string{
{"Ddefault_library", "both"},
},
}, },
t.Load(XZ), XZ,
t.Load(Packaging), Packaging,
t.Load(Bash), Bash,
t.Load(PCRE2), PCRE2,
t.Load(Libffi), Libffi,
t.Load(Zlib), Zlib,
) )
} }
func init() { artifactsF[GLib] = Toolchain.newGLib } func init() { artifactsF[GLib] = Toolchain.newGLib }

View File

@@ -7,13 +7,13 @@ func (t Toolchain) newKmod() pkg.Artifact {
version = "34.2" version = "34.2"
checksum = "0K7POeTKxMhExsaTsnKAC6LUNsRSfe6sSZxWONPbOu-GI_pXOw3toU_BIoqfBhJV" checksum = "0K7POeTKxMhExsaTsnKAC6LUNsRSfe6sSZxWONPbOu-GI_pXOw3toU_BIoqfBhJV"
) )
return t.NewViaMeson("kmod", version, pkg.NewHTTPGetTar( return t.NewPackage("kmod", version, pkg.NewHTTPGetTar(
nil, "https://www.kernel.org/pub/linux/utils/kernel/"+ nil, "https://www.kernel.org/pub/linux/utils/kernel/"+
"kmod/kmod-"+version+".tar.gz", "kmod/kmod-"+version+".tar.gz",
mustDecode(checksum), mustDecode(checksum),
pkg.TarGzip, pkg.TarGzip,
), &MesonAttr{ ), nil, &MesonHelper{
Configure: [][2]string{ Setup: [][2]string{
{"Dsysconfdir", "/system/etc"}, {"Dsysconfdir", "/system/etc"},
{"Dbashcompletiondir", "no"}, {"Dbashcompletiondir", "no"},
{"Dfishcompletiondir", "no"}, {"Dfishcompletiondir", "no"},
@@ -22,12 +22,12 @@ func (t Toolchain) newKmod() pkg.Artifact {
}, },
// makes assumptions about the running kernel // makes assumptions about the running kernel
SkipCheck: true, SkipTest: true,
}, },
t.Load(Zlib), Zlib,
t.Load(Zstd), Zstd,
t.Load(OpenSSL), OpenSSL,
t.Load(KernelHeaders), KernelHeaders,
) )
} }
func init() { artifactsF[Kmod] = Toolchain.newKmod } func init() { artifactsF[Kmod] = Toolchain.newKmod }

View File

@@ -31,49 +31,59 @@ python3 setup.py \
} }
func init() { artifactsF[Meson] = Toolchain.newMeson } func init() { artifactsF[Meson] = Toolchain.newMeson }
// MesonAttr holds the project-specific attributes that will be applied to a new // MesonHelper is the [Meson] build system helper.
// [pkg.Artifact] compiled via [Meson]. type MesonHelper struct {
type MesonAttr struct { // Runs after setup.
// Mount the source tree writable. ScriptCompileEarly string
Writable bool // Runs after compile.
// Additional environment variables.
Env []string
// Runs before setup.
ScriptEarly string
// Runs after configure.
ScriptCompiled string ScriptCompiled string
// Runs after install. // Runs after install.
Script string Script string
// Flags passed to the setup command. // Flags passed to the setup command.
Configure [][2]string Setup [][2]string
// Whether to skip meson test. // Whether to skip meson test.
SkipCheck bool SkipTest bool
// Appended after the test command.
AppendTest string
// Suffix appended to the source pathname.
SourceSuffix string
// Passed through to [Toolchain.New], before source.
Paths []pkg.ExecPath
// Passed through to [Toolchain.New].
Flag int
} }
// NewViaMeson returns a [pkg.Artifact] for compiling and installing via [Meson]. var _ Helper = new(MesonHelper)
func (t Toolchain) NewViaMeson(
name, version string, // name returns its arguments joined with '-'.
source pkg.Artifact, func (*MesonHelper) name(name, version string) string {
attr *MesonAttr, return name + "-" + version
extra ...pkg.Artifact, }
) pkg.Artifact {
if name == "" || version == "" { // extra returns hardcoded meson runtime dependencies.
panic("names must be non-empty") func (*MesonHelper) extra(int) []PArtifact {
return []PArtifact{
Python,
Meson,
Ninja,
PkgConfig,
CMake,
} }
}
// wantsChmod returns false.
func (*MesonHelper) wantsChmod() bool { return false }
// wantsWrite returns false.
func (*MesonHelper) wantsWrite() bool { return false }
// scriptEarly returns the zero value.
func (*MesonHelper) scriptEarly() string { return "" }
// createDir returns false.
func (*MesonHelper) createDir() bool { return false }
// wantsDir requests a new directory in TMPDIR.
func (*MesonHelper) wantsDir() string { return `"$(mktemp -d)"` }
// script generates the cure script.
func (attr *MesonHelper) script(name string) string {
if attr == nil { if attr == nil {
attr = new(MesonAttr) attr = new(MesonHelper)
} }
scriptCompiled := attr.ScriptCompiled scriptCompiled := attr.ScriptCompiled
@@ -81,26 +91,21 @@ func (t Toolchain) NewViaMeson(
scriptCompiled = "\n" + scriptCompiled scriptCompiled = "\n" + scriptCompiled
} }
var check string var scriptTest string
if !attr.SkipCheck { if !attr.SkipTest {
check = "\nmeson test \\\n\t--print-errorlogs" + attr.AppendTest scriptTest = `
meson test \
--print-errorlogs`
} }
return t.New(name+"-"+version, attr.Flag, slices.Concat([]pkg.Artifact{ return `
t.Load(Python),
t.Load(Meson),
t.Load(Ninja),
t.Load(PkgConfig),
t.Load(CMake),
}, extra), nil, attr.Env, attr.ScriptEarly+`
cd "$(mktemp -d)" cd "$(mktemp -d)"
meson setup \ meson setup \
`+strings.Join(slices.Collect(func(yield func(string) bool) { ` + strings.Join(slices.Collect(func(yield func(string) bool) {
for _, v := range append([][2]string{ for _, v := range append([][2]string{
{"prefix", "/system"}, {"prefix", "/system"},
{"buildtype", "release"}, {"buildtype", "release"},
}, attr.Configure...) { }, attr.Setup...) {
s := "-" + v[0] s := "-" + v[0]
if len(v[0]) > 0 && v[0][0] != 'D' { if len(v[0]) > 0 && v[0][0] != 'D' {
s = "-" + s s = "-" + s
@@ -112,14 +117,10 @@ meson setup \
return return
} }
} }
}), " \\\n\t")+` \ }), " \\\n\t") + ` \
. /usr/src/`+name+` . '/usr/src/` + name + `'
meson compile`+scriptCompiled+check+` meson compile` + scriptCompiled + scriptTest + `
meson install \ meson install \
--destdir=/work --destdir=/work
`+attr.Script, slices.Concat(attr.Paths, []pkg.ExecPath{ ` + attr.Script
pkg.Path(AbsUsrSrc.Append(
name+attr.SourceSuffix,
), attr.Writable, source),
})...)
} }

View File

@@ -7,30 +7,31 @@ func (t Toolchain) newWayland() pkg.Artifact {
version = "1.24.0" version = "1.24.0"
checksum = "JxgLiFRRGw2D3uhVw8ZeDbs3V7K_d4z_ypDog2LBqiA_5y2vVbUAk5NT6D5ozm0m" checksum = "JxgLiFRRGw2D3uhVw8ZeDbs3V7K_d4z_ypDog2LBqiA_5y2vVbUAk5NT6D5ozm0m"
) )
return t.NewViaMeson("wayland", version, pkg.NewHTTPGetTar( return t.NewPackage("wayland", version, pkg.NewHTTPGetTar(
nil, "https://gitlab.freedesktop.org/wayland/wayland/"+ nil, "https://gitlab.freedesktop.org/wayland/wayland/"+
"-/archive/"+version+"/wayland-"+version+".tar.bz2", "-/archive/"+version+"/wayland-"+version+".tar.bz2",
mustDecode(checksum), mustDecode(checksum),
pkg.TarBzip2, pkg.TarBzip2,
), &MesonAttr{ ), &PackageAttr{
Writable: true, Writable: true,
ScriptEarly: ` ScriptEarly: `
cd /usr/src/wayland cd /usr/src/wayland
chmod +w tests tests/sanity-test.c chmod +w tests tests/sanity-test.c
echo 'int main(){}' > tests/sanity-test.c echo 'int main(){}' > tests/sanity-test.c
`, `,
Configure: [][2]string{ }, &MesonHelper{
Setup: [][2]string{
{"Ddefault_library", "both"}, {"Ddefault_library", "both"},
{"Ddocumentation", "false"}, {"Ddocumentation", "false"},
{"Dtests", "true"}, {"Dtests", "true"},
}, },
}, },
t.Load(Gawk), Gawk,
t.Load(Diffutils), Diffutils,
t.Load(Libffi), Libffi,
t.Load(Libexpat), Libexpat,
t.Load(Libxml2), Libxml2,
) )
} }
func init() { artifactsF[Wayland] = Toolchain.newWayland } func init() { artifactsF[Wayland] = Toolchain.newWayland }
@@ -40,13 +41,14 @@ func (t Toolchain) newWaylandProtocols() pkg.Artifact {
version = "1.47" version = "1.47"
checksum = "B_NodZ7AQfCstcx7kgbaVjpkYOzbAQq0a4NOk-SA8bQixAE20FY3p1-6gsbPgHn9" checksum = "B_NodZ7AQfCstcx7kgbaVjpkYOzbAQq0a4NOk-SA8bQixAE20FY3p1-6gsbPgHn9"
) )
return t.NewViaMeson("wayland-protocols", version, t.NewPatchedSource( return t.NewPackage("wayland-protocols", version, pkg.NewHTTPGetTar(
"wayland-protocols", version, pkg.NewHTTPGetTar( nil, "https://gitlab.freedesktop.org/wayland/wayland-protocols/"+
nil, "https://gitlab.freedesktop.org/wayland/wayland-protocols/"+ "-/archive/"+version+"/wayland-protocols-"+version+".tar.bz2",
"-/archive/"+version+"/wayland-protocols-"+version+".tar.bz2", mustDecode(checksum),
mustDecode(checksum), pkg.TarBzip2,
pkg.TarBzip2, ), &PackageAttr{
), false, [2]string{"build-only", `From 8b4c76275fa1b6e0a99a53494151d9a2c907144d Mon Sep 17 00:00:00 2001 Patches: [][2]string{
{"build-only", `From 8b4c76275fa1b6e0a99a53494151d9a2c907144d Mon Sep 17 00:00:00 2001
From: "A. Wilcox" <AWilcox@Wilcox-Tech.com> From: "A. Wilcox" <AWilcox@Wilcox-Tech.com>
Date: Fri, 8 Nov 2024 11:27:25 -0600 Date: Fri, 8 Nov 2024 11:27:25 -0600
Subject: [PATCH] tests: Make build-only tests actually build-only Subject: [PATCH] tests: Make build-only tests actually build-only
@@ -97,11 +99,12 @@ index aa216ec2..5a93bb36 100644
-- --
GitLab GitLab
`}, `},
), nil, },
t.Load(Wayland), }, (*MesonHelper)(nil),
t.Load(Libffi), Wayland,
t.Load(Libexpat), Libffi,
t.Load(Libxml2), Libexpat,
Libxml2,
) )
} }
func init() { artifactsF[WaylandProtocols] = Toolchain.newWaylandProtocols } func init() { artifactsF[WaylandProtocols] = Toolchain.newWaylandProtocols }