castholm / zigglgen

Zig OpenGL binding generator
MIT License
58 stars 14 forks source link

Proposal: Replace `updateApiRegistry.ps1` with a step in `build.zig` #13

Open terraquad opened 4 days ago

terraquad commented 4 days ago

It would be beneficial since you don't need to manually call the script, and another benefit would be that it's cross-platform.

I can't really do this since I have never programmed in PowerShell, but it still would be nice to see :)

castholm commented 4 days ago

PowerShell has been cross-platform for almost 8 years now :)

The main reason the script exists is because I didn't want to take a dependency on a Zig XML parsing library, so transforming the Khronos OpenGL XML API registry into Zig code in advance was the best alternative. And since it's a shell script, we can additionally do things like use advanced regex patterns to order all the symbols in a way that's intuitive to the code reader in advance, so that we don't have to sort anything at build time.

If the script was to be replaced with Zig code, it would need to be placed in a separate directory with its own separate build.zig so that consumers of zigglgen don't take on a transitive XML parser dependency. But even then I'm not sure if Zig as a low-level systems programming language is the right tool for the job. Wrangling an API schema into a project-specific format a couple of times per year is a perfect example of a task that shell scripts excel at.