-
-
Notifications
You must be signed in to change notification settings - Fork 82
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
how to use with Zig's package manager? #146
Comments
There is no module |
Thanks. it worked. |
I was able to get the wrapper working by doing the following:
And applying the following change to diff --git a/build.zig b/build.zig
index d731c9a..5c21365 100644
--- a/build.zig
+++ b/build.zig
@@ -1,4 +1,5 @@
const std = @import("std");
+const sdl = @import("sdl");
// Although this function looks imperative, note that its job is to
// declaratively construct a build graph that will be executed by an external
@@ -36,6 +37,10 @@ pub fn build(b: *std.Build) void {
.optimize = optimize,
});
+ const sdl_sdk = sdl.init(b, null);
+ sdl_sdk.link(exe, .dynamic);
+ exe.root_module.addImport("sdl", sdl_sdk.getWrapperModule());
+
// This declares intent for the executable to be installed into the
// standard location when the user invokes the "install" step (the default
// step when running `zig build`). And then adding SDL wrapper code (see diff --git a/src/main.zig b/src/main.zig
index c8a3f67..31242e1 100644
--- a/src/main.zig
+++ b/src/main.zig
@@ -1,19 +1,40 @@
const std = @import("std");
+const SDL = @import("sdl");
pub fn main() !void {
+ try SDL.init(.{
+ .video = true,
+ .events = true,
+ .audio = true,
+ });
+ defer SDL.quit();
+ // ... see examples/wrapper.zig
} Note the name used to install the package is the name used to import it in Then using |
zig fetch --save=sdl https://github.com/MasterQ32/SDL.zig/archive/72233ed5d92dbc76bfddd3d0434bb7d04faad5cc.tar.gz where are you getting these urls from? |
@ikouchiha47 See https://docs.github.com/en/repositories/working-with-files/using-files/downloading-source-code-archives#source-code-archive-urls for details on that URL format. But you should be able to take that one and replace You can find the list of all commits here: https://github.com/MasterQ32/SDL.zig/commits/master/ |
Noob question: do I have to put SDL.zig in a local subfolder in my project and use a build.zig file like in the README.md, or can I use the ZON package manager like the OP tried in #146 (comment) ? I did the former and it worked after some light tweaking. I'd like to do the latter |
Also zig noob here: when I do I've added the module in the |
build.zig.zon
file:build.zig
file:I get this error:
The text was updated successfully, but these errors were encountered: