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
|
|
|
|
2018-03-04 14:46:49 +01:00
|
|
|
To build Node.js with ninja, there are 3 steps that must be taken:
|
2016-01-19 21:24:42 +01:00
|
|
|
|
2016-05-16 03:51:07 +02:00
|
|
|
1. Configure the project's OS-based build rules via `./configure --ninja`.
|
|
|
|
2. Run `ninja -C out/Release` to produce a compiled release binary.
|
|
|
|
3. Lastly, make symlink to `./node` using `ln -fs out/Release/node node`.
|
2016-01-19 21:24:42 +01:00
|
|
|
|
2017-12-17 16:59:46 +01:00
|
|
|
When running `ninja -C out/Release` you will see output similar to the following
|
|
|
|
if the build has succeeded:
|
|
|
|
|
2016-07-09 07:13:09 +02:00
|
|
|
```txt
|
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
|
|
|
|
`-j<number of processor threads on your machine>`).
|
2016-01-19 21:24:42 +01:00
|
|
|
|
|
|
|
## Considerations
|
|
|
|
|
2017-12-17 16:59:46 +01:00
|
|
|
Ninja builds vary slightly from `make` builds. If you wish to run `make test`
|
2018-03-04 14:46:49 +01:00
|
|
|
after, `make` will likely still need to rebuild some amount of Node.js.
|
2016-01-19 21:24:42 +01:00
|
|
|
|
2017-12-17 16:59:46 +01:00
|
|
|
As such, if you wish to run the tests, it can be helpful to invoke the test
|
|
|
|
runner directly, like so:
|
2016-01-19 21:24:42 +01:00
|
|
|
`tools/test.py --mode=release message parallel sequential -J`
|
|
|
|
|
|
|
|
## Alias
|
|
|
|
|
2018-02-12 08:31:55 +01:00
|
|
|
`alias nnode='./configure --ninja && ninja -C out/Release && ln -fs
|
|
|
|
out/Release/node node'`
|
2016-01-19 21:24:42 +01:00
|
|
|
|
|
|
|
## Producing a debug build
|
|
|
|
|
2017-12-17 16:59:46 +01:00
|
|
|
The above alias can be modified slightly to produce a debug build, rather than a
|
|
|
|
release build as shown below:
|
2018-02-12 08:31:55 +01:00
|
|
|
`alias nnodedebug='./configure --ninja && ninja -C out/Debug && ln -fs
|
|
|
|
out/Debug/node node_g'`
|
2016-01-19 21:24:42 +01:00
|
|
|
|
2016-10-25 22:04:13 +02:00
|
|
|
[Ninja]: https://ninja-build.org/
|