libmach: initial API bindings for mach core #406
No reviewers
Labels
No labels
CI
all
basisu
blog
bug
build
contributor-friendly
core
correctness
deferred
dev
direct3d-headers
docs
driver-os-issue
duplicate
dxcompiler
editor
examples
experiment
feature-idea
feedback
flac
freetype
gamemode
gkurve
glfw
gpu
gpu-dawn
harfbuzz
help welcome
in-progress
infrastructure
invalid
libmach
linux-audio-headers
long-term
mach
mach.gfx
mach.math
mach.physics
mach.testing
model3d
needs-triage
object
opengl-headers
opus
os/linux
os/macos
os/wasm
os/windows
package-manager
priority
proposal
proposal-accepted
question
roadmap
slipped
stability
sysaudio
sysgpu
sysjs
validating-fix
vulkan-zig-generated
wayland-headers
website
wontfix
wrench
www
x11-headers
xcode-frameworks
zig-update
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
hexops/mach!406
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "libmach"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
This pull request includes:
src/bindings.zigbuild.zigin order to buildlibmachlibmach/to check iflibmachworks as expectedThis looks like a great starting point, and is a clear improvement over what we have here today so I'm going to merge it. We can continue to iterate on this. I'll leave feedback inline on how we can improve it next
@ -0,0 +33,4 @@return;}if (libmach.core_callbacks.core_update == null) {std.debug.print("Did not provide a core_update callback\n", .{});Perhaps we should panic in these cases?
@ -0,0 +1,52 @@const std = @import("std");Two thoughts for improvement:
Should these bindings live here, or in
libmachI wonder? The same question would go for other Mach libraries in the future, e.g. when we expose a C ABI for the ECS library, I wonder where it should live?We should plan on changing this API to reflect what Ayush said in Matrix, something like this as our long-term goal (but may require some changes to make this possible):
@ -0,0 +7,4 @@// Current Limitations:// 1. Currently, ecs seems to be using some weird compile-time type trickery, so I'm not exactly sure how// `engine` should be integrated into the C API// 2. Core might need to expose more state so more API functions can be exposed (for example, the WebGPU API)Once https://github.com/hexops/mach/pull/403 lands we should end up being ABI-compatible with the
webgpu.hAPI, and Zig's stage2 compiler could even emitwebgpu.hfor us based on this too I think. Should be possible to start writing Mach core / WebGPU apps using this.@ -0,0 +1,64 @@;; Tests the behavior of `libmach` using Common Lisp's CFFIJust curious @zack466 which language do you actually plan to use this from? I've personally never used lisp, but would be interested in maintaining some official Go bindings potentially.
@ -0,0 +1,52 @@const std = @import("std");My opinion on (1) I think the bindings should live inside src/ maybe changing the name to libmach.zig to be more clear. The libmach directory currently doesn't serves any purpose, it just contains examples.
@ -0,0 +1,52 @@const std = @import("std");Well, right now
build.zigis set to output thelibmachshared library tolibmach/build/. Is there another location we would want it to go? (or should we just keep it inzig-out/lib/).For the location of the bindings, I think it would have to be in
srcso it has easy access to mach internals. If it were inlibmachwe would have to importmach, which would probably be annoying to deal with (in terms of build scripts and stuff).Also, currently the libmach code is split between
src/bindings.zigandsrc/platform/libmach.zig. I did this since Zig was not letting me import Core from../Core.ziginsrc/platform/libmach.zig, so I couldn't put all of the code in that file. But looking at howwasm.zigis handled (which imports../Core.zigwithout any problems), I realize that we can probably just merge all of the code intosrc/platform/libmach.zig.@ -0,0 +1,64 @@;; Tests the behavior of `libmach` using Common Lisp's CFFICommon Lisp, haha
CFFI code is dead simple in Lisp (as you can see in
test.lisp), which is really nice. I was actually originally trying to work with bgfx, but it was a huge pain to compile and use properly, so I eventually gave up. With Mach, on the other hand, a simplezig builddoes the trick!