1 | Framsticks SDK in JavaScript |
---|
2 | ---------------------------- |
---|
3 | |
---|
4 | Note: Emscripten does not like spaces in paths. |
---|
5 | In order to compile the Framsticks SDK properly, ensure you don't have spaces in directory names. |
---|
6 | |
---|
7 | To generate the newest JavaScript version of the Framsticks SDK, you need to have the latest version |
---|
8 | of Emscripten installed. To perform a compilation, you first need to activate the Emscripten SDK: |
---|
9 | |
---|
10 | On Windows (deprecated): |
---|
11 | emsdk.bat activate latest |
---|
12 | |
---|
13 | On Linux: |
---|
14 | emsdk activate latest |
---|
15 | |
---|
16 | The emsdk script should be available in your Emscripten install directory. |
---|
17 | "latest" can be replaced by any name of the Emscripten version installed. |
---|
18 | After activating the Emscripten SDK, to compile Framsticks SDK you need to call: |
---|
19 | |
---|
20 | On Windows (deprecated): |
---|
21 | emmake.bat mingw32-make.exe -j8 --directory=../../cpp -f ../js/sdk/Makefile-SDK-Emscripten.mak |
---|
22 | |
---|
23 | On Linux: |
---|
24 | $EMSCRIPTEN/emmake make --directory=../../cpp -f ../js/sdk/Makefile-SDK-Emscripten.mak |
---|
25 | |
---|
26 | After completing this, the JavaScript version of Framsticks SDK should be available as frams-sdk.js. |
---|
27 | |
---|
28 | |
---|
29 | |
---|
30 | Classes, methods and fields available in JavaScript Framsticks SDK are defined in js_interface/js_interface.idl. |
---|
31 | To access them from a JavaScript app, you need to include the JavaScript version of Framsticks SDK file in HTML: |
---|
32 | <script src="sdk/frams-sdk.js"></script> |
---|
33 | |
---|
34 | and then you can access Framsticks classes in JavaScript files using the Module variable like that: |
---|
35 | let gcm = new Module.DefaultGenoConvManager(); |
---|
36 | gcm.addDefaultConverters(); |
---|
37 | let dummyGeno = new Module.Geno().useConverters(gcm); |
---|
38 | Module.destroy(dummyGeno); |
---|
39 | let validators = new Module.Validators(); |
---|
40 | dummyGeno = new Module.Geno().useValidators(validators); |
---|
41 | Module.destroy(dummyGeno); |
---|
42 | let modelValidator = new Module.ModelGenoValidator(); |
---|
43 | validators.append(modelValidator); |
---|