0
0
mirror of https://github.com/nodejs/node.git synced 2024-11-30 23:43:09 +01:00
nodejs/doc/contributing/building-node-with-ninja.md
Jeff Dickey fd07bab7ae
build: added NINJA env to customize ninja binary
Fixes: https://github.com/nodejs/node/issues/44286
PR-URL: https://github.com/nodejs/node/pull/44293
Reviewed-By: Richard Lau <rlau@redhat.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
2022-08-22 11:39:00 +00:00

1.7 KiB

Building Node.js with Ninja

The purpose of this guide is to show how to build Node.js using Ninja, as doing so can be significantly quicker than using make. Please see Ninja's site for installation instructions (Unix only).

Ninja is supported in the Makefile. Run ./configure --ninja to configure the project to run the regular make commands with Ninja.

For example, make will execute ninja -C out/Release internally to produce a compiled release binary, It will also execute ln -fs out/Release/node node, so that you can execute ./node at the project's root.

When running make, you will see output similar to the following if the build has succeeded:

ninja: Entering directory `out/Release`
[4/4] LINK node, POSTBUILDS

The bottom line will change while building, showing the progress as [finished/total] build steps. This is useful output that make does not produce and is one of the benefits of using Ninja. When using Ninja, builds are always run in parallel, based by default on the number of CPUs your system has. You can use the -j parameter to override this behavior, which is equivalent to the -j parameter in the regular make:

make -j4 # With this flag, Ninja will limit itself to 4 parallel jobs,
         # regardless of the number of cores on the current machine.

Producing a debug build

To create a debug build rather than a release build:

./configure --ninja --debug && make

Customizing ninja path

On some systems (such as RHEL7 and below), the Ninja binary might be installed with a different name. For these systems use the NINJA env var:

./configure --ninja && NINJA="ninja-build" make