From 18ba73c9571f4dbf07a14c980c4bb86d234fa136 Mon Sep 17 00:00:00 2001 From: Ophestra Date: Tue, 25 Aug 2026 14:55:17 +0900 Subject: internal/rosa: optionally load built-ins from filesystem This avoids having to rebuild cmd/mbf over and over. Signed-off-by: Ophestra --- internal/rosa/builtins.go | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) (limited to 'internal/rosa/builtins.go') diff --git a/internal/rosa/builtins.go b/internal/rosa/builtins.go index 6d457dbd..dbafa397 100644 --- a/internal/rosa/builtins.go +++ b/internal/rosa/builtins.go @@ -1,10 +1,13 @@ package rosa import ( + "io/fs" + "os" "path" "slices" "strconv" "strings" + "time" "hakurei.app/internal/pkg" ) @@ -115,8 +118,29 @@ func skipGNUTests(tests ...int64) string { return buf.String() } -// builtin contains native and embedded [Artifact] registrations. -var builtin S +var ( + // 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. func New() *S { return builtin.Clone() } -- cgit v1.3.1