Copyright 2019-2021 Moddable Tech, Inc.
Revised: June 14, 2021
This document provides instructions to build and run Moddable SDK apps for the Wasm platform.
-
Setup instructions
Setup instructions Setup instructions
-
Clone the Emscripten repository into your
~/Projects
directory and activate the latest version.cd ~/Projects git clone https://github.com/emscripten-core/emsdk.git cd emsdk ./emsdk install latest ./emsdk activate latest
If you already have the Emscripten repository, upgrade to the latest version using the following commands:
cd ~/Projects/emsdk git pull ./emsdk install latest ./emsdk activate latest
We last tested using version 2.0.24 (commit
e2dc11e0dbd8f9367d70c76e57cdb9a45515390e
). -
Clone the Binaryen repository into your
~/Projects
directory and build it.cd ~/Projects git clone https://github.com/WebAssembly/binaryen.git cd binaryen cmake . && make
We last tested using wasm-opt version 101 (commit
aec8d12282b5279b80e79f21d54491db5d55278e
) -
Setup the
PATH
and other environment variables by pasting the following commands into your~/.profile
. The first command sources a shell script that sets environment variables for Emscripten. The second updates yourPATH
to include BinaryEn.source ~/Projects/emsdk/emsdk_env.sh export PATH=~/Projects/binaryen/bin:$PATH
Note: These instructions assume that your shell sources from
~/.profile
when a new terminal is opened. That may not be the case depending on what shell you use and how you have it configured. Starting with macOS Catalina, the default shell iszsh
which uses~/.zshrc
instead.Note: You must open a new shell instance or manually run the export statements in your shell before proceeding. Adding the export statements to your
~/.profile
does not update the environment variables in active shell instances. -
Build the Moddable Wasm tools from the command line:
cd ${MODDABLE}/build/makefiles/wasm make
-
To test, build the
balls
example for thewasm
target.cd $MODDABLE/examples/piu/balls mcconfig -d -m -p wasm
You can run the app that's built in the browser by hosting it on a local HTTP server. Python provides a simple tool for doing this.
If you are using Python 2:
cd $MODDABLE/build/bin/wasm/debug/balls python -m SimpleHTTPServer
If you are using Python 3:
cd $MODDABLE/build/bin/wasm/debug/balls python3 -m http.server
Go to
localhost:8000
in a browser. You should see a web page with a simulator runningballs
.
-
Clone the Emscripten repository into your
~/Projects
directory and activate the latest version.cd ~/Projects git clone https://github.com/emscripten-core/emsdk.git cd emsdk ./emsdk install latest ./emsdk activate latest
If you already have the Emscripten repository, upgrade to the latest version using the following commands:
cd ~/Projects/emsdk git pull ./emsdk install latest ./emsdk activate latest
We last tested using version 2.0.4 (commit
88b4ec65923815c3077e3637eefb54ab272d2646
). -
Clone the Binaryen repository into your
~/Projects
directory and build it.cd ~/Projects git clone https://github.com/WebAssembly/binaryen.git cd binaryen cmake . && make
We last tested using wasm-opt version 96 (commit
a96e8310e1a58c0a43b2d0e2ff4f9db24dd9a18a
) -
Setup the
PATH
and other environment variables by pasting the following commands into your~/.bashrc
. The first command sources a shell script that sets environment variables for Emscripten. The second updates yourPATH
to include BinaryEn.source ~/Projects/emsdk/emsdk_env.sh export PATH=~/Projects/binaryen/bin:$PATH
Note: You must open a new shell instance or manually run the export statements in your shell before proceeding. Adding the export statements to your
~/.profile
does not update the environment variables in active shell instances. -
Build the Moddable Wasm tools from the command line:
cd ${MODDABLE}/build/makefiles/wasm make
-
To test, build the
balls
example for thewasm
target.cd $MODDABLE/examples/piu/balls mcconfig -d -m -p wasm
You can run the app that's built in the browser by hosting it on a local HTTP server. Python provides a simple tool for doing this.
If you are using Python 2:
cd $MODDABLE/build/bin/wasm/debug/balls python -m SimpleHTTPServer
If you are using Python 3:
cd $MODDABLE/build/bin/wasm/debug/balls python3 -m http.server
Go to
localhost:8000
in a browser. You should see a web page with a simulator runningballs
.
Not all features of the Moddable SDK are supported in the Wasm simulator.
The following features are currently supported:
- All JavaScript features supported by XS
- Piu user interface framework
- Commodetto graphics library
The following features are not supported:
- Files
- Socket
- BLE
- Pins/IO