Skip to content

Commit a0216ca

Browse files
committed
solve review comments
1 parent c06ffee commit a0216ca

File tree

1 file changed

+30
-17
lines changed

1 file changed

+30
-17
lines changed

doc/contributing/gn-build.md

+30-17
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,18 @@ Similar to GYP, GN is a build system designed for building Chromium. The
44
official builds of Node.js are built with GYP, but GN build files are also
55
provided as an unofficial alternative build system.
66

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+
713
Currently the GN build is used by:
814

915
1. Electron for building Node.js together with Chromium.
1016
2. V8 for testing the integration of Node.js in CI.
1117

12-
## Files of GN
18+
## Files for GN support
1319

1420
Node.js contains following GN build files:
1521

@@ -24,14 +30,15 @@ Unlike GYP, the GN tool does not include any built-in rules for compiling a
2430
project, which means projects building with GN must provide their own build
2531
configurations for things like how to invoke a C++ compiler. Chromium related
2632
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.
2936

3037
### 1. Install `depot_tools`
3138

3239
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`:
3542

3643
```bash
3744
git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git
@@ -41,7 +48,7 @@ export PATH=/path/to/depot_tools:$PATH
4148
You can also follow the [official tutorial of
4249
`depot_tools`](https://commondatastorage.googleapis.com/chrome-infra-docs/flat/depot_tools/docs/html/depot_tools_tutorial.html).
4350

44-
### 2. Check out code
51+
### 2. Check out code of Node.js
4552

4653
To check out the latest main branch of Node.js for building, use the `fetch`
4754
tool from `depot_tools`:
@@ -77,36 +84,42 @@ The `node_gn` is a workspace directory, which only contains configurations and
7784
caches of the `gclient` tool from `depot_tools`, and the repository is checked
7885
out at `node_gn/node`.
7986

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`.
8391

8492
### 3. Build
8593

8694
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.
8997

9098
The `node-ci` repository provides a script for calling GN:
9199

92100
```bash
101+
cd node # Enter `node_gn/node` which contains a node-ci checkout
93102
./tools/gn-gen.py out/Release
94103
```
95104

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`.
97107

98108
And then you can execute `ninja`:
99109

100110
```bash
101111
ninja -C out/Release node
102112
```
103113

114+
After the build is completed, the compiled Node.js executable can be found in
115+
`out/Release/node`.
116+
104117
## Status of the GN build
105118

106119
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.
109122

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

Comments
 (0)