2018-03-04 14:46:49 +01:00
|
|
|
# Building Node.js with Ninja
|
2016-01-19 21:24:42 +01:00
|
|
|
|
2017-12-17 16:59:46 +01:00
|
|
|
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
|
2019-07-10 07:07:42 +02:00
|
|
|
[Ninja's site][Ninja] for installation instructions (Unix only).
|
2016-01-19 21:24:42 +01:00
|
|
|
|
2020-04-06 19:50:20 +02:00
|
|
|
[Ninja][] is supported in the Makefile. Run `./configure --ninja` to configure
|
|
|
|
the project to run the regular `make` commands with Ninja.
|
2016-01-19 21:24:42 +01:00
|
|
|
|
2020-04-06 19:50:20 +02:00
|
|
|
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.
|
2016-01-19 21:24:42 +01:00
|
|
|
|
2020-04-06 19:50:20 +02:00
|
|
|
When running `make`, you will see output similar to the following
|
2017-12-17 16:59:46 +01:00
|
|
|
if the build has succeeded:
|
|
|
|
|
2020-04-23 20:01:52 +02:00
|
|
|
```console
|
2016-01-19 21:24:42 +01:00
|
|
|
ninja: Entering directory `out/Release`
|
|
|
|
[4/4] LINK node, POSTBUILDS
|
|
|
|
```
|
|
|
|
|
2017-12-17 16:59:46 +01:00
|
|
|
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. Also, Ninja will likely
|
|
|
|
compile much faster than even `make -j4` (or
|
2020-04-06 19:50:20 +02:00
|
|
|
`-j<number of processor threads on your machine>`). You can still pass the
|
|
|
|
number of processes to run for [Ninja][] using the environment variable `JOBS`.
|
|
|
|
This will be the equivalent to the `-j` parameter in the regular `make`:
|
2016-01-19 21:24:42 +01:00
|
|
|
|
2020-04-06 19:50:20 +02:00
|
|
|
```bash
|
2020-06-02 03:37:23 +02:00
|
|
|
JOBS=12 make
|
2020-04-06 19:50:20 +02:00
|
|
|
```
|
2016-01-19 21:24:42 +01:00
|
|
|
|
|
|
|
## Producing a debug build
|
|
|
|
|
2020-04-06 19:50:20 +02:00
|
|
|
To create a debug build rather than a release build:
|
|
|
|
|
|
|
|
```bash
|
2020-06-02 03:37:23 +02:00
|
|
|
./configure --ninja --debug && make
|
2020-04-06 19:50:20 +02:00
|
|
|
```
|
2016-01-19 21:24:42 +01:00
|
|
|
|
2016-10-25 22:04:13 +02:00
|
|
|
[Ninja]: https://ninja-build.org/
|