Skip to content

Commit

Permalink
Migrate documentation to directly invoke CMake
Browse files Browse the repository at this point in the history
Summary: Update documentation to avoid configure.py, and delete it.

Reviewed By: jpporto

Differential Revision: D35342500

fbshipit-source-id: caff5ee274bce4df998295ff5409700d09488b64
  • Loading branch information
neildhar authored and facebook-github-bot committed Apr 4, 2022
1 parent f75d5a8 commit 26468cc
Show file tree
Hide file tree
Showing 7 changed files with 31 additions and 349 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ set(HERMES_ENABLE_TRACE_PC_GUARD OFF CACHE BOOL
"Enable -fsanitize-coverage=trace-pc-guard")

set(HERMES_ENABLE_CODE_COVERAGE OFF CACHE BOOL
"Enable code coverage to be generated when running binaries")
"Enables code coverage to be collected from binaries. Coverage output will be placed in a subdirectory called \"coverage\" of the build directory.")

set(HERMES_ENABLE_LIBFUZZER OFF CACHE BOOL
"Enable libfuzzer")
Expand Down
10 changes: 4 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,8 @@ To build a local debug version of the Hermes CLI tools the following steps shoul
mkdir hermes_workingdir
cd hermes_workingdir
git clone https://github.com/facebook/hermes.git
hermes/utils/build/configure.py
cd build
ninja
cmake -S hermes -B build -G Ninja
cmake --build ./build
```

Or if you're using Windows, the following should get you going in a Git Bash shell:
Expand All @@ -34,9 +33,8 @@ Or if you're using Windows, the following should get you going in a Git Bash she
mkdir hermes_workingdir
cd hermes_workingdir
git -c core.autocrlf=false clone https://github.com/facebook/hermes.git
hermes/utils/build/configure.py --build-system='Visual Studio 16 2019' --cmake-flags='-A x64' --distribute
cd build
MSBuild.exe ALL_BUILD.vcxproj /p:Configuration=Release
cmake -S hermes -B build -G 'Visual Studio 16 2019' -A x64
cmake --build ./build
```

You will now be in a directory with the output of building Hermes into CLI tools. From here you can run a piece of JavaScript as follows:
Expand Down
22 changes: 8 additions & 14 deletions doc/BuildingAndRunning.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,32 +33,26 @@ Create a base directory to work in, e.g. `~/workspace`, and cd into it.
After `cd`ing, follow the steps below to generate the Hermes build system:

git clone https://github.com/facebook/hermes.git
hermes/utils/build/configure.py
cmake -S hermes -B build -G Ninja

The build system has now been generated in the `build` directory. To perform the build:

cd build && ninja

Note that you can also pass an argument to specify a customized directory:

hermes/utils/build/configure.py ~/out_of_tree_build
cd out_of_tree_build && ninja
cmake --build ./build


## Release Build

The above instructions create an unoptimized debug build. The `--distribute` flag will enable a release build, in the `build_release` directory. Example:
The above instructions create an unoptimized debug build. The `-DCMAKE_BUILD_TYPE=Release` flag will create a release build:

hermes/utils/build/configure.py --distribute
cd build_release && ninja
cmake -S hermes -B build_release -G Ninja -DCMAKE_BUILD_TYPE=Release
cmake --build ./build_release

## Building on Windows

The Windows build depends on which particular combination of GitBash/Cygwin/WSL and Visual Studio is used.
To build on Windows using Visual Studio with a checkout in the `hermes` directory:

git -c core.autocrlf=false clone https://github.com/facebook/hermes.git
hermes/utils/build/configure.py --build-system='Visual Studio 16 2019' --distribute
cd build_release && MSBuild.exe ALL_BUILD.vcxproj /p:Configuration=Release
cmake -S hermes -B build -G 'Visual Studio 16 2019'
cmake --build ./build

## Running Hermes

