internal/rosa: expose supported architectures
Test / Create distribution (push) Successful in 53s
Test / Sandbox (push) Successful in 2m57s
Test / ShareFS (push) Successful in 3m56s
Test / Hakurei (push) Successful in 4m3s
Test / Sandbox (race detector) (push) Successful in 5m33s
Test / Hakurei (race detector) (push) Successful in 6m41s
Test / Flake checks (push) Successful in 1m12s
Test / Create distribution (push) Successful in 53s
Test / Sandbox (push) Successful in 2m57s
Test / ShareFS (push) Successful in 3m56s
Test / Hakurei (push) Successful in 4m3s
Test / Sandbox (race detector) (push) Successful in 5m33s
Test / Hakurei (race detector) (push) Successful in 6m41s
Test / Flake checks (push) Successful in 1m12s
This information is useful to external tooling and makes a lot more sense in this package than cmd/mbf. This change also fixes non-native artifact resolution during clean. Signed-off-by: Ophestra <cat@gensokyo.uk>
This commit is contained in:
+3
-19
@@ -8,7 +8,6 @@ import (
|
|||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"hakurei.app/check"
|
"hakurei.app/check"
|
||||||
"hakurei.app/container"
|
|
||||||
"hakurei.app/internal/pkg"
|
"hakurei.app/internal/pkg"
|
||||||
"hakurei.app/internal/rosa"
|
"hakurei.app/internal/rosa"
|
||||||
"hakurei.app/message"
|
"hakurei.app/message"
|
||||||
@@ -111,24 +110,9 @@ func (cache *cache) open() (err error) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
pkg.RegisterArch("riscv64", container.BinfmtEntry{
|
for arch, entry := range rosa.Arches(pathname) {
|
||||||
Offset: 0,
|
pkg.RegisterArch(arch, entry)
|
||||||
Magic: "\x7fELF\x02\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\xf3\x00",
|
}
|
||||||
Mask: "\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff",
|
|
||||||
Interpreter: pathname.Append(
|
|
||||||
"system/bin",
|
|
||||||
"qemu-riscv64",
|
|
||||||
),
|
|
||||||
})
|
|
||||||
pkg.RegisterArch("arm64", container.BinfmtEntry{
|
|
||||||
Offset: 0,
|
|
||||||
Magic: "\x7fELF\x02\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\xb7\x00",
|
|
||||||
Mask: "\xff\xff\xff\xff\xff\xff\xff\xfc\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff",
|
|
||||||
Interpreter: pathname.Append(
|
|
||||||
"system/bin",
|
|
||||||
"qemu-aarch64",
|
|
||||||
),
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return
|
return
|
||||||
|
|||||||
+10
-4
@@ -883,13 +883,19 @@ func main() {
|
|||||||
func([]string) error {
|
func([]string) error {
|
||||||
return cm.Do(func(cache *pkg.Cache) error {
|
return cm.Do(func(cache *pkg.Cache) error {
|
||||||
t := rosa.Native().Clone().Std()
|
t := rosa.Native().Clone().Std()
|
||||||
a := t.Append(nil, t.CollectAll()...)
|
handles := t.CollectAll()
|
||||||
for arch := range pkg.Arch() {
|
|
||||||
|
flags := t.Flags()
|
||||||
|
a := t.Append(nil, handles...)
|
||||||
|
for arch := range rosa.Arches(nil) {
|
||||||
if arch == runtime.GOARCH {
|
if arch == runtime.GOARCH {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
t.DropCaches(arch, t.Flags())
|
|
||||||
a = t.Append(a, t.CollectAll()...)
|
t.DropCaches(arch, rosa.OptLLVMNoLTO|rosa.OptSkipCheck)
|
||||||
|
a = t.Append(a, handles...)
|
||||||
|
t.DropCaches(arch, flags)
|
||||||
|
a = t.Append(a, handles...)
|
||||||
}
|
}
|
||||||
|
|
||||||
ids, checksums, err := cache.Clean(
|
ids, checksums, err := cache.Clean(
|
||||||
|
|||||||
@@ -443,12 +443,11 @@ func (t Toolchain) appendHandle(a []pkg.Artifact, pv pa, p ArtifactH) []pkg.Arti
|
|||||||
}
|
}
|
||||||
pv[p] = struct{}{}
|
pv[p] = struct{}{}
|
||||||
|
|
||||||
meta, _ := t.MustLoad(p)
|
meta, u := t.MustLoad(p)
|
||||||
for _, d := range meta.Dependencies {
|
for _, d := range meta.Dependencies {
|
||||||
a = t.appendHandle(a, pv, d)
|
a = t.appendHandle(a, pv, d)
|
||||||
}
|
}
|
||||||
_, d := t.MustLoad(p)
|
return append(a, u)
|
||||||
return append(a, d)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Append recursively appends multiple [Artifact] named by their handles, and
|
// Append recursively appends multiple [Artifact] named by their handles, and
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ import (
|
|||||||
"errors"
|
"errors"
|
||||||
"io"
|
"io"
|
||||||
"io/fs"
|
"io/fs"
|
||||||
|
"iter"
|
||||||
"net/http"
|
"net/http"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"reflect"
|
"reflect"
|
||||||
@@ -22,6 +23,7 @@ import (
|
|||||||
"unsafe"
|
"unsafe"
|
||||||
|
|
||||||
"hakurei.app/check"
|
"hakurei.app/check"
|
||||||
|
"hakurei.app/container"
|
||||||
"hakurei.app/internal/pkg"
|
"hakurei.app/internal/pkg"
|
||||||
"hakurei.app/internal/rosa/azalea"
|
"hakurei.app/internal/rosa/azalea"
|
||||||
)
|
)
|
||||||
@@ -239,6 +241,49 @@ func (s *S) wantsArch() {
|
|||||||
// Arch returns the target architecture.
|
// Arch returns the target architecture.
|
||||||
func (s *S) Arch() string { s.wantsArch(); return s.arch }
|
func (s *S) Arch() string { s.wantsArch(); return s.arch }
|
||||||
|
|
||||||
|
// Arches returns an iterator over supported emulation targets.
|
||||||
|
func Arches(qemu *check.Absolute) iter.Seq2[string, container.BinfmtEntry] {
|
||||||
|
return func(yield func(string, container.BinfmtEntry) bool) {
|
||||||
|
for _, target := range []struct {
|
||||||
|
arch, name string
|
||||||
|
offset byte
|
||||||
|
magic, mask string
|
||||||
|
}{{
|
||||||
|
arch: "riscv64",
|
||||||
|
offset: 0,
|
||||||
|
magic: "\x7fELF\x02\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\xf3\x00",
|
||||||
|
mask: "\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff",
|
||||||
|
}, {
|
||||||
|
arch: "arm64",
|
||||||
|
name: "aarch64",
|
||||||
|
offset: 0,
|
||||||
|
magic: "\x7fELF\x02\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\xb7\x00",
|
||||||
|
mask: "\xff\xff\xff\xff\xff\xff\xff\xfc\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff",
|
||||||
|
}} {
|
||||||
|
name := target.name
|
||||||
|
if name == "" {
|
||||||
|
name = target.arch
|
||||||
|
}
|
||||||
|
var interpreter *check.Absolute
|
||||||
|
if qemu != nil {
|
||||||
|
interpreter = qemu.Append(
|
||||||
|
"system/bin",
|
||||||
|
"qemu-"+name,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
if !yield(target.arch, container.BinfmtEntry{
|
||||||
|
Offset: target.offset,
|
||||||
|
Magic: target.magic,
|
||||||
|
Mask: target.mask,
|
||||||
|
Interpreter: interpreter,
|
||||||
|
}) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Flags returns the current preset flags.
|
// Flags returns the current preset flags.
|
||||||
func (s *S) Flags() int { return s.opts }
|
func (s *S) Flags() int { return s.opts }
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user