{build,wasmserve}: improvements
build: use parseIp4 instead resolveIp wasmserve: use ansi_to_html.js instead ansi_up.js wasmserve: handle build procces unexpected exits and more
This commit is contained in:
parent
b0cd4ec1a0
commit
8b50f076a6
5 changed files with 109 additions and 497 deletions
13
build.zig
13
build.zig
|
|
@ -107,6 +107,7 @@ pub fn build(b: *std.build.Builder) void {
|
|||
.target = target,
|
||||
.deps = example.packages,
|
||||
.res_dirs = if (example.has_assets) &.{"examples/" ++ example.name ++ "/assets"} else null,
|
||||
.watch_paths = &.{"examples/" ++ example.name},
|
||||
},
|
||||
);
|
||||
example_app.setBuildMode(mode);
|
||||
|
|
@ -227,6 +228,7 @@ pub const App = struct {
|
|||
step: *std.build.LibExeObjStep,
|
||||
platform: Platform,
|
||||
res_dirs: ?[]const []const u8,
|
||||
watch_paths: ?[]const []const u8,
|
||||
|
||||
pub const Platform = enum {
|
||||
native,
|
||||
|
|
@ -244,6 +246,7 @@ pub const App = struct {
|
|||
target: std.zig.CrossTarget,
|
||||
deps: ?[]const Pkg = null,
|
||||
res_dirs: ?[]const []const u8 = null,
|
||||
watch_paths: ?[]const []const u8 = null,
|
||||
}) App {
|
||||
const target = (std.zig.system.NativeTargetInfo.detect(options.target) catch unreachable).target;
|
||||
const platform = Platform.fromTarget(target);
|
||||
|
|
@ -297,6 +300,7 @@ pub const App = struct {
|
|||
.name = options.name,
|
||||
.platform = platform,
|
||||
.res_dirs = options.res_dirs,
|
||||
.watch_paths = options.watch_paths,
|
||||
};
|
||||
}
|
||||
|
||||
|
|
@ -367,14 +371,17 @@ pub const App = struct {
|
|||
const address = std.process.getEnvVarOwned(app.b.allocator, "MACH_ADDRESS") catch app.b.allocator.dupe(u8, "127.0.0.1") catch unreachable;
|
||||
const port = std.process.getEnvVarOwned(app.b.allocator, "MACH_PORT") catch app.b.allocator.dupe(u8, "8080") catch unreachable;
|
||||
const address_parsed = std.net.Address.resolveIp(address, std.fmt.parseInt(u16, port, 10) catch unreachable) catch unreachable;
|
||||
|
||||
const wasmserve = @import("tools/wasmserve/wasmserve.zig");
|
||||
const install_step_name = if (std.mem.startsWith(u8, app.step.name, "example-"))
|
||||
app.step.name
|
||||
else
|
||||
null;
|
||||
const serve_step = wasmserve.serve(
|
||||
app.step,
|
||||
.{
|
||||
.install_step_name = app.step.name,
|
||||
.install_step_name = install_step_name,
|
||||
.install_dir = web_install_dir,
|
||||
.watch_paths = &.{"tools/wasmserve/wasmserve.zig"},
|
||||
.watch_paths = app.watch_paths,
|
||||
.listen_address = address_parsed,
|
||||
},
|
||||
) catch unreachable;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue