1
0
forked from rosa/hakurei

internal/rosa/meson: optionally use muon

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" "strings"
) )
var _meson = H("meson") var (
_muon = H("muon")
_meson = H("meson")
)
// MesonHelper builds and tests a meson project. // MesonHelper builds and tests a meson project.
type MesonHelper struct { type MesonHelper struct {
// Use muon instead of meson.
Muon bool
// Runs after setup. // Runs after setup.
ScriptCompileEarly string ScriptCompileEarly string
// Runs after compile. // Runs after compile.
@@ -29,7 +35,12 @@ type MesonHelper struct {
var _ Helper = new(MesonHelper) var _ Helper = new(MesonHelper)
// extra returns hardcoded meson runtime dependencies. // 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. // wantsChmod returns false.
func (*MesonHelper) wantsChmod() bool { return false } func (*MesonHelper) wantsChmod() bool { return false }
@@ -43,6 +54,12 @@ func (*MesonHelper) scriptEarly() string { return "" }
// wantsDir requests a new directory in TMPDIR. // wantsDir requests a new directory in TMPDIR.
func (*MesonHelper) wantsDir() (string, bool) { return `"$(mktemp -d)"`, false } 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. // script generates the cure script.
func (attr *MesonHelper) script(t Toolchain, name string) string { func (attr *MesonHelper) script(t Toolchain, name string) string {
if attr == nil { if attr == nil {
@@ -54,13 +71,28 @@ func (attr *MesonHelper) script(t Toolchain, name string) string {
scriptCompiled = "\n" + scriptCompiled 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 var scriptTest string
if !attr.SkipTest && t.opts&OptSkipCheck == 0 { if !attr.SkipTest && t.opts&OptSkipCheck == 0 {
scriptTest = ` scriptTest = `
meson test \ ` + muon + ` test \
` + jobsFlagE + ` \ ` + jobsFlagE + ` \
-t 10 \ -t 10`
if python {
scriptTest += ` \
--print-errorlogs` --print-errorlogs`
} else {
scriptTest += " -Rv"
}
if attr.InteractiveTest { if attr.InteractiveTest {
scriptTest += ` \ scriptTest += ` \
--interactive` --interactive`
@@ -71,13 +103,12 @@ meson test \
} }
return ` return `
cd "$(mktemp -d)" ` + muon + ` 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([]KV{ for _, v := range append([]KV{
{"wrap-mode", "nofallback"}, {"Dwrap_mode", "nofallback"},
{"prefix", "/system"}, {"Dprefix", "/system"},
{"buildtype", "release"}, {"Dbuildtype", "release"},
}, attr.Setup...) { }, 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' {
@@ -91,11 +122,9 @@ meson setup \
} }
} }
}), " \\\n\t") + ` \ }), " \\\n\t") + ` \
. '/usr/src/` + name + `' '/usr/src/` + name + `'
meson compile \ ` + muon + compile + scriptCompiled + scriptTest + `
` + jobsFlagE + ` \ ` + muon + ` install \
` + loadFlagE + scriptCompiled + scriptTest + ` ` + destdir + ` /work
meson install \
--destdir=/work
` + attr.Script ` + 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 /usr/src/muon
/boot/muon-bootstrap samu `+jobsFlagE+` /boot/muon-bootstrap samu `+jobsFlagE+`
`; `;
check = "./muon test "+jobsFlagE+" -R\n"; check = "./muon test "+jobsFlagE+" -Rv\n";
install = "./muon install -d /work\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, python-early,
kernel-headers, kernel-headers,
]; ];
runtime = [ pkg-config ];
} }
+1
View File
@@ -878,6 +878,7 @@ func (s *S) getFrame() azalea.Frame {
) (v any, set bool, err error) { ) (v any, set bool, err error) {
var attr MesonHelper var attr MesonHelper
if err = args.Apply(map[unique.Handle[azalea.Ident]]any{ if err = args.Apply(map[unique.Handle[azalea.Ident]]any{
k("muon"): &attr.Muon,
k("preCompile"): &attr.ScriptCompileEarly, k("preCompile"): &attr.ScriptCompileEarly,
k("postCompile"): &attr.ScriptCompiled, k("postCompile"): &attr.ScriptCompiled,
k("postInstall"): &attr.Script, k("postInstall"): &attr.Script,