Creating and editing a filesystem seperate from compilation

19 views
Skip to first unread message

Ronny Nissengold

unread,
Jul 16, 2023, 10:22:26 AM7/16/23
to emscripten-discuss
Hi all,
By giving the linker the --preload-file flag with the appropriate folder I was able to successfully create and access the emscripten FS from cpp as I usually would.
However I would like to be able to create a FS separately from the compilation process. It just feels wrong.
I was able to use the file_packager.py to create a .data and .js file.
I tried running the filesystem.js before my main .js file in my custom index.html, and got an error:
Module.addRunDependency is not a function
Any idea what am I doing wrong? What is the best way to create and access FS in emscripten? Should I just preload in the linker?
Thanks!
Ronny

Alon Zakai

unread,
Jul 18, 2023, 11:53:36 AM7/18/23
to emscripte...@googlegroups.com
That error might be because we do not export all functions by default. Try with

emcc -sEXPORTED_RUNTIME_METHODS=addRunDependency

--
You received this message because you are subscribed to the Google Groups "emscripten-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to emscripten-disc...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/emscripten-discuss/31e7e544-610b-48c4-993a-b8272037c6e1n%40googlegroups.com.

Ronny Nissengold

unread,
Jul 19, 2023, 6:39:48 AM7/19/23
to emscripten-discuss
Thanks!
But I am not trying to compile into a project a filesystem. I already did that successfully using the embind flags.
I am trying to work with a filesystem for a project separately from its compilation.
Is that at all possible?
I tried using the file_packager.py to no avail.
It generates a .data file with the FS and the .js file I don't know what to do with.

ב-יום שלישי, 18 ביולי 2023 בשעה 18:53:36 UTC+3, alon...@gmail.com כתב/ה:

Alon Zakai

unread,
Jul 19, 2023, 1:05:32 PM7/19/23
to emscripte...@googlegroups.com
The JS file that the file packager creates depends on the emscripten runtime code, so you do need to compile a program to use it. But perhaps you can compile a small one. Then you just combine the JS from that with the JS from the file packager and it should work. There are examples of this in the test suite I believe (search for FILE_PACKAGER in tests/*).


Ronny Nissengold

unread,
Jul 20, 2023, 3:44:01 AM7/20/23
to emscripten-discuss
Thanks a lot!
I think I will stick to compiling an assets folder, it is not too bad.

ב-יום רביעי, 19 ביולי 2023 בשעה 20:05:32 UTC+3, alon...@gmail.com כתב/ה:
Reply all
Reply to author
Forward
0 new messages