Skip to content

Commit 4a4e15a

Browse files
authored
Configure emscripten modules for web environment (#5)
1 parent 94348af commit 4a4e15a

File tree

3 files changed

+2935
-3632
lines changed

3 files changed

+2935
-3632
lines changed

ctowasm/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,13 +75,13 @@ emcc <library name>.c -sEXPORTED_FUNCTIONS=<function names> -sEXPORTED_RUNTIME_M
7575
An example of the above command that was used to compile `math.h` functions to make available in the the "math" module:
7676

7777
```
78-
emcc math.c -sEXPORTED_FUNCTIONS=_acos,_asin,_atan,_cos,_cosh,_sin,_sinh,_tan,_tanh,_exp,_log,_log10,_pow,_sqrt,_ceil,_floor -sEXPORTED_RUNTIME_METHODS=ccall,cwrap -sMODULARIZE -sSINGLE_FILE -o math.js
78+
emcc math.c -sEXPORTED_FUNCTIONS=_acos,_asin,_atan,_cos,_cosh,_sin,_sinh,_tan,_tanh,_exp,_log,_log10,_pow,_sqrt,_ceil,_floor -sEXPORTED_RUNTIME_METHODS=ccall,cwrap -sMODULARIZE -sSINGLE_FILE -sENVIRONMENT=web -o math.js
7979
```
8080

8181
An example of a more complex version of the above command that was used to compile `stdlib.h` functions for the "utility" module:
8282

8383
```
84-
emcc utility.c -sEXPORTED_FUNCTIONS=_atoi,_atof,_abs,_labs,_rand,_bsearch,_qsort,_srand,_free,_malloc -sEXPORTED_RUNTIME_METHODS=ccall,cwrap,stringToNewUTF8,addFunction,wasmMemory -sMODULARIZE -sSINGLE_FILE -sALLOW_TABLE_GROWTH -o utility.js
84+
emcc utility.c -sEXPORTED_FUNCTIONS=_atoi,_atof,_abs,_labs,_rand,_bsearch,_qsort,_srand,_free,_malloc -sEXPORTED_RUNTIME_METHODS=ccall,cwrap,stringToNewUTF8,addFunction,wasmMemory -sMODULARIZE -sSINGLE_FILE -sALLOW_TABLE_GROWTH -sENVIRONMENT=web -o utility.js
8585
```
8686

8787
4. Move the resultant \<library name>.js file into this project repository, in the module folder. Ensure you define types for importing the functions from this js file in your \<module name>.ts file. See the folders of the [utility](src/modules/utility) and [math](src/modules/math) modules for examples.

0 commit comments

Comments
 (0)