Skip to content

Commit ab50362

Browse files
committed
Helpful Nitpicks
1 parent bc2ce6f commit ab50362

File tree

4 files changed

+23
-6
lines changed

4 files changed

+23
-6
lines changed

README.md

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,14 +45,31 @@ Add zemscripten's "root" module to your wasm compile target., then create an `em
4545
.embed_paths = &.{},
4646
.preload_paths = &.{},
4747
.install_dir = .{ .custom = "web" },
48-
.shell_file_path = @import("zemscripten").htmlPath(b),
4948
},
5049
);
5150
emcc_step.dependOn(activate_emsdk_step);
5251
5352
b.getInstallStep().dependOn(emcc_step);
5453
```
5554

55+
To use a custom html file emccStep() accepts a shell_file_path option:
56+
```zig
57+
const emcc_step = @import("zemscripten").emccStep(
58+
b,
59+
wasm,
60+
.{
61+
.optimize = optimize,
62+
.flags = emcc_flags,
63+
.settings = emcc_settings,
64+
.use_preload_plugins = true,
65+
.embed_paths = &.{},
66+
.preload_paths = &.{},
67+
.install_dir = .{ .custom = "web" },
68+
.shell_file_path = "path/to/file"
69+
},
70+
);
71+
```
72+
5673
Now you can use the provided Zig panic and log overrides in your wasm's root module and define the entry point that invoked by the js output of `emcc` (by default it looks for a symbol named `main`). For example:
5774
```zig
5875
const std = @import("std");
@@ -86,3 +103,4 @@ You can also define a run step that invokes `emrun`. This will serve the html lo
86103
b.step("emrun", "Build and open the web app locally using emrun").dependOn(emrun_step);
87104
```
88105
See the [emrun documentation](https://emscripten.org/docs/compiling/Running-html-files-with-emrun.html) for the difference args that can be used.
106+

build.zig.zon

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
.{
22
.name = "zemscripten",
3-
.version = "0.2.1-dev",
3+
.version = "0.2.0-dev",
44
.paths = .{
55
"build.zig",
66
"build.zig.zon",

src/dummy.zig

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +0,0 @@
1-
pub const is_emscripten = false;

src/zemscripten.zig

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,9 +70,9 @@ pub fn getElementCssSize(
7070
}
7171
extern fn emscripten_get_element_css_size([*:0]const u8, *f64, *f64) c_int;
7272

73-
/// EmmalocAllocator allocator
74-
/// use with linker flag -sMALLOC=emmalloc
75-
/// for details see docs: https://github.com/emscripten-core/emscripten/blob/main/system/lib/emmalloc.c
73+
// EmmalocAllocator allocator
74+
// use with linker flag -sMALLOC=emmalloc
75+
// for details see docs: https://github.com/emscripten-core/emscripten/blob/main/system/lib/emmalloc.c
7676
extern fn emmalloc_memalign(u32, u32) ?*anyopaque;
7777
extern fn emmalloc_realloc_try(?*anyopaque, u32) ?*anyopaque;
7878
extern fn emmalloc_free(?*anyopaque) void;

0 commit comments

Comments
 (0)