cmd/mbf: garbage collection commands
All checks were successful
Test / Create distribution (push) Successful in 1m29s
Test / Sandbox (push) Successful in 2m43s
Test / ShareFS (push) Successful in 3m55s
Test / Hakurei (push) Successful in 4m3s
Test / Sandbox (race detector) (push) Successful in 8m34s
Test / Hakurei (race detector) (push) Successful in 11m35s
Test / Flake checks (push) Successful in 8m40s

Signed-off-by: Ophestra <cat@gensokyo.uk>
This commit is contained in:
2026-06-02 13:37:46 +09:00
parent fbd2329d50
commit 1490b32387

View File

@@ -86,6 +86,7 @@ func main() {
flagCheck bool
flagLTO bool
flagPT bool
flagDry bool
flagSourcePath string
flagCrossOverride int
@@ -204,6 +205,10 @@ func main() {
&flagPT,
"parse-time", command.BoolFlag(false),
"Print duration of the initial azalea parse",
).Flag(
&flagDry,
"dry", command.BoolFlag(false),
"Do not destroy cache entries",
).Flag(
&flagSourcePath,
"source", command.StringFlag(""),
@@ -736,8 +741,9 @@ func main() {
)
}
c.NewCommand(
"clear",
cleanC := c.New("clean", "Remove unused entries from the cache")
cleanC.NewCommand(
"fault",
"Remove all fault entries from the cache",
func([]string) error {
return cm.Do(func(*pkg.Cache) error {
@@ -758,6 +764,43 @@ func main() {
})
},
)
cleanC.NewCommand(
"checksum",
"Remove unreachable checksum entries",
func([]string) error {
return cm.Do(func(cache *pkg.Cache) error {
_, checksums, err := cache.Clean(flagDry, false)
log.Printf("destroyed %d entries", len(checksums))
return err
})
},
)
{
var flagDeep bool
cleanC.NewCommand(
"all",
"Remove identifiers not reachable by loaded packages",
func([]string) error {
return cm.Do(func(cache *pkg.Cache) error {
t := rosa.Native().Std()
ids, checksums, err := cache.Clean(
flagDry,
!flagDeep,
t.Append(nil, t.CollectAll()...)...,
)
log.Printf(
"destroyed %d identifier and %d checksum entries",
len(ids), len(checksums),
)
return err
})
},
).Flag(
&flagDeep,
"deep", command.BoolFlag(false),
"Include transitive inputs",
)
}
c.NewCommand(
"abort",