Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add WebAssembly build instructions #25

Merged
merged 1 commit into from
Nov 9, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,35 @@ For more detailed documentation of all available options and functionality, visi

## Building

### Compiling MiniZinc for WebAssembly

The WebAssembly build of MiniZinc requires [Emscripten](https://emscripten.org/).

```sh
# Clone MiniZinc
git clone https://github.com/MiniZinc/libminizinc minizinc

# Download solvers (or you can build them yourself using emscripten)
cd minizinc
MZNARCH=wasm ./download_vendor

# Configure MiniZinc
emcmake cmake -S . -B build \
-DCMAKE_FIND_ROOT_PATH="/" \
-DCMAKE_BUILD_TYPE=Release \
-DGecode_ROOT="$PWD/vendor/gecode" \
-DOsiCBC_ROOT="$PWD/vendor/cbc" \
-DCMAKE_PREFIX_PATH="$PWD/vendor/highs/lib/cmake/highs:$PWD/vendor/chuffed/lib/cmake/chuffed" \
-DCMAKE_INSTALL_PREFIX="../minizinc-install"

# Build MiniZinc
cmake --build build --config Release --target install
```

The WebAssembly build of MiniZinc can also be obtained from the [build workflow](https://github.com/MiniZinc/minizinc-js/actions/workflows/build.yml) as the `minizinc` artifact.

### Building MiniZinc JS

1. Run `npm install` to install dependencies.
2. Place the `bin/` folder of the WebAssembly build of MiniZinc inside this directory.
Alternatively set the `MZN_WASM_DIR` environment variable to the installation directory of the
Expand Down