|
| 1 | +# Compiling LiveCode to JavaScript for HTML5 |
| 2 | + |
| 3 | + |
| 4 | + |
| 5 | +Copyright © 2015 LiveCode Ltd., Edinburgh, UK |
| 6 | + |
| 7 | +**Warning**: Emscripten (HTML5) platform support for LiveCode is experimental and not recommended for production use. |
| 8 | + |
| 9 | +## Dependencies |
| 10 | + |
| 11 | +You will need a 64-bit Linux machine or VM with at least 4 GB of RAM |
| 12 | +(8 GB is recommended). |
| 13 | + |
| 14 | +### Emscripten SDK |
| 15 | + |
| 16 | +Unsurprisingly, the Emscripten SDK must be installed in order to build |
| 17 | +an Emscripten engine. |
| 18 | + |
| 19 | +1. Download the portable Emscripten SDK from <https://kripken.github.io/emscripten/site>. Put it in `/opt/emsdk_portable`, for example. |
| 20 | + |
| 21 | +2. Check what SDKs are available by running: |
| 22 | + |
| 23 | + /opt/emsdk_portable/emsdk list |
| 24 | + |
| 25 | +3. Install and activate the "incoming" SDK by running: |
| 26 | + |
| 27 | + /opt/emsdk_portable/emsdk install sdk-incoming-64bit |
| 28 | + /opt/emsdk_portable/emsdk activate sdk-incoming-64bit |
| 29 | + |
| 30 | + This will take a really long time and use an insane amount of RAM. |
| 31 | + |
| 32 | +## Build environment |
| 33 | + |
| 34 | +Before building for Emscripten, source the Emscripten SDK script that sets up the environment correctly. You need to source it with the `.` or `source` command rather than just running it. |
| 35 | + |
| 36 | + source /opt/emsdk_protable/emsdk_env.sh |
| 37 | + |
| 38 | +## Configuring LiveCode |
| 39 | + |
| 40 | +To configure LiveCode, run: |
| 41 | + |
| 42 | + make config-emscripten |
| 43 | + |
| 44 | +This will generate make control files in the `build-emscripten` directory. You can also run `config.sh` directly. |
| 45 | + |
| 46 | +## Compiling LiveCode |
| 47 | + |
| 48 | +LiveCode currently requires some special setup steps to enable building on Emscripten. |
| 49 | + |
| 50 | +To compile LiveCode, run: |
| 51 | + |
| 52 | + make compile-emscripten |
| 53 | + |
| 54 | +This will generate outputs in the `emscripten-bin` directory. |
| 55 | + |
| 56 | +## Running LiveCode |
| 57 | + |
| 58 | +**Note**: See also the "HTML5 Deployment" guide, available in the in-IDE dictionary. |
| 59 | + |
| 60 | +Use the desktop build of the LiveCode IDE to run the standalone builder and create an "HTML5" standalone. |
| 61 | + |
| 62 | +Once you've created a standalone, you can open the HTML file in a web browser to try out the engine. |
| 63 | + |
| 64 | +Some web browsers (including Google Chrome) have JavaScript security policies that won't allow you to run the engine from a local filesystem. For these browsers, you will need to run a local web server. You can use the following steps to launch a local-only webserver listening on port 8080: |
| 65 | + |
| 66 | + cd /path/to/my/standalone |
| 67 | + python -m SimpleHTTPServer 8080 |
| 68 | + |
| 69 | +You can then load http://localhost:8080/ in a web browser to view your standalone HTML5 engine. |
| 70 | + |
0 commit comments