mach: build: Use proper application name in case of wasm
This uses the new html-generator tool to automatically fix the file names in resulting application.html
This commit is contained in:
parent
19fb2e8ebd
commit
d85c6a8669
1 changed files with 12 additions and 11 deletions
23
build.zig
23
build.zig
|
|
@ -147,8 +147,7 @@ pub const App = struct {
|
||||||
|
|
||||||
const step = blk: {
|
const step = blk: {
|
||||||
if (options.target.toTarget().cpu.arch == .wasm32) {
|
if (options.target.toTarget().cpu.arch == .wasm32) {
|
||||||
// TODO: use options.name
|
const lib = b.addSharedLibrary(options.name, thisDir() ++ "/src/wasm.zig", .unversioned);
|
||||||
const lib = b.addSharedLibrary("application", thisDir() ++ "/src/wasm.zig", .unversioned);
|
|
||||||
lib.addPackage(gpu.pkg);
|
lib.addPackage(gpu.pkg);
|
||||||
|
|
||||||
break :blk lib;
|
break :blk lib;
|
||||||
|
|
@ -187,12 +186,15 @@ pub const App = struct {
|
||||||
);
|
);
|
||||||
app.getInstallStep().?.step.dependOn(&install_mach_js.step);
|
app.getInstallStep().?.step.dependOn(&install_mach_js.step);
|
||||||
|
|
||||||
const install_template_html = app.b.addInstallFileWithDir(
|
const html_generator = app.b.addExecutable("html-generator", thisDir() ++ "/tools/html-generator.zig");
|
||||||
.{ .path = thisDir() ++ "/www/template.html" },
|
const run_html_generator = html_generator.run();
|
||||||
web_install_dir,
|
run_html_generator.addArgs(&.{ std.mem.concat(
|
||||||
"application.html",
|
app.b.allocator,
|
||||||
);
|
u8,
|
||||||
app.getInstallStep().?.step.dependOn(&install_template_html.step);
|
&.{ app.name, ".html" },
|
||||||
|
) catch unreachable, app.name });
|
||||||
|
run_html_generator.cwd = app.b.getInstallPath(web_install_dir, "");
|
||||||
|
app.getInstallStep().?.step.dependOn(&run_html_generator.step);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -237,13 +239,12 @@ pub const App = struct {
|
||||||
.macos, .windows => "open",
|
.macos, .windows => "open",
|
||||||
else => "xdg-open", // Assume linux-like
|
else => "xdg-open", // Assume linux-like
|
||||||
},
|
},
|
||||||
// TODO: use actual application name
|
app.b.fmt("http://{s}:{s}/{s}.html", .{ address, port, app.name }),
|
||||||
app.b.fmt("http://{s}:{s}/{s}.html", .{ address, port, "application" }),
|
|
||||||
});
|
});
|
||||||
launch.step.dependOn(&app.getInstallStep().?.step);
|
launch.step.dependOn(&app.getInstallStep().?.step);
|
||||||
|
|
||||||
const serve = http_server.run();
|
const serve = http_server.run();
|
||||||
serve.addArgs(&.{ "application", address, port });
|
serve.addArgs(&.{ app.name, address, port });
|
||||||
serve.step.dependOn(&launch.step);
|
serve.step.dependOn(&launch.step);
|
||||||
serve.cwd = app.b.getInstallPath(web_install_dir, "");
|
serve.cwd = app.b.getInstallPath(web_install_dir, "");
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue