Skip to content

Commit 8da0500

Browse files
ehsanFishrock123
authored andcommittedMay 30, 2016
build: re-add --ninja option to configure
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: nodejs#467 Refs: de224d6 PR-URL: nodejs#6780 Reviewed-By: Jeremiah Senkpiel <[email protected]>
1 parent 7010b94 commit 8da0500

File tree

2 files changed

+16
-7
lines changed

2 files changed

+16
-7
lines changed
 

‎configure

+10
Original file line numberDiff line numberDiff line change
@@ -394,6 +394,11 @@ parser.add_option('--xcode',
394394
dest='use_xcode',
395395
help='generate build files for use with xcode')
396396

397+
parser.add_option('--ninja',
398+
action='store_true',
399+
dest='use_ninja',
400+
help='generate build files for use with Ninja')
401+
397402
parser.add_option('--enable-asan',
398403
action='store_true',
399404
dest='enable_asan',
@@ -806,6 +811,9 @@ def configure_node(o):
806811

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

814+
if options.use_xcode and options.use_ninja:
815+
raise Exception('--xcode and --ninja cannot be used together.')
816+
809817
def configure_library(lib, output):
810818
shared_lib = 'shared_' + lib
811819
output['variables']['node_' + shared_lib] = b(getattr(options, shared_lib))
@@ -1241,6 +1249,8 @@ gyp_args = [sys.executable, 'tools/gyp_node.py', '--no-parallel']
12411249

12421250
if options.use_xcode:
12431251
gyp_args += ['-f', 'xcode']
1252+
elif options.use_ninja:
1253+
gyp_args += ['-f', 'ninja']
12441254
elif flavor == 'win' and sys.platform != 'msys':
12451255
gyp_args += ['-f', 'msvs', '-G', 'msvs_version=auto']
12461256
else:

‎doc/guides/building-node-with-ninja.md

+6-7
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,11 @@
22

33
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).
44

5-
To build Node with ninja, there are 4 steps that must be taken:
5+
To build Node with ninja, there are 3 steps that must be taken:
66

7-
1. Configure the project's OS-based build rules via `./configure` as usual.
8-
2. Use `tools/gyp_node.py -f ninja` to produce Ninja-buildable `gyp` output.
9-
3. Run `ninja -C out/Release` to produce a compiled release binary.
10-
4. Lastly, make symlink to `./node` using `ln -fs out/Release/node node`.
7+
1. Configure the project's OS-based build rules via `./configure --ninja`.
8+
2. Run `ninja -C out/Release` to produce a compiled release binary.
9+
3. Lastly, make symlink to `./node` using `ln -fs out/Release/node node`.
1110

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

2928
## Alias
3029

31-
`alias nnode='./configure && tools/gyp_node.py -f ninja && ninja -C out/Release && ln -fs out/Release/node node'`
30+
`alias nnode='./configure --ninja && ninja -C out/Release && ln -fs out/Release/node node'`
3231

3332
## Producing a debug build
3433

3534
The above alias can be modified slightly to produce a debug build, rather than a release build as shown below:
36-
`alias nnodedebug='./configure && tools/gyp_node.py -f ninja && ninja -C out/Debug && ln -fs out/Debug/node node_g'`
35+
`alias nnodedebug='./configure --ninja && ninja -C out/Debug && ln -fs out/Debug/node node_g'`
3736

3837

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

0 commit comments

Comments
 (0)
Please sign in to comment.