Skip to content

Commit fcb3096

Browse files
comments
1 parent 54d61ef commit fcb3096

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

gen/main.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,14 +31,17 @@ func main() {
3131
os.Exit(1)
3232
}
3333

34+
// Order matters for validation steps, so enforce it.
3435
if len(yamlPaths) > 1 && filepath.Base(yamlPaths[0]) != "webgpu.yml" {
3536
panic(`"webgpu.yml" must be the first sequence in the order`)
3637
}
3738

39+
// Validate the yaml files (jsonschema, duplications)
3840
if err := ValidateYamls(schemaPath, yamlPaths); err != nil {
3941
panic(err)
4042
}
4143

44+
// Generate the header files
4245
for i, yamlPath := range yamlPaths {
4346
src, err := os.ReadFile(yamlPath)
4447
if err != nil {
@@ -84,6 +87,7 @@ func SortAndTransform(yml *Yml) {
8487

8588
// Sort enums
8689
slices.SortStableFunc(yml.Enums, func(a, b Enum) int {
90+
// We want to generate extended enum declarations before the normal ones.
8791
if a.Extended && !b.Extended {
8892
return -1
8993
} else if !a.Extended && b.Extended {

gen/validator.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import (
1212
)
1313

1414
func ValidateYamls(schemaPath string, yamlPaths []string) error {
15+
// Validation through json schema
1516
for _, yamlPath := range yamlPaths {
1617
yamlFile, err := os.ReadFile(yamlPath)
1718
if err != nil {
@@ -28,6 +29,7 @@ func ValidateYamls(schemaPath string, yamlPaths []string) error {
2829
}
2930
}
3031

32+
// Validation of possible duplication of entries across multiple yaml files
3133
if err := mergeAndValidateDuplicates(yamlPaths); err != nil {
3234
panic(err)
3335
}

0 commit comments

Comments
 (0)