internal/rosa: optionally load built-ins from filesystem
Test / Create distribution (push) Successful in 57s
Test / Sandbox (push) Successful in 3m15s
Test / Hakurei (push) Successful in 5m8s
Test / Sandbox (race detector) (push) Successful in 6m12s
Test / Hakurei (race detector) (push) Successful in 7m30s
Test / ShareFS (push) Successful in 7m51s
Test / Flake checks (push) Successful in 1m8s
Test / Create distribution (push) Successful in 57s
Test / Sandbox (push) Successful in 3m15s
Test / Hakurei (push) Successful in 5m8s
Test / Sandbox (race detector) (push) Successful in 6m12s
Test / Hakurei (race detector) (push) Successful in 7m30s
Test / ShareFS (push) Successful in 7m51s
Test / Flake checks (push) Successful in 1m8s
This avoids having to rebuild cmd/mbf over and over. Signed-off-by: Ophestra <cat@gensokyo.uk>
This commit is contained in:
@@ -1,10 +1,13 @@
|
|||||||
package rosa
|
package rosa
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"io/fs"
|
||||||
|
"os"
|
||||||
"path"
|
"path"
|
||||||
"slices"
|
"slices"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
"time"
|
||||||
|
|
||||||
"hakurei.app/internal/pkg"
|
"hakurei.app/internal/pkg"
|
||||||
)
|
)
|
||||||
@@ -115,8 +118,29 @@ func skipGNUTests(tests ...int64) string {
|
|||||||
return buf.String()
|
return buf.String()
|
||||||
}
|
}
|
||||||
|
|
||||||
// builtin contains native and embedded [Artifact] registrations.
|
var (
|
||||||
var builtin S
|
// builtin contains native and embedded [Artifact] registrations.
|
||||||
|
builtin S
|
||||||
|
|
||||||
|
// parseTime is the duration of early parsing of built-in azalea expressions.
|
||||||
|
parseTime time.Duration
|
||||||
|
)
|
||||||
|
|
||||||
|
// ParseTime returns the time taken by early parsing of built-in azalea expressions.
|
||||||
|
func ParseTime() time.Duration { return parseTime }
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
sub, err := fs.Sub(builtinAzalea, "package")
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
t := time.Now()
|
||||||
|
if err = builtin.RegisterFS(sub); err != nil {
|
||||||
|
println(err.Error())
|
||||||
|
os.Exit(1)
|
||||||
|
}
|
||||||
|
parseTime = time.Since(t)
|
||||||
|
}
|
||||||
|
|
||||||
// New returns the address of a newly populated [S] derived from built-ins.
|
// New returns the address of a newly populated [S] derived from built-ins.
|
||||||
func New() *S { return builtin.Clone() }
|
func New() *S { return builtin.Clone() }
|
||||||
|
|||||||
@@ -0,0 +1,11 @@
|
|||||||
|
//go:build !penv
|
||||||
|
|
||||||
|
package rosa
|
||||||
|
|
||||||
|
import "embed"
|
||||||
|
|
||||||
|
// builtinAzalea is the backing directory of built-in azalea-based [Artifact]
|
||||||
|
// implementations.
|
||||||
|
//
|
||||||
|
//go:embed package
|
||||||
|
var builtinAzalea embed.FS
|
||||||
@@ -0,0 +1,28 @@
|
|||||||
|
//go:build penv
|
||||||
|
|
||||||
|
package rosa
|
||||||
|
|
||||||
|
import (
|
||||||
|
"io/fs"
|
||||||
|
"os"
|
||||||
|
)
|
||||||
|
|
||||||
|
// builtinAzalea is the backing directory of built-in azalea-based [Artifact]
|
||||||
|
// implementations.
|
||||||
|
var builtinAzalea = func() fs.FS {
|
||||||
|
const name = "ROSA_SOURCE"
|
||||||
|
|
||||||
|
pathname, ok := os.LookupEnv(name)
|
||||||
|
if !ok {
|
||||||
|
println(name + " not set")
|
||||||
|
os.Exit(1)
|
||||||
|
}
|
||||||
|
|
||||||
|
root, err := os.OpenRoot(pathname)
|
||||||
|
if err != nil {
|
||||||
|
println(err.Error())
|
||||||
|
os.Exit(1)
|
||||||
|
}
|
||||||
|
|
||||||
|
return root.FS()
|
||||||
|
}()
|
||||||
@@ -2,14 +2,11 @@
|
|||||||
package rosa
|
package rosa
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"embed"
|
|
||||||
"io/fs"
|
|
||||||
"os"
|
"os"
|
||||||
"slices"
|
"slices"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
|
||||||
"unsafe"
|
"unsafe"
|
||||||
|
|
||||||
"hakurei.app/fhs"
|
"hakurei.app/fhs"
|
||||||
@@ -623,28 +620,3 @@ func (attr *GenericHelper) script(t Toolchain, _ string) string {
|
|||||||
script += attr.Install
|
script += attr.Install
|
||||||
return script
|
return script
|
||||||
}
|
}
|
||||||
|
|
||||||
// parseTime is the duration of early parsing of built-in azalea expressions.
|
|
||||||
var parseTime time.Duration
|
|
||||||
|
|
||||||
// ParseTime returns the time taken by early parsing of built-in azalea expressions.
|
|
||||||
func ParseTime() time.Duration { return parseTime }
|
|
||||||
|
|
||||||
// builtinAzalea is the backing directory of built-in azalea-based [Artifact]
|
|
||||||
// implementations.
|
|
||||||
//
|
|
||||||
//go:embed package
|
|
||||||
var builtinAzalea embed.FS
|
|
||||||
|
|
||||||
func init() {
|
|
||||||
sub, err := fs.Sub(builtinAzalea, "package")
|
|
||||||
if err != nil {
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
t := time.Now()
|
|
||||||
if err = builtin.RegisterFS(sub); err != nil {
|
|
||||||
println(err.Error())
|
|
||||||
os.Exit(1)
|
|
||||||
}
|
|
||||||
parseTime = time.Since(t)
|
|
||||||
}
|
|
||||||
|
|||||||
Reference in New Issue
Block a user