From ebbc64bc97bc3f883a1f1ea6962de1f177a27598 Mon Sep 17 00:00:00 2001 From: Jeremiah Senkpiel Date: Tue, 19 Jan 2016 15:24:42 -0500 Subject: [PATCH] doc: add "building node with ninja" guide PR-URL: https://github.com/nodejs/node/pull/4767 Refs: https://github.com/nodejs/docs/pull/38 Reviewed-By: Bryan English Reviewed-By: Stephan Belanger --- doc/guides/building-node-with-ninja.md | 39 ++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 doc/guides/building-node-with-ninja.md diff --git a/doc/guides/building-node-with-ninja.md b/doc/guides/building-node-with-ninja.md new file mode 100644 index 0000000..550effa --- /dev/null +++ b/doc/guides/building-node-with-ninja.md @@ -0,0 +1,39 @@ +# Building Node 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][Ninja] for installation instructions (unix only). + +To build Node with ninja, there are 4 steps that must be taken: + +1. Configure the project's OS-based build rules via `./configure` as usual. +2. Use `tools/gyp_node.py -f ninja` to produce Ninja-buildable `gyp` output. +3. Run `ninja -C out/Release` to produce a compiled release binary. +4. Lastly, make symlink to `./node` using `ln -fs out/Release/node node`. + +When running `ninja -C out/Release` 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. +Also, Ninja will likely compile much faster than even `make -j8` (or `-j`). + +## Considerations + +Ninja builds vary slightly from `make` builds. If you wish to run `make test` after, `make` will likely still need to rebuild some amount of Node. + +As such, if you wish to run the tests, it can be helpful to invoke the test runner directly, like so: +`tools/test.py --mode=release message parallel sequential -J` + +## Alias + +`alias nnode='./configure && tools/gyp_node.py -f ninja && ninja -C out/Release && ln -fs out/Release/node node'` + +## Producing a debug build + +The above alias can be modified slightly to produce a debug build, rather than a release build as shown below: +`alias nnodedebug='./configure && tools/gyp_node.py -f ninja && ninja -C out/Debug && ln -fs out/Debug/node node_g'` + + +[Ninja]: https://martine.github.io/ninja/ -- 2.7.4