diff options
author | Robert Ou <rqou@robertou.com> | 2017-11-14 04:09:32 -0800 |
---|---|---|
committer | Robert Ou <rqou@robertou.com> | 2018-05-18 22:53:52 -0700 |
commit | 0abe7c6c77cdb4017cf5d8c34766e43806ce4876 (patch) | |
tree | 6738df42b10100da9e5a6834e09d702cabdc5420 /kernel | |
parent | d9ef793430cf6bec2daeed20fbe44c3b060c435a (diff) | |
download | yosys-0abe7c6c77cdb4017cf5d8c34766e43806ce4876.tar.gz yosys-0abe7c6c77cdb4017cf5d8c34766e43806ce4876.tar.bz2 yosys-0abe7c6c77cdb4017cf5d8c34766e43806ce4876.zip |
Modify emscripten main to mount nodefs and to run arg as a script
Diffstat (limited to 'kernel')
-rw-r--r-- | kernel/driver.cc | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/kernel/driver.cc b/kernel/driver.cc index bec872c24..178641101 100644 --- a/kernel/driver.cc +++ b/kernel/driver.cc @@ -85,20 +85,37 @@ USING_YOSYS_NAMESPACE #ifdef EMSCRIPTEN # include <sys/stat.h> # include <sys/types.h> +# include <emscripten.h> extern "C" int main(int, char**); extern "C" void run(const char*); extern "C" const char *errmsg(); extern "C" const char *prompt(); -int main(int, char**) +int main(int argc, char **argv) { + EM_ASM( + if (ENVIRONMENT_IS_NODE) + { + FS.mkdir('/hostcwd'); + FS.mount(NODEFS, { root: '.' }, '/hostcwd'); + FS.mkdir('/hostfs'); + FS.mount(NODEFS, { root: '/' }, '/hostfs'); + } + ); + mkdir("/work", 0777); chdir("/work"); log_files.push_back(stdout); log_error_stderr = true; yosys_banner(); yosys_setup(); + + if (argc == 2) + { + // Run the first argument as a script file + run_frontend(argv[1], "script", 0, 0, 0); + } } void run(const char *command) |