diff options
Diffstat (limited to 'internal/rosa/meson.go')
| -rw-r--r-- | internal/rosa/meson.go | 64 |
1 files changed, 55 insertions, 9 deletions
diff --git a/internal/rosa/meson.go b/internal/rosa/meson.go index 25291dd0..59029595 100644 --- a/internal/rosa/meson.go +++ b/internal/rosa/meson.go @@ -3,6 +3,8 @@ package rosa import ( "slices" "strings" + + "hakurei.app/pkg" ) var ( @@ -35,11 +37,54 @@ type MesonHelper struct { var _ Helper = new(MesonHelper) // tools returns hardcoded meson runtime dependencies. -func (attr *MesonHelper) tools() P { - if !attr.isPython() { - return P{_muon} +func (attr *MesonHelper) tools(t Toolchain) P { + m := _muon + if attr.isPython() { + m = _meson + } + if t.cross() { + return P{m, _qemu} } - return P{_meson} + return P{m} +} + +// paths returns the cross-compiler mfile, or nil if not cross-compiling. +func (*MesonHelper) paths(t Toolchain) []pkg.ExecPath { + if !t.cross() { + return nil + } + + arch, mesonArch, target := t.Arch(), t.linuxArch(), t.triple() + return []pkg.ExecPath{pkg.Path( + AbsSystem.Append("mfile"), + false, pkg.NewFile("mfile-"+arch, []byte(`# meson env2mfile +[binaries] +# Compilers +c = ['clang', '--target=`+target+`', '--sysroot=/system/`+arch+`'] +cpp = ['clang++', '--target=`+target+`', '--sysroot=/system/`+arch+`'] +pkg-config = ['pkg-config'] +exe_wrapper = ['qemu-`+mesonArch+`', '-L', '/system/`+arch+`'] + +# Other binaries +ar = ['llvm-ar'] +ranlib = ['llvm-ranlib'] +strip = ['llvm-strip'] + +[built-in options] + +[properties] +sys_root = '/system/`+arch+`' +pkg_config_libdir = '/system/`+arch+`/system/lib/pkgconfig' + +[host_machine] +cpu = '`+mesonArch+`' +cpu_family = '`+mesonArch+`' +endian = 'little' +system = 'linux' +subsystem = 'linux' +kernel = 'linux' +`)), + )} } // inputs is a noop. @@ -65,10 +110,6 @@ func (attr *MesonHelper) isPython() bool { // script generates the cure script. func (attr *MesonHelper) script(t Toolchain, name string) string { - if t.cross() { - panic(CrossError(name)) - } - if attr == nil { attr = new(MesonHelper) } @@ -109,8 +150,13 @@ func (attr *MesonHelper) script(t Toolchain, name string) string { } } + var setupArgs string + if t.cross() { + setupArgs += " --cross-file=/system/mfile" + } + return ` -` + muon + ` setup \ +` + muon + ` setup` + setupArgs + ` \ ` + strings.Join(slices.Collect(func(yield func(string) bool) { for _, v := range append([]KV{ {"wrap_mode", "nofallback"}, |
