Move Generation Destinations

This commit is contained in:
2026-04-18 10:24:34 +02:00
parent 897776f432
commit 6f6bf7080a
10 changed files with 166 additions and 91 deletions
+16 -1
View File
@@ -145,6 +145,12 @@ func (p *Project) ValidateLayout() error {
} {
info, err := os.Stat(path)
if err != nil {
if label == "paths.assets" && errors.Is(err, os.ErrNotExist) && p.isCachePath(path) {
if mkErr := os.MkdirAll(path, 0o755); mkErr != nil {
failures = append(failures, fmt.Errorf("%s: create cache directory %s: %w", label, path, mkErr))
}
continue
}
failures = append(failures, fmt.Errorf("%s: %w", label, err))
continue
}
@@ -160,6 +166,15 @@ func (p *Project) ValidateLayout() error {
return nil
}
func (p *Project) isCachePath(path string) bool {
rel, err := filepath.Rel(p.Root, path)
if err != nil || strings.HasPrefix(rel, ".."+string(filepath.Separator)) || rel == ".." {
return false
}
parts := strings.Split(filepath.Clean(rel), string(filepath.Separator))
return len(parts) > 0 && parts[0] == ".cache"
}
func (p *Project) Scan() error {
sourceFiles, sourceExts, err := scanDir(p.SourceDir(), func(path string) bool {
ext := strings.ToLower(filepath.Ext(path))
@@ -334,7 +349,7 @@ func defaultConfig() Config {
Build: "build",
},
TopData: TopDataConfig{
Build: "build/topdata",
Build: ".cache/topdata",
},
}
}