-
Notifications
You must be signed in to change notification settings - Fork 5
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
Update EMSDK and add Emmaloc #1
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! Just some nitpicks
Will get to this soon. Just a note to myself, update the EMSDK zig-gamedev .zon package to 3.1.73 when this is approved. |
build.zig
Outdated
pub const emsdk_version = emsdk_ver_major ++ "." ++ emsdk_ver_minor ++ "." ++ emsdk_ver_tiny; | ||
|
||
pub fn build(b: *std.Build) void { | ||
_ = b.addModule("root", .{ .root_source_file = b.path("src/zemscripten.zig") }); | ||
_ = b.addModule("dummy", .{ .root_source_file = b.path("src/dummy.zig") }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what is dummy.zig for?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When you run natively, @import("zemscripten") imports the dummy.zig instead of zemscripten.zig, so you can run both natively and emscripten in the same program. There might be a better way to do this. We could make it so that importing zemscripten means only a emscripten build could run. I forgot to add to the README, when you build like this it would look like
const zemscripten = b.dependency("zemscripten", .{});
if (target.result.os.tag != .emscripten) {
exe.root_module.addImport("zemscripten", zemscripten.module("dummy"));
} else {
exe.root_module.addImport("zemscripten", zemscripten.module("root"));
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Multiple main files is the strategy I use in personal projects. I also intend to refactor the zig-gamedev samples to be like sdl2_demo (https://github.com/zig-gamedev/zig-gamedev/tree/main/samples/sdl2_demo/src).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, yeah I do the same thing. So safe to remove dummy.zig?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah I think so. We could put it back if it is useful to someone later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice!
My best attempt at incorporating deins zig-gamedev/zig-gamedev#309 (comment) pull request to allow for emscripten builds.
My shell_minimal.html file is what I use to size canvas to the browser size. We should add the basic emscripten html file as well.