@@ -4,12 +4,18 @@ Similar to GYP, GN is a build system designed for building Chromium. The
4
4
official builds of Node.js are built with GYP, but GN build files are also
5
5
provided as an unofficial alternative build system.
6
6
7
+ The GN build files only support a subset of the Node.js build configurations.
8
+ It's not required for all pull requests to Node.js to support GN builds, and
9
+ Node.js's own CI does not currently test GN builds, though Node.js welcomes pull
10
+ requests that improve GN support or fix breakages introduced by other pull
11
+ requests.
12
+
7
13
Currently the GN build is used by:
8
14
9
15
1 . Electron for building Node.js together with Chromium.
10
16
2 . V8 for testing the integration of Node.js in CI.
11
17
12
- ## Files of GN
18
+ ## Files for GN support
13
19
14
20
Node.js contains following GN build files:
15
21
@@ -24,14 +30,15 @@ Unlike GYP, the GN tool does not include any built-in rules for compiling a
24
30
project, which means projects building with GN must provide their own build
25
31
configurations for things like how to invoke a C++ compiler. Chromium related
26
32
projects like V8 and skia choose to reuse Chromium's build configurations, and
27
- we are reusing V8's Node.js integration testing repository
28
- ([ node-ci] ( https://chromium.googlesource.com/v8/node-ci/ ) ) for building Node.js.
33
+ V8's Node.js integration testing repository
34
+ ([ node-ci] ( https://chromium.googlesource.com/v8/node-ci/ ) ) can be reused for
35
+ building Node.js.
29
36
30
37
### 1. Install ` depot_tools `
31
38
32
39
The ` depot_tools ` is a set of tools used by Chromium related projects for
33
- checking out code and managing dependencies, and since we are reusing the infra
34
- of V8, we have to install and add it to ` PATH ` :
40
+ checking out code and managing dependencies, and since this guide is reusing the
41
+ infra of V8, it needs to be installed and added to ` PATH ` :
35
42
36
43
``` bash
37
44
git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git
@@ -41,7 +48,7 @@ export PATH=/path/to/depot_tools:$PATH
41
48
You can also follow the [ official tutorial of
42
49
` depot_tools ` ] ( https://commondatastorage.googleapis.com/chrome-infra-docs/flat/depot_tools/docs/html/depot_tools_tutorial.html ) .
43
50
44
- ### 2. Check out code
51
+ ### 2. Check out code of Node.js
45
52
46
53
To check out the latest main branch of Node.js for building, use the ` fetch `
47
54
tool from ` depot_tools ` :
@@ -77,36 +84,42 @@ The `node_gn` is a workspace directory, which only contains configurations and
77
84
caches of the ` gclient ` tool from ` depot_tools ` , and the repository is checked
78
85
out at ` node_gn/node ` .
79
86
80
- The ` node_gn/node ` directory is not the repository of Node.js, it is actually
81
- node-ci, the repository used by V8 for testing integration with Node.js. The
82
- source code of Node.js is checked out at ` node_gn/node/node ` .
87
+ The ` node_gn/node ` directory is not a checkout of Node.js, it is actually
88
+ [ node-ci] ( https://chromium.googlesource.com/v8/node-ci/ ) , the repository used by
89
+ V8 for testing integration with Node.js. The source code of Node.js is checked
90
+ out at ` node_gn/node/node ` .
83
91
84
92
### 3. Build
85
93
86
94
GN only supports [ ` ninja ` ] ( https://ninja-build.org ) for building, so to build
87
- Node.js with GN we have to generate ` ninja ` build files first and then call
88
- ` ninja ` to do the building.
95
+ Node.js with GN, ` ninja ` build files should be generated first, and then
96
+ ` ninja ` can be invoked to do the building.
89
97
90
98
The ` node-ci ` repository provides a script for calling GN:
91
99
92
100
``` bash
101
+ cd node # Enter `node_gn/node` which contains a node-ci checkout
93
102
./tools/gn-gen.py out/Release
94
103
```
95
104
96
- which writes ` ninja ` build files into the ` out/Release ` directory.
105
+ which writes ` ninja ` build files into the ` out/Release ` directory under
106
+ ` node_gn/node ` .
97
107
98
108
And then you can execute ` ninja ` :
99
109
100
110
``` bash
101
111
ninja -C out/Release node
102
112
```
103
113
114
+ After the build is completed, the compiled Node.js executable can be found in
115
+ ` out/Release/node ` .
116
+
104
117
## Status of the GN build
105
118
106
119
Currently the GN build of Node.js is not fully functioning. It builds for macOS
107
- and Linux, but we are still fixing a few issues to make the Windows build work.
108
- And not all tests are passing using the GN build.
120
+ and Linux, while the Windows build is still a work in progress. And some tests
121
+ are still failing with the GN build.
109
122
110
- There are also efforts on [ making GN build work without using
111
- ` depot_tools ` ] ( https://github.com/photoionization/node_with_gn ) , which uses a
112
- [ forked version of GN ] ( https://github.com/yue/build-gn ) .
123
+ There are also efforts on making GN build work without using ` depot_tools ` ,
124
+ which is tracked in the issue
125
+ [ # 51689 ] ( https://github.com/nodejs/node/issues/51689 ) .
0 commit comments