-
-
Notifications
You must be signed in to change notification settings - Fork 63
zig api: (WIP) add a Zig API/bindings for libremidi, also add the posibility to build using the Zig Build System #158
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
…sibility to build using the Zig Build System This commit adds Zig bindings for libremidi and implements a subset of the build logic in Zig's build system. At this point, I'm satisfied with the API I landed on for the bindings, now awaiting feedback! Work still needed on build logic.
f01bc61
to
202dedf
Compare
warning though Seems to be a bug in the zig build system: ziglang/zig#20476 I'll see if i can find a workaround
I assume it uses Zig's own linker instead
Forces use of Zig's self-hosted backend wherever possible
Now simply typing 'zig build' works on both windows AND linux!
thanks, that's amazing work! :) |
Just realized I can probably improve the API a little bit by getting rid of the Let me know what you think! |
Also, is there a way I/you can disable auto CI runs on every commit? Until I actually add CI scripts for the Zig Build System this is just going to be a waste of compute... |
You can add [ci skip] at the beginning of your commit messages |
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