wasm shell + destructuring
This commit is contained in:
@@ -21,6 +21,8 @@ pub const TargetConfig = struct {
|
||||
sysroot: ?[]const u8 = null,
|
||||
/// Extra flags passed through to the linker (e.g. Emscripten -s flags).
|
||||
extra_link_flags: []const []const u8 = &.{},
|
||||
/// Custom WASM shell template path (overrides the built-in template).
|
||||
wasm_shell_path: ?[]const u8 = null,
|
||||
|
||||
pub const OptLevel = enum {
|
||||
none,
|
||||
@@ -192,12 +194,16 @@ pub fn link(allocator: std.mem.Allocator, io: std.Io, output_obj: []const u8, ex
|
||||
try argv.append(allocator, "-sMEMORY64");
|
||||
}
|
||||
|
||||
// Use the built-in sx HTML shell template (write to temp file for emcc)
|
||||
// HTML shell template: use custom path if set, otherwise write built-in template to temp file
|
||||
if (std.mem.endsWith(u8, output_bin, ".html")) {
|
||||
const shell_html = @embedFile("wasm_shell.html");
|
||||
const shell_path = try std.fmt.allocPrint(allocator, "{s}.shell.html", .{output_obj});
|
||||
std.Io.Dir.writeFile(.cwd(), io, .{ .sub_path = shell_path, .data = shell_html }) catch {};
|
||||
try argv.appendSlice(allocator, &.{ "--shell-file", shell_path });
|
||||
if (target_config.wasm_shell_path) |custom_shell| {
|
||||
try argv.appendSlice(allocator, &.{ "--shell-file", custom_shell });
|
||||
} else {
|
||||
const shell_html = @embedFile("wasm_shell.html");
|
||||
const shell_path = try std.fmt.allocPrint(allocator, "{s}.shell.html", .{output_obj});
|
||||
std.Io.Dir.writeFile(.cwd(), io, .{ .sub_path = shell_path, .data = shell_html }) catch {};
|
||||
try argv.appendSlice(allocator, &.{ "--shell-file", shell_path });
|
||||
}
|
||||
}
|
||||
|
||||
// Extra linker flags (e.g. -sUSE_SDL=3, -sUSE_WEBGL2=1, --preload-file assets)
|
||||
|
||||
Reference in New Issue
Block a user