Is it possible to remove references to standard DOM when compiling to WebAssembly ?

26 views
Skip to first unread message

laurent bernabe

unread,
Jul 11, 2019, 5:20:40 PM7/11/19
to emscripten-discuss
Hi,

My main goal is to adapt this Stockfish chess engine for being used in React Native.
But in React-Native :
  • we can't use NODE API such as path/fs ... For this point, I've found a solution : more below,
  • we can't rely on Window object and so, nor Document : the original DOM model is forbidden in react-native.
As for removing node js dependency, I've written my own Makefile script . This way, we do not have any call to neither path, nor fs, ...

But I don't know yet how to remove the document/window dependencies. I bet it has something to do with the used Javascript engine when compiling the web assembly.
But though I've set up some with the JSVU utility, as someone already pointed me in another topic, I don't know how to force emscripten to use one of them, and which one I should use.

Meanwhile, my bet is that SpiderMonkey is a good candidate for that. Am I right ? And how to "bind" a custom JS engine to emscripten ?

Thanks in advance,

Regards

Jukka Jylänki

unread,
Jul 15, 2019, 6:11:20 AM7/15/19
to emscripte...@googlegroups.com
We have a linker flag -s ENVIRONMENT=x to specify at compile time the
runtime environment that is used. E.g. -s ENVIRONMENT=web generates a
build that is used in a browser only, and -s ENVIRONMENT=node
generates a build that is to be used in node.js only. -s
ENVIRONMENT=web,node generates a build for both.

There is currently no specific flag for React Native, but you can try
expanding the ENVIRONMENT linker flag to add such a target.

pe 12. heinäk. 2019 klo 0.20 laurent bernabe
(laurent...@gmail.com) kirjoitti:
> --
> 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/79870177-8aeb-4dce-9bbe-d014d5eaa694%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

laurent bernabe

unread,
Jul 15, 2019, 9:06:20 AM7/15/19
to emscripten-discuss
Thank you very much for your answer,

Unfortunately, my WebAssembly level is too basic for me to adapt Emscripten in order to generate a React-Native suitable binary. So for now, I'll just go on with native mobile development.

Thanks anyway,

Regards


Le lundi 15 juillet 2019 12:11:20 UTC+2, jj a écrit :
We have a linker flag -s ENVIRONMENT=x to specify at compile time the
runtime environment that is used. E.g. -s ENVIRONMENT=web generates a
build that is used in a browser only, and -s ENVIRONMENT=node
generates a build that is to be used in node.js only. -s
ENVIRONMENT=web,node generates a build for both.

There is currently no specific flag for React Native, but you can try
expanding the ENVIRONMENT linker flag to add such a target.

pe 12. heinäk. 2019 klo 0.20 laurent bernabe
(laurent...@gmail.com) kirjoitti:
>
> Hi,
>
> My main goal is to adapt this Stockfish chess engine for being used in React Native.
> But in React-Native :
>
> we can't use NODE API such as path/fs ... For this point, I've found a solution : more below,
> we can't rely on Window object and so, nor Document : the original DOM model is forbidden in react-native.
>
> As for removing node js dependency, I've written my own Makefile script . This way, we do not have any call to neither path, nor fs, ...
>
> But I don't know yet how to remove the document/window dependencies. I bet it has something to do with the used Javascript engine when compiling the web assembly.
> But though I've set up some with the JSVU utility, as someone already pointed me in another topic, I don't know how to force emscripten to use one of them, and which one I should use.
>
> Meanwhile, my bet is that SpiderMonkey is a good candidate for that. Am I right ? And how to "bind" a custom JS engine to emscripten ?
>
> Thanks in advance,
>
> Regards
>
> --
> 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-discuss+unsub...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages