internal/rosa/meson: optionally use muon
Test / Create distribution (push) Successful in 58s
Test / Sandbox (push) Successful in 2m51s
Test / ShareFS (push) Successful in 3m54s
Test / Sandbox (race detector) (push) Successful in 5m33s
Test / Hakurei (race detector) (push) Successful in 6m44s
Test / Hakurei (push) Successful in 2m23s
Test / Flake checks (push) Successful in 1m8s

This is a much faster implementation free of python dependency hell, however currently fails to handle symbol visibility correctly, so unable to default to on. This change also cleans up some meson arguments.

Signed-off-by: Ophestra <cat@gensokyo.uk>
This commit is contained in:
2026-07-14 21:45:07 +09:00
parent fb3df67ba6
commit 098943ab46
3 changed files with 48 additions and 16 deletions
+44 -15
View File
@@ -5,10 +5,16 @@ import (
"strings"
)
var _meson = H("meson")
var (
_muon = H("muon")
_meson = H("meson")
)
// MesonHelper builds and tests a meson project.
type MesonHelper struct {
// Use muon instead of meson.
Muon bool
// Runs after setup.
ScriptCompileEarly string
// Runs after compile.
@@ -29,7 +35,12 @@ type MesonHelper struct {
var _ Helper = new(MesonHelper)
// extra returns hardcoded meson runtime dependencies.
func (*MesonHelper) extra(int) P { return P{_meson} }
func (attr *MesonHelper) extra(int) P {
if !attr.isPython() {
return P{_muon}
}
return P{_meson}
}
// wantsChmod returns false.
func (*MesonHelper) wantsChmod() bool { return false }
@@ -43,6 +54,12 @@ func (*MesonHelper) scriptEarly() string { return "" }
// wantsDir requests a new directory in TMPDIR.
func (*MesonHelper) wantsDir() (string, bool) { return `"$(mktemp -d)"`, false }
// isPython returns whether the legacy python implementation is used.
func (attr *MesonHelper) isPython() bool {
return attr != nil &&
(!attr.Muon || len(attr.SkipTests) != 0 || attr.InteractiveTest)
}
// script generates the cure script.
func (attr *MesonHelper) script(t Toolchain, name string) string {
if attr == nil {
@@ -54,13 +71,28 @@ func (attr *MesonHelper) script(t Toolchain, name string) string {
scriptCompiled = "\n" + scriptCompiled
}
python := attr.isPython()
muon := "muon"
compile := " samu " + jobsFlagE
destdir := "-d"
if python {
muon = "meson"
compile = " compile " + jobsFlagE + " " + loadFlagE
destdir = "--destdir"
}
var scriptTest string
if !attr.SkipTest && t.opts&OptSkipCheck == 0 {
scriptTest = `
meson test \
` + muon + ` test \
` + jobsFlagE + ` \
-t 10 \
-t 10`
if python {
scriptTest += ` \
--print-errorlogs`
} else {
scriptTest += " -Rv"
}
if attr.InteractiveTest {
scriptTest += ` \
--interactive`
@@ -71,13 +103,12 @@ meson test \
}
return `
cd "$(mktemp -d)"
meson setup \
` + muon + ` setup \
` + strings.Join(slices.Collect(func(yield func(string) bool) {
for _, v := range append([]KV{
{"wrap-mode", "nofallback"},
{"prefix", "/system"},
{"buildtype", "release"},
{"Dwrap_mode", "nofallback"},
{"Dprefix", "/system"},
{"Dbuildtype", "release"},
}, attr.Setup...) {
s := "-" + v[0]
if len(v[0]) > 0 && v[0][0] != 'D' {
@@ -91,11 +122,9 @@ meson setup \
}
}
}), " \\\n\t") + ` \
. '/usr/src/` + name + `'
meson compile \
` + jobsFlagE + ` \
` + loadFlagE + scriptCompiled + scriptTest + `
meson install \
--destdir=/work
'/usr/src/` + name + `'
` + muon + compile + scriptCompiled + scriptTest + `
` + muon + ` install \
` + destdir + ` /work
` + attr.Script
}
+3 -1
View File
@@ -49,7 +49,7 @@ sed -i '/common.220 fs module/d' subprojects/meson-tests/meson.build
/usr/src/muon
/boot/muon-bootstrap samu `+jobsFlagE+`
`;
check = "./muon test "+jobsFlagE+" -R\n";
check = "./muon test "+jobsFlagE+" -Rv\n";
install = "./muon install -d /work\n";
};
@@ -57,4 +57,6 @@ sed -i '/common.220 fs module/d' subprojects/meson-tests/meson.build
python-early,
kernel-headers,
];
runtime = [ pkg-config ];
}
+1
View File
@@ -878,6 +878,7 @@ func (s *S) getFrame() azalea.Frame {
) (v any, set bool, err error) {
var attr MesonHelper
if err = args.Apply(map[unique.Handle[azalea.Ident]]any{
k("muon"): &attr.Muon,
k("preCompile"): &attr.ScriptCompileEarly,
k("postCompile"): &attr.ScriptCompiled,
k("postInstall"): &attr.Script,