genbindings: avoid generating empty files

This commit is contained in:
mappu 2024-08-19 19:11:36 +12:00
parent 926cfc7c84
commit 043db615b1
2 changed files with 11 additions and 0 deletions

View File

@ -176,3 +176,8 @@ type CppParsedHeader struct {
Typedefs []CppTypedef
Classes []CppClass
}
func (c CppParsedHeader) Empty() bool {
return len(c.Typedefs) == 0 &&
len(c.Classes) == 0
}

View File

@ -192,6 +192,12 @@ func main() {
}
}
// Breakout if there is nothing bindable
if parsed.Empty() {
log.Printf("Nothing in this header was bindable.")
continue
}
// Emit 3 code files from the intermediate format
outputName := filepath.Join(*outDir, "gen_"+strings.TrimSuffix(filepath.Base(inputHeader), `.h`))