Skip to content

Commit 6085ae2

Browse files
author
rodolpheh
committed
Merge branch 'main' into shell-file-lazypath
2 parents e1da691 + 97eb64f commit 6085ae2

File tree

5 files changed

+29
-20
lines changed

5 files changed

+29
-20
lines changed

.github/workflows/main.yml

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,8 @@ jobs:
2020
steps:
2121
- name: Checkout repository
2222
uses: actions/checkout@v3
23-
- name: Read .zig-version
24-
id: zigversion
25-
uses: juliangruber/read-file-action@v1
26-
with:
27-
path: ./.zigversion
2823
- name: Install Zig
29-
uses: mlugg/setup-zig@v1
30-
with:
31-
version: ${{ steps.zigversion.outputs.content }}
24+
uses: mlugg/setup-zig@v2
3225
- name: Check format
3326
continue-on-error: true
3427
run: zig fmt --check .

.zigversion

Lines changed: 0 additions & 1 deletion
This file was deleted.

build.zig

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@ pub fn build(b: *std.Build) void {
1313
pub fn emccPath(b: *std.Build) []const u8 {
1414
return std.fs.path.join(b.allocator, &.{
1515
b.dependency("emsdk", .{}).path("").getPath(b),
16-
"upstream/emscripten/",
16+
"upstream",
17+
"emscripten",
1718
switch (builtin.target.os.tag) {
1819
.windows => "emcc.bat",
1920
else => "emcc",
@@ -24,7 +25,8 @@ pub fn emccPath(b: *std.Build) []const u8 {
2425
pub fn emrunPath(b: *std.Build) []const u8 {
2526
return std.fs.path.join(b.allocator, &.{
2627
b.dependency("emsdk", .{}).path("").getPath(b),
27-
"upstream/emscripten/",
28+
"upstream",
29+
"emscripten",
2830
switch (builtin.target.os.tag) {
2931
.windows => "emrun.bat",
3032
else => "emrun",
@@ -35,7 +37,10 @@ pub fn emrunPath(b: *std.Build) []const u8 {
3537
pub fn htmlPath(b: *std.Build) []const u8 {
3638
return std.fs.path.join(b.allocator, &.{
3739
b.dependency("emsdk", .{}).path("").getPath(b),
38-
"upstream/emscripten/src/shell.html",
40+
"upstream",
41+
"emscripten",
42+
"src",
43+
"shell.html",
3944
}) catch unreachable;
4045
}
4146

@@ -54,6 +59,9 @@ pub fn activateEmsdkStep(b: *std.Build) *std.Build.Step {
5459
.linux, .macos => {
5560
emsdk_install.step.dependOn(&b.addSystemCommand(&.{ "chmod", "+x", emsdk_script_path }).step);
5661
},
62+
.windows => {
63+
emsdk_install.step.dependOn(&b.addSystemCommand(&.{ "takeown", "/f", emsdk_script_path }).step);
64+
},
5765
else => {},
5866
}
5967

@@ -74,13 +82,21 @@ pub fn activateEmsdkStep(b: *std.Build) *std.Build.Step {
7482
.linux, .macos => {
7583
const chmod_emcc = b.addSystemCommand(&.{ "chmod", "+x", emccPath(b) });
7684
chmod_emcc.step.dependOn(&emsdk_activate.step);
85+
step.dependOn(&chmod_emcc.step);
7786

7887
const chmod_emrun = b.addSystemCommand(&.{ "chmod", "+x", emrunPath(b) });
7988
chmod_emrun.step.dependOn(&emsdk_activate.step);
80-
81-
step.dependOn(&chmod_emcc.step);
8289
step.dependOn(&chmod_emrun.step);
8390
},
91+
.windows => {
92+
const takeown_emcc = b.addSystemCommand(&.{ "takeown", "/f", emccPath(b) });
93+
takeown_emcc.step.dependOn(&emsdk_activate.step);
94+
step.dependOn(&takeown_emcc.step);
95+
96+
const takeown_emrun = b.addSystemCommand(&.{ "takeown", "/f", emrunPath(b) });
97+
takeown_emrun.step.dependOn(&emsdk_activate.step);
98+
step.dependOn(&takeown_emrun.step);
99+
},
84100
else => {},
85101
}
86102

build.zig.zon

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
.name = .zemscripten,
33
.fingerprint = 0x2de6d80ca84319b1, // Changing this has security and trust implications.
44
.version = "0.2.0-dev",
5+
.minimum_zig_version = "0.14.0",
56
.paths = .{
67
"build.zig",
78
"build.zig.zon",

src/zemscripten.zig

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ comptime {
88

99
pub extern fn emscripten_sleep(ms: u32) void;
1010

11-
pub const MainLoopCallback = *const fn () callconv(.C) void;
11+
pub const MainLoopCallback = *const fn () callconv(.c) void;
1212
extern fn emscripten_set_main_loop(MainLoopCallback, c_int, c_int) void;
1313
pub fn setMainLoop(cb: MainLoopCallback, maybe_fps: ?i16, simulate_infinite_loop: bool) void {
1414
emscripten_set_main_loop(cb, if (maybe_fps) |fps| fps else -1, @intFromBool(simulate_infinite_loop));
@@ -19,13 +19,13 @@ pub fn cancelMainLoop() void {
1919
emscripten_cancel_main_loop();
2020
}
2121

22-
pub const MainLoopArgCallback = *const fn (arg: *anyopaque) callconv(.C) void;
22+
pub const MainLoopArgCallback = *const fn (arg: *anyopaque) callconv(.c) void;
2323
extern fn emscripten_set_main_loop_arg(MainLoopArgCallback, arg: *anyopaque, c_int, c_int) void;
2424
pub fn setMainLoopArg(cb: MainLoopArgCallback, arg: *anyopaque, maybe_fps: ?i16, simulate_infinite_loop: bool) void {
2525
emscripten_set_main_loop_arg(cb, arg, if (maybe_fps) |fps| fps else -1, @intFromBool(simulate_infinite_loop));
2626
}
2727

28-
pub const AnimationFrameCallback = *const fn (f64, ?*anyopaque) callconv(.C) c_int;
28+
pub const AnimationFrameCallback = *const fn (f64, ?*anyopaque) callconv(.c) c_int;
2929
extern fn emscripten_request_animation_frame_loop(AnimationFrameCallback, ?*anyopaque) void;
3030
pub const requestAnimationFrameLoop = emscripten_request_animation_frame_loop;
3131

@@ -45,7 +45,7 @@ pub const CanvasSizeChangedCallback = *const fn (
4545
i16,
4646
*anyopaque,
4747
?*anyopaque,
48-
) callconv(.C) c_int;
48+
) callconv(.c) c_int;
4949
pub fn setResizeCallback(
5050
cb: CanvasSizeChangedCallback,
5151
use_capture: bool,
@@ -81,13 +81,13 @@ pub fn getElementCssSize(
8181
}
8282
extern fn emscripten_get_element_css_size([*:0]const u8, *f64, *f64) c_int;
8383

84-
// EmmalocAllocator allocator
84+
// EmmallocAllocator allocator
8585
// use with linker flag -sMALLOC=emmalloc
8686
// for details see docs: https://github.com/emscripten-core/emscripten/blob/main/system/lib/emmalloc.c
8787
extern fn emmalloc_memalign(u32, u32) ?*anyopaque;
8888
extern fn emmalloc_realloc_try(?*anyopaque, u32) ?*anyopaque;
8989
extern fn emmalloc_free(?*anyopaque) void;
90-
pub const EmmalocAllocator = struct {
90+
pub const EmmallocAllocator = struct {
9191
const Self = @This();
9292
dummy: u32 = undefined,
9393

0 commit comments

Comments
 (0)