According to emscripten docs, --embed-file and --preload-file accept directory inputs, which will bundle everything in the directory into the js/.data file accordingly. Currently, an input with options like so will error:
const opts: StepOptions = .{
.optimize = optimize,
.flags = emcc_flags,
.settings = emcc_settings,
.install_dir = install_dir,
.out_file_name = "main.html",
.preload_paths = &.{.{ .src_path = b.path("assets/") }}, // <--- here
};
Relevant error:
...
run
└─ run dependency
└─ install generated/
└─ run dependency (main.html) failure
error: failed checking cache: /home/user/project/assets file_hash IsDir
Build Summary: 19/23 steps succeeded (1 failed)
run transitive failure
└─ run dependency transitive failure
└─ install generated/ transitive failure
├─ run dependency (main.html) failure
└─ run dependency (main.html) (+3 more reused dependencies)
...
Here is a hacky fix, the clear issue is .addFileArg deals with the cache and expects a file input. So, simply passing string of the path as the arg fixes the problem :
diff --git a/build.zig b/build.zig
index b16f992..3a06129 100644
--- a/build.zig
+++ b/build.zig
@@ -247,7 +247,7 @@ pub fn emccStep(
if (options.preload_paths) |preload_paths| {
for (preload_paths) |path| {
emcc.addArg("--preload-file");
- emcc.addFileArg(path.src_path);
+ emcc.addArg(path.src_path.getDisplayName());
}
}
There is probably better solution here.. getDisplayName for one is deprecated apparently.
According to emscripten docs,
--embed-fileand--preload-fileaccept directory inputs, which will bundle everything in the directory into the js/.datafile accordingly. Currently, an input with options like so will error:Relevant error:
Here is a hacky fix, the clear issue is
.addFileArgdeals with the cache and expects a file input. So, simply passing string of the path as the arg fixes the problem :There is probably better solution here..
getDisplayNamefor one is deprecated apparently.