Building and Running
This document describes how to build and run Hermes as a standalone compiler and VM. To use Hermes in the context of a React Native app, see the React Native documentation.
#
DependenciesHermes is a C++11 project. clang, gcc, and Visual C++ are supported. Hermes also requires cmake, git, ICU, Python, and zip. It builds with CMake and ninja.
The Hermes REPL will also use libreadline, if available.
To install dependencies on Ubuntu:
On Arch Linux:
On Mac via Homebrew:
#
Building on Linux and macOSHermes will place its build files in the current directory by default.
You can also give explicit source and build directories, use --help
on the build scripts to see how.
Create a base directory to work in, e.g. ~/workspace
, and cd into it.
(Tip: avoid naming it hermes
, as hermes
will be one of several subdirectories in the workspace).
After cd
ing, follow the steps below to generate the Hermes build system:
The build system has now been generated in the build
directory. To perform the build:
#
Release BuildThe above instructions create an unoptimized debug build. The --distribute
flag will enable a release build, in the build_release
directory. Example:
#
Building on WindowsThe Windows build depends on which particular combination of GitBash/Cygwin/WSL and Visual Studio is used.
#
Running HermesThe primary binary is the hermes
tool, which will be found at build/bin/hermes
. This tool compiles JavaScript to Hermes bytecode. It can also execute JavaScript, from source or bytecode or be used as a REPL.
#
Executing JavaScript with Hermes#
Compiling and Executing JavaScript with Bytecode#
Running TestsTo run the Hermes test suite:
#
Formatting CodeTo automatically format all your changes, you will need clang-format
, then
simply run:
#
Other ToolsIn addition to hermes
, the following tools will be built:
hdb
: JavaScript command line debuggerhbcdump
: Hermes bytecode disassemblerhermesc
: Standalone Hermes compiler. This can compile JavaScript to Hermes bytecode, but does not support executing it.hvm
: Standalone Hermes VM. This can execute Hermes bytecode, but does not support compiling it.