Skip to content

Commit

Permalink
build: re-add --ninja option to configure
Browse files Browse the repository at this point in the history
Ninja is a build backend supported by gyp which is much faster than
Make and is able to parallelize builds across all of the available
cores very well. On my machine, this reduces the average build time
from 5:14 minutes to 4:33 minutes.

Refs: #467
Refs: de224d6
PR-URL: #6780
Reviewed-By: Jeremiah Senkpiel <[email protected]>
  • Loading branch information
ehsan authored and rvagg committed Oct 18, 2016
1 parent f64dd5e commit 9c30a0f
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 7 deletions.
10 changes: 10 additions & 0 deletions configure
Original file line number Diff line number Diff line change
Expand Up @@ -370,6 +370,11 @@ parser.add_option('--xcode',
dest='use_xcode',
help='generate build files for use with xcode')

parser.add_option('--ninja',
action='store_true',
dest='use_ninja',
help='generate build files for use with Ninja')

parser.add_option('--enable-asan',
action='store_true',
dest='enable_asan',
Expand Down Expand Up @@ -776,6 +781,9 @@ def configure_node(o):

o['variables']['asan'] = int(options.enable_asan or 0)

if options.use_xcode and options.use_ninja:
raise Exception('--xcode and --ninja cannot be used together.')

def configure_library(lib, output):
shared_lib = 'shared_' + lib
output['variables']['node_' + shared_lib] = b(getattr(options, shared_lib))
Expand Down Expand Up @@ -1197,6 +1205,8 @@ gyp_args = [sys.executable, 'tools/gyp_node.py', '--no-parallel']

if options.use_xcode:
gyp_args += ['-f', 'xcode']
elif options.use_ninja:
gyp_args += ['-f', 'ninja']
elif flavor == 'win' and sys.platform != 'msys':
gyp_args += ['-f', 'msvs', '-G', 'msvs_version=auto']
else:
Expand Down
13 changes: 6 additions & 7 deletions doc/guides/building-node-with-ninja.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,11 @@

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:
To build Node with ninja, there are 3 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`.
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`.

When running `ninja -C out/Release` you will see output similar to the following if the build has succeeded:
```
Expand All @@ -28,12 +27,12 @@ As such, if you wish to run the tests, it can be helpful to invoke the test runn

## Alias

`alias nnode='./configure && tools/gyp_node.py -f ninja && ninja -C out/Release && ln -fs out/Release/node node'`
`alias nnode='./configure --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'`
`alias nnodedebug='./configure --ninja && ninja -C out/Debug && ln -fs out/Debug/node node_g'`


[Ninja]: https://martine.github.io/ninja/

0 comments on commit 9c30a0f

Please sign in to comment.