There are a number of prerequisites for building the code in this repo.
Here follow terse descriptions on how to get there.
-
Follow these instructions to install the Rust toolchain.
- There are other installation paths, but
rustup
is heartily recommended. - Installing
rustup
should also installcargo
, Rust's day-to-day workhorse tool. - Run
rustup update
both now & occasionally, to get updates to languages & components.
- There are other installation paths, but
- Follow these to install wasm-bindgen.
- This is the tool that binds Rust and WebAssembly together.
- For sturdiness, we require specific versions of Node.js.
- To that end, install nvm, the Node
Version Manager.
- Note the instructions on how to enable
nvm
for your current shell session.
- Note the instructions on how to enable
- Grab a stable node version for general use:
nvm install --lts --latest-npm
- Further down, you will run a script that installs a specific node version for our use.
- To that end, install nvm, the Node
Version Manager.
Grab the actual repository:
> git clone https://github.com/facebookincubator/glTFVariantMeld
> cd glTFVariantMeld
At this point you should be able to run cargo build
, which will recurse into ./native
where the Rust source lives. Binaries will end up in ./target/debug/
.
If you now try:
> ./build-wasm-pkg.sh
you should end up with a generated NPM package in ./web/wasmpkg/
.
You can eyeball it for fun, but we don't do anything with the generated package directly. We just reference it from elsewhere, as per the next section.
Now simply run:
> cd web/cli
> npm install
> ./build-node-app.sh
This script should make sure you've got NVM installed, and then use it to make sure you're running the recommended Node.js version, then execute the TypeScript-blessed WebPack to generate the required files in ./dist
. Something like this:
> ls -l ./dist
-rw-r--r-- 1 zell staff 31497 Sep 17 17:05 0.app.js
-rwxr-xr-x 1 zell staff 31707 Sep 17 17:05 app.js
-rw-r--r-- 1 zell staff 1010595 Sep 17 17:05 d4d094458c23e79dfea6.module.wasm
Finally, the script executes dist/app.js
which actually runs the app.
Tada! You have built a native library, converted it to WebAssembly, bundled it all into executable JavaScript, and successfully run it. It's not much harder to run it in the browser, but instructions for that will come later.