diff options
Diffstat (limited to 'internal/rosa/meson.go')
| -rw-r--r-- | internal/rosa/meson.go | 63 |
1 files changed, 58 insertions, 5 deletions
diff --git a/internal/rosa/meson.go b/internal/rosa/meson.go index 97262fbb..9231880a 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,57 @@ 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{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 } - return P{_meson} + + arch, mesonArch, target := t.Arch(), t.llvmArch(), 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-`+t.linuxArch()+`', '-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', + '/system/`+arch+`/system/share/pkgconfig' + ] + +[host_machine] +cpu = '`+mesonArch+`' +cpu_family = '`+mesonArch+`' +endian = 'little' +system = 'linux' +subsystem = 'linux' +kernel = 'linux' +`)), + )} } // inputs is a noop. @@ -105,8 +153,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"}, |
