@@ -28,27 +28,33 @@ Node.js contains following GN build files: |
28 | 28 |
|
29 | 29 | Unlike GYP, the GN tool does not include any built-in rules for compiling a |
30 | 30 | project, which means projects building with GN must provide their own build |
31 | | -configurations for things like how to invoke a C++ compiler. Chromium related |
32 | | -projects like V8 and skia choose to reuse Chromium's build configurations, and |
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. |
| 31 | +configurations for things like how to invoke a C++ compiler. |
| 32 | + |
| 33 | +Chromium related projects like V8 and skia choose to reuse Chromium's build |
| 34 | +configurations, and V8's Node.js integration testing repository |
| 35 | +[`node-ci`][node-ci] can be reused for building Node.js. |
36 | 36 |
|
37 | 37 | ### 1. Install `depot_tools` |
38 | 38 |
|
39 | | -The `depot_tools` is a set of tools used by Chromium related projects for |
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`: |
| 39 | +You'll need to install [`depot_tools`][depot-tools] the toolset |
| 40 | +used for fetching Chromium and its dependencies. |
42 | 41 |
|
43 | 42 | ```bash |
44 | 43 | git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git |
45 | 44 | export PATH=/path/to/depot_tools:$PATH |
46 | 45 | ``` |
47 | 46 |
|
48 | | -You can also follow the [official tutorial of |
49 | | -`depot_tools`](https://commondatastorage.googleapis.com/chrome-infra-docs/flat/depot_tools/docs/html/depot_tools_tutorial.html). |
| 47 | +You can ensure `depot_tools` is correctly added to your PATH by running |
| 48 | +`which gn` and confirming that it returns `/path/to/depot_tools/gn`. |
| 49 | + |
| 50 | +**NOTE:** On Windows you'll also need to set the environment variable |
| 51 | +`DEPOT_TOOLS_WIN_TOOLCHAIN=0`. To do so, open `Control Panel` → `System and |
| 52 | +Security` → `System` → `Advanced system settings` and add a system variable |
| 53 | +`DEPOT_TOOLS_WIN_TOOLCHAIN` with value `0`. This tells `depot_tools` to use |
| 54 | +your locally installed version of Visual Studio (by default, `depot_tools` will |
| 55 | +try to download a Google-internal version that only Googlers have access to). |
50 | 56 |
|
51 | | -### 2. Check out code of Node.js |
| 57 | +### 2. Checkout Node.js Source Code |
52 | 58 |
|
53 | 59 | To check out the latest main branch of Node.js for building, use the `fetch` |
54 | 60 | tool from `depot_tools`: |
@@ -91,9 +97,9 @@ out at `node_gn/node/node`. |
91 | 97 |
|
92 | 98 | ### 3. Build |
93 | 99 |
|
94 | | -GN only supports [`ninja`](https://ninja-build.org) for building, so to build |
95 | | -Node.js with GN, `ninja` build files should be generated first, and then |
96 | | -`ninja` can be invoked to do the building. |
| 100 | +GN only supports [`ninja`](https://ninja-build.org) for building. To build |
| 101 | +Node.js with GN you'll first need to generate `ninja` build files and then invoke |
| 102 | +`ninja` to perform the build. |
97 | 103 |
|
98 | 104 | The `node-ci` repository provides a script for calling GN: |
99 | 105 |
|
@@ -103,9 +109,10 @@ cd node # Enter `node_gn/node` which contains a node-ci checkout |
103 | 109 | ``` |
104 | 110 |
|
105 | 111 | which writes `ninja` build files into the `out/Release` directory under |
106 | | -`node_gn/node`. |
| 112 | +`node_gn/node`. To see all possible configurable options, run |
| 113 | +`tools/gn-gen.py --help`. |
107 | 114 |
|
108 | | -And then you can execute `ninja`: |
| 115 | +When `gn-gen.py` has executed successfully, you can then execute `ninja`: |
109 | 116 |
|
110 | 117 | ```bash |
111 | 118 | ninja -C out/Release node |
@@ -116,10 +123,12 @@ After the build is completed, the compiled Node.js executable can be found in |
116 | 123 |
|
117 | 124 | ## Status of the GN build |
118 | 125 |
|
119 | | -Currently the GN build of Node.js is not fully functioning. It builds for macOS |
120 | | -and Linux, while the Windows build is still a work in progress. And some tests |
121 | | -are still failing with the GN build. |
| 126 | +Currently the GN build of Node.js is not fully functioning. Some tests |
| 127 | +are still failing with the GN build, and there may be other small pitfall |
| 128 | +for certain configuration options. |
| 129 | + |
| 130 | +An effort is currently underway to make GN build work without using `depot_tools`, |
| 131 | +which is tracked in [#51689](https://github.com/nodejs/node/issues/51689). |
122 | 132 |
|
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). |
| 133 | +[depot-tools]: https://commondatastorage.googleapis.com/chrome-infra-docs/flat/depot_tools/docs/html/depot_tools_tutorial.html#_setting_up |
| 134 | +[node-ci]: https://chromium.googlesource.com/v8/node-ci |