diff options
author | Robert Ou <rqou@robertou.com> | 2017-11-15 03:14:14 -0800 |
---|---|---|
committer | Robert Ou <rqou@robertou.com> | 2018-03-31 14:10:36 -0700 |
commit | 3bee3cfeadcb57833a90c7789333750676f39e81 (patch) | |
tree | 54cd6a8b36740bdd98a4f9dea6c6290ec3d15d59 /icepack | |
parent | 9b0603c4bc156b350918c3a8762ffac28b3de42b (diff) | |
download | icestorm-3bee3cfeadcb57833a90c7789333750676f39e81.tar.gz icestorm-3bee3cfeadcb57833a90c7789333750676f39e81.tar.bz2 icestorm-3bee3cfeadcb57833a90c7789333750676f39e81.zip |
Mount NODEFS if using emscripten and nodejs
Mounts root directory on `/hostfs` and the current working directory on
`/hostcwd`
Diffstat (limited to 'icepack')
-rw-r--r-- | icepack/icepack.cc | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/icepack/icepack.cc b/icepack/icepack.cc index d845ba7..3029c25 100644 --- a/icepack/icepack.cc +++ b/icepack/icepack.cc @@ -34,6 +34,10 @@ #include <stdio.h> #include <stdarg.h> +#ifdef __EMSCRIPTEN__ +#include <emscripten.h> +#endif + #ifdef _WIN32 #define __PRETTY_FUNCTION__ __FUNCTION__ #endif @@ -1338,6 +1342,18 @@ void usage() int main(int argc, char **argv) { +#ifdef __EMSCRIPTEN__ + EM_ASM( + if (ENVIRONMENT_IS_NODE) + { + FS.mkdir('/hostcwd'); + FS.mount(NODEFS, { root: '.' }, '/hostcwd'); + FS.mkdir('/hostfs'); + FS.mount(NODEFS, { root: '/' }, '/hostfs'); + } + ); +#endif + vector<string> parameters; bool unpack_mode = false; bool nosleep_mode = false; |