mach: build: install additional files (html, js) in case of wasm

Install the files template.html (renamed to application.html) and
mach.js in case of WASM. Also changed the install directory to
{prefix}/www.
This commit is contained in:
iddev5 2022-05-26 18:42:32 +05:30 committed by Stephen Gutekanst
parent 7c70dde3f1
commit 84af4e118c

View file

@ -121,6 +121,8 @@ const Packages = struct {
}; };
}; };
const web_install_dir = std.build.InstallDir{ .custom = "www" };
pub const App = struct { pub const App = struct {
b: *std.build.Builder, b: *std.build.Builder,
name: []const u8, name: []const u8,
@ -172,6 +174,27 @@ pub const App = struct {
pub fn install(app: *const App) void { pub fn install(app: *const App) void {
app.step.install(); app.step.install();
// Install additional files (src/mach.js and template.html)
// in case of wasm
if (app.step.target.toTarget().cpu.arch == .wasm32) {
// Set install directory to '{prefix}/www'
app.step.install_step.?.dest_dir = web_install_dir;
const install_mach_js = app.b.addInstallFileWithDir(
.{ .path = thisDir() ++ "/src/mach.js" },
web_install_dir,
"mach.js",
);
app.step.install_step.?.step.dependOn(&install_mach_js.step);
const install_template_html = app.b.addInstallFileWithDir(
.{ .path = thisDir() ++ "/www/template.html" },
web_install_dir,
"application.html",
);
app.step.install_step.?.step.dependOn(&install_template_html.step);
}
} }
pub fn link(app: *const App, options: Options) void { pub fn link(app: *const App, options: Options) void {