Expand Down
2 changes: 1 addition & 1 deletion doc/CrossCompilation.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ workspace where the `hermes` git checkout directory is a subdirectory.
cd "$HERMES_WS_DIR"
# Generate the build system at $HERMES_WS_DIR/build_host_hermesc
hermes/utils/build/configure.py ./build_host_hermesc
cmake -S hermes -B ./build_host_hermesc
# Build the Hermes compiler
cmake --build ./build_host_hermesc --target hermesc
Expand Down
54 changes: 15 additions & 39 deletions doc/Emscripten.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,46 +38,22 @@ Please follow the [Cross Compilation](./CrossCompilation.md) to set up a workpla
and build a host hermesc at `$HERMES_WS_DIR/build_host_hermesc`.


## Building Hermes With configure.py
# Building Hermes With Emscripten and CMake

cmake -S ${HermesSourcePath?} -B build \
-DCMAKE_TOOLCHAIN_FILE=${EmscriptenRoot?}/emscripten/cmake/Modules/Platform/Emscripten.cmake \
-DCMAKE_BUILD_TYPE=MinSizeRel \
-DEMSCRIPTEN_FASTCOMP=1 \
-DCMAKE_EXE_LINKER_FLAGS="-s NODERAWFS=1 -s WASM=0 -s ALLOW_MEMORY_GROWTH=1"
# Build Hermes
cmake --build ./build --target hermes --parallel
# Execute hermes
node bin/hermes.js --help

In the commands above, replace `${HermesSourcePath?}` with the path where you
cloned Hermes, and `${EmscriptenRoot?}` with the path to your Emscripten
install.

```
# Configure the build. Here the build is output to a
# directory starting with the prefix "embuild".
python3 ${HERMES_WS_DIR}/hermes/utils/build/configure.py \
--cmake-flags " -DIMPORT_HERMESC:PATH=${HERMES_WS_DIR}/build_host_hermesc/ImportHermesc.cmake " \
--distribute \
--wasm \
--emscripten-platform=upstream \
--emscripten-root="${EmscriptenRoot?}" \
/tmp/embuild
# Build Hermes. The build directory name will depend on the flags passed to
# configure.py.
cmake --build /tmp/embuild --target hermes
# Execute hermes
node /tmp/embuild/bin/hermes.js --help
```

Make sure that the `--emscripten-platform` option matches the directory given
to `--emscripten-root`, and is also the current activated Emscripten toolchain
via `emsdk activate`.

See `configure.py --help` for more build options.

## Build with CMake directly

The `configure.py` script runs CMake for you with options chosen by the Hermes
project. If you want to customize your build, you can take this command as a
base.

```
cmake ${HERMES_WS_DIR}/hermes \
-B embuild \
-DCMAKE_TOOLCHAIN_FILE=${EmscriptenRoot?}/cmake/Modules/Platform/Emscripten.cmake \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_EXE_LINKER_FLAGS="-s NODERAWFS=1 -s WASM=1 -s ALLOW_MEMORY_GROWTH=1" \
-DIMPORT_HERMESC:PATH="${HERMES_WS_DIR}/build_host_hermesc/ImportHermesc.cmake"
```

Each option is explained below:
* `CMAKE_BUILD_TYPE`: set it to one of CMake's build modes: `Debug`, `Release`,
Expand Down
5 changes: 2 additions & 3 deletions doc/Hades.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,8 @@ with the interpreter.

# Enabling Hades

In local builds on the command line using CMake or `configure.py` (which
forwards to CMake), Hades is the default GC used, and currently the only GC
supported for production use.
In local builds on the command line using CMake (which forwards to CMake), Hades
is the default GC used, and currently the only GC supported for production use.
The GC being used is controlled by the CMake variable `-DHERMESVM_GCKIND=value`.

To use a pre-built package of Hermes with Hades enabled, check the
Expand Down
Loading

0 comments on commit 26468cc

Please sign in to comment.