zig api: (WIP) add a Zig API/bindings for libremidi, also add the posibility to build using the Zig Build System #158
Add this suggestion to a batch that can be applied as a single commit. This suggestion is invalid because no changes were made to the code. Suggestions cannot be applied while the pull request is closed. Suggestions cannot be applied while viewing a subset of changes. Only one suggestion per line can be applied in a batch. Add this suggestion to a batch that can be applied as a single commit. Applying suggestions on deleted lines is not supported. You must change the existing code in this line in order to create a valid suggestion. Outdated suggestions cannot be applied. This suggestion has been applied or marked resolved. Suggestions cannot be applied from pending reviews. Suggestions cannot be applied on multi-line comments. Suggestions cannot be applied while the pull request is queued to merge. Suggestion cannot be applied right now. Please check back later.
Overview
This PR provides two things:
Zig API
The bindings make use of Zig's language features, such as namespacing, slices, methods, optionals and more in order to provide an idiomatic Zig API. As such, most C functions are thinly wrapped to provide a better experience, some are provided as-is. Some safety is also gained by means of better type information for pointer arguments.
This means that the wrapper has a non-zero runtime cost, but it should be on the same order of magnitude than what the C wrapper already does. Also, the C API example has been directly translated to Zig using the new API, and as such becomes much more readable in the process.
Zig Build System
There now are build.zig & build.zig.zon files at the root of the tree (necessary for the library to be usable from the Zig user side). This is currently able to build the C API on Linux with :
All the other options are either broken or unimplemented for now. One big blocker is that I haven't been able to make Zig build the CPP library standalone yet. Also that CMake is really hard to grok :).
Once this is solved, adding compilation of all examples and tests should be smooth sailing, in theory (famous last words).
TL;DR
I would appreciate any feedback and especially some help on the build system. Once all this is done I can add CI tests and I think it'd be ready for merging :D
Cheers!
Update 1