Improved Logging
This commit is contained in:
@@ -141,8 +141,11 @@ func BuildNative(p *project.Project, progress func(string)) (BuildResult, error)
|
||||
|
||||
report := ValidateProject(p)
|
||||
if report.HasErrors() {
|
||||
first := report.Diagnostics[0]
|
||||
return BuildResult{}, fmt.Errorf("topdata validation failed with %d error(s): %s: %s", report.ErrorCount(), first.Path, first.Message)
|
||||
summary := report.SummaryLines(3)
|
||||
if len(summary) > 0 {
|
||||
return BuildResult{}, fmt.Errorf("topdata validation failed with %d error(s): %s", report.ErrorCount(), summary[0])
|
||||
}
|
||||
return BuildResult{}, fmt.Errorf("topdata validation failed with %d error(s)", report.ErrorCount())
|
||||
}
|
||||
return buildNativeUnchecked(p, progress)
|
||||
}
|
||||
@@ -269,8 +272,14 @@ func buildNativeUnchecked(p *project.Project, progress func(string)) (BuildResul
|
||||
globalKeyToID[key] = rowID
|
||||
}
|
||||
|
||||
groupTotals := nativeCompileGroupTotals(collected)
|
||||
currentGroup := ""
|
||||
for _, dataset := range collected {
|
||||
progress(fmt.Sprintf("Compiling %s -> %s", dataset.Dataset.Name, dataset.Dataset.OutputName))
|
||||
group := nativeCompileGroup(dataset.Dataset.Name)
|
||||
if group != currentGroup {
|
||||
currentGroup = group
|
||||
progress(fmt.Sprintf("Compiling %s datasets (%d tables)...", group, groupTotals[group]))
|
||||
}
|
||||
compiled, err := resolveNativeDataset(dataset, globalKeyToID, globalRowByKey, tableRegistry, compiler)
|
||||
if err != nil {
|
||||
return BuildResult{}, err
|
||||
@@ -298,6 +307,27 @@ func buildNativeUnchecked(p *project.Project, progress func(string)) (BuildResul
|
||||
}, nil
|
||||
}
|
||||
|
||||
func nativeCompileGroup(datasetName string) string {
|
||||
head, _, ok := strings.Cut(datasetName, "/")
|
||||
if !ok {
|
||||
return datasetName
|
||||
}
|
||||
switch head {
|
||||
case "itemprops", "racialtypes", "damagetypes", "parts", "classes":
|
||||
return head
|
||||
default:
|
||||
return head
|
||||
}
|
||||
}
|
||||
|
||||
func nativeCompileGroupTotals(collected []nativeCollectedDataset) map[string]int {
|
||||
totals := make(map[string]int)
|
||||
for _, dataset := range collected {
|
||||
totals[nativeCompileGroup(dataset.Dataset.Name)]++
|
||||
}
|
||||
return totals
|
||||
}
|
||||
|
||||
func discoverNativeDatasets(dataDir string) ([]nativeDataset, error) {
|
||||
var datasets []nativeDataset
|
||||
err := filepath.WalkDir(dataDir, func(path string, d fs.DirEntry, err error) error {
|
||||
|
||||
Reference in New Issue
Block a user