id | title |
---|---|
cross-compilation |
Cross Compilation |
This document describes how to build Hermes in a cross compilation setting, e.g. building for Android, WASM (with Emscripten), or any other platforms different than the host development machines.
Hermes now requires a two stage build proecess because the VM now contains Hermes bytecode which needs to be compiled by Hermes
We will use environment variable $HERMES_WS_DIR
to indicate the root of your
workspace where the hermes
git checkout directory is a subdirectory.
cd "$HERMES_WS_DIR"
# Generate the build system at $HERMES_WS_DIR/build
cmake -S hermes -B ./build
# Build the Hermes compiler
cmake --build ./build --target hermesc
The key is that we need to pass a CMake flag -DIMPORT_HERMESC:PATH=$HERMES_WS_DIR/build_host_hermesc/ImportHermesc.cmake
during the cross compilation build of
Hermes so it can access the host hermesc
from the first stage to build the VM.
This process is currently happened in different places for different platforms:
- For Android, this happened in
hermes/android/build.gradle
- For Apple platforms, this happend in
hermes/utils/build-apple-framework.sh
- For Emscripten, you can find an example from the
test-emscripten
job fromhermes/.circleci/config.yml
. Also see more details at Building with Emscripten