The docs are shown with `emcc --help`, also available here

https://emscripten.org/docs/tools_reference/emcc.html

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.

On Wed, Apr 3, 2019 at 5:19 PM Brian Craft <[email protected]> wrote:

> 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.
>
> On Wednesday, April 3, 2019 at 4:39:03 PM UTC-7, Brian Craft wrote:
>>
>> 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.
>>
> --
> 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 [email protected].
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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 [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to