Improved Logging

This commit is contained in:
2026-04-10 08:20:38 +02:00
parent 3a0d4eb990
commit bbe2376252
2 changed files with 92 additions and 6 deletions
+41 -6
View File
@@ -272,13 +272,19 @@ func buildNativeUnchecked(p *project.Project, progress func(string)) (BuildResul
globalKeyToID[key] = rowID globalKeyToID[key] = rowID
} }
groupTotals := nativeCompileGroupTotals(collected) groupStats := nativeCompileGroupStats(collected)
currentGroup := "" currentGroup := ""
for _, dataset := range collected { for _, dataset := range collected {
group := nativeCompileGroup(dataset.Dataset.Name) group := nativeCompileGroup(dataset.Dataset.Name)
if group != currentGroup { if group != currentGroup {
currentGroup = group currentGroup = group
progress(fmt.Sprintf("Compiling %s datasets (%d tables)...", group, groupTotals[group])) stats := groupStats[group]
progress(fmt.Sprintf(
"Compiling %s datasets (%d output tables from %d source fragments)...",
group,
stats.OutputTables,
stats.SourceFragments,
))
} }
compiled, err := resolveNativeDataset(dataset, globalKeyToID, globalRowByKey, tableRegistry, compiler) compiled, err := resolveNativeDataset(dataset, globalKeyToID, globalRowByKey, tableRegistry, compiler)
if err != nil { if err != nil {
@@ -320,12 +326,41 @@ func nativeCompileGroup(datasetName string) string {
} }
} }
func nativeCompileGroupTotals(collected []nativeCollectedDataset) map[string]int { type nativeCompileGroupStat struct {
totals := make(map[string]int) OutputTables int
SourceFragments int
}
func nativeCompileGroupStats(collected []nativeCollectedDataset) map[string]nativeCompileGroupStat {
stats := make(map[string]nativeCompileGroupStat)
for _, dataset := range collected { for _, dataset := range collected {
totals[nativeCompileGroup(dataset.Dataset.Name)]++ group := nativeCompileGroup(dataset.Dataset.Name)
groupStat := stats[group]
groupStat.OutputTables++
groupStat.SourceFragments += nativeDatasetSourceFragments(dataset.Dataset)
stats[group] = groupStat
} }
return totals return stats
}
func nativeDatasetSourceFragments(dataset nativeDataset) int {
fragments := 1
if dataset.Kind == nativeDatasetBase {
fragments += countModuleFiles(dataset.ModulesDir)
fragments += countModuleFiles(dataset.GeneratedDir)
}
return fragments
}
func countModuleFiles(dir string) int {
if strings.TrimSpace(dir) == "" {
return 0
}
paths, err := collectModulePaths(dir)
if err != nil {
return 0
}
return len(paths)
} }
func discoverNativeDatasets(dataDir string) ([]nativeDataset, error) { func discoverNativeDatasets(dataDir string) ([]nativeDataset, error) {
+51
View File
@@ -8334,6 +8334,57 @@ func TestBuildAndPackageIncludesCompiled2DAAndTopAssets(t *testing.T) {
} }
} }
func TestNativeCompileGroupStatsCountSourceFragmentsForBaseDatasets(t *testing.T) {
root := testProjectRoot(t)
modulesDir := filepath.Join(root, "placeables", "modules")
generatedDir := filepath.Join(root, "feat", "generated")
mkdirAll(t, modulesDir)
mkdirAll(t, generatedDir)
writeFile(t, filepath.Join(modulesDir, "a.json"), "{}\n")
writeFile(t, filepath.Join(modulesDir, "b.json"), "{}\n")
writeFile(t, filepath.Join(generatedDir, "family.json"), "{}\n")
stats := nativeCompileGroupStats([]nativeCollectedDataset{
{
Dataset: nativeDataset{
Kind: nativeDatasetBase,
Name: "placeables",
ModulesDir: modulesDir,
GeneratedDir: filepath.Join(root, "missing-generated"),
},
},
{
Dataset: nativeDataset{
Kind: nativeDatasetBase,
Name: "feat",
ModulesDir: filepath.Join(root, "missing-modules"),
GeneratedDir: generatedDir,
},
},
{
Dataset: nativeDataset{
Kind: nativeDatasetPlain,
Name: "classes/skills/fighter",
},
},
})
placeables := stats["placeables"]
if placeables.OutputTables != 1 || placeables.SourceFragments != 3 {
t.Fatalf("unexpected placeables stats: %#v", placeables)
}
feat := stats["feat"]
if feat.OutputTables != 1 || feat.SourceFragments != 2 {
t.Fatalf("unexpected feat stats: %#v", feat)
}
classes := stats["classes"]
if classes.OutputTables != 1 || classes.SourceFragments != 1 {
t.Fatalf("unexpected classes stats: %#v", classes)
}
}
func TestValidateProjectAcceptsPNGTopPackageAsset(t *testing.T) { func TestValidateProjectAcceptsPNGTopPackageAsset(t *testing.T) {
root := testProjectRoot(t) root := testProjectRoot(t)
mkdirAll(t, filepath.Join(root, "topdata", "data", "repadjust")) mkdirAll(t, filepath.Join(root, "topdata", "data", "repadjust"))