[examples] Update build.zig to support wasm examples (#5811)

* Include resource preloads when building wasm examples with Zig.

List of resources derived from examples/Makefile.Web

* Move resource list to zon file to reduce build.zig bloat
This commit is contained in:
Jim Price
2026-04-28 03:26:30 -07:00
committed by GitHub
parent 3c82b48b1f
commit 6a430eb834
2 changed files with 1429 additions and 0 deletions

View File

@@ -706,10 +706,16 @@ fn addExamples(
const emcc_flags = emsdk.emccDefaultFlags(b.allocator, .{ .optimize = optimize });
const emcc_settings = emsdk.emccDefaultSettings(b.allocator, .{ .optimize = optimize });
const EmccExamplesPreloadMap = std.static_string_map.StaticStringMap([]const emsdk.zemscripten.EmccFilePath);
const EmccExamplesPreloadKV = struct { []const u8, []const emsdk.zemscripten.EmccFilePath };
const emcc_examples_preloads: []const EmccExamplesPreloadKV = @import("examples/example_resources.zon");
const emcc_examples_preloads_map = EmccExamplesPreloadMap.initComptime(emcc_examples_preloads);
const emcc_step = emsdk.emccStep(b, raylib, wasm, .{
.optimize = optimize,
.flags = emcc_flags,
.settings = emcc_settings,
.preload_paths = emcc_examples_preloads_map.get(filename) orelse &.{},
.shell_file_path = b.path("src/shell.html"),
.install_dir = install_dir,
});
@@ -788,3 +794,4 @@ fn waylandGenerate(
}
}
}

File diff suppressed because it is too large Load Diff