docs for --pre-js

259 views
Skip to first unread message

Brian Craft

unread,
Apr 3, 2019, 7:39:03 PM4/3/19
to emscripten-discuss
I haven't been able to find docs or examples for --pre-js. Can anyone point in the right direction?

I worked out that it's "--pre-js=foo.js", not "--pre-js foo.js". I don't understand the module system, though, and can't access the functions defined in the file.

I was expecting that I would add the functions to EXTRA_EXPORTED_RUNTIME_METHODS, and they would appear on Module. This seems to sort of half work: if I add a function to EXTRA_EXPORTED_RUNTIME_METHODS but fail to set --pre-js, the build will cough up an error, like

shared:ERROR: undefined exported function: "fradixSortL16_64"

After adding --pre-js, this build error disappears, so it seems to be finding the function during build, but the function is not available at run time on Module.

Brian Craft

unread,
Apr 3, 2019, 8:19:37 PM4/3/19
to emscripten-discuss
On review, this isn't quite correct. It wasn't --pre-js that fixed the build error, it was moving the export from EXPORTED_FUNCTIONS to EXTRA_EXPORTED_RUNTIME_METHODS. So, I don't have any evidence that it's finding the methods in the --pre-js file. Adding random names to the runtime method list doesn't generate any build-time error.

Alon Zakai

unread,
Apr 5, 2019, 4:41:57 PM4/5/19
to emscripte...@googlegroups.com
The docs are shown with `emcc --help`, also available here


The syntax is a space, so --pre-js FILE.js

See the test suite for working examples of all this stuff, can search for `--pre-js` in tests/*.py.

If you want the function to be exportable on Module, then it's better to use `--js-library`, btw. Such functions are just normal JS system libraries, exportable in the usual way.

--
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.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages