Skip to content

36 files changed

+1923
-0
lines changed
 

‎BUILD.gn

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
##############################################################################
2+
# #
3+
# DO NOT EDIT THIS FILE! #
4+
# #
5+
##############################################################################
6+
7+
# This file is used by GN for building, which is NOT the build system used for
8+
# building official binaries.
9+
# Please modify the gyp files if you are making changes to build system.
10+
11+
import("unofficial.gni")
12+
13+
node_gn_build("node") {
14+
}

‎deps/ada/BUILD.gn

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
##############################################################################
2+
# #
3+
# DO NOT EDIT THIS FILE! #
4+
# #
5+
##############################################################################
6+
7+
# This file is used by GN for building, which is NOT the build system used for
8+
# building official binaries.
9+
# Please modify the gyp files if you are making changes to build system.
10+
11+
import("unofficial.gni")
12+
13+
ada_gn_build("ada") {
14+
}

‎deps/ada/unofficial.gni

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# Copyright 2023 Microsoft Inc.
2+
# Use of this source code is governed by a BSD-style license that can be
3+
# found in the LICENSE file.
4+
5+
# This file is used by GN for building, which is NOT the build system used for
6+
# building official binaries.
7+
# Please edit the gyp files if you are making changes to build system.
8+
9+
import("../../node.gni")
10+
import("$node_v8_path/gni/v8.gni")
11+
12+
# The actual configurations are put inside a template in unofficial.gni to
13+
# prevent accidental edits from contributors.
14+
template("ada_gn_build") {
15+
config("ada_config") {
16+
include_dirs = [ "." ]
17+
}
18+
19+
gypi_values = exec_script("../../tools/gypi_to_gn.py",
20+
[ rebase_path("ada.gyp") ],
21+
"scope",
22+
[ "ada.gyp" ])
23+
24+
source_set(target_name) {
25+
forward_variables_from(invoker, "*")
26+
public_configs = [ ":ada_config" ]
27+
sources = gypi_values.ada_sources
28+
}
29+
}

‎deps/base64/BUILD.gn

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
##############################################################################
2+
# #
3+
# DO NOT EDIT THIS FILE! #
4+
# #
5+
##############################################################################
6+
7+
# This file is used by GN for building, which is NOT the build system used for
8+
# building official binaries.
9+
# Please modify the gyp files if you are making changes to build system.
10+
11+
import("unofficial.gni")
12+
13+
base64_gn_build("base64") {
14+
}

‎deps/base64/unofficial.gni

+141
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,141 @@
1+
# Copyright (c) 2013-2022 GitHub Inc.
2+
# Copyright 2022 the V8 project authors. All rights reserved.
3+
# Copyright 2023 Microsoft Inc.
4+
# Use of this source code is governed by a BSD-style license that can be
5+
# found in the LICENSE file.
6+
7+
# This file is used by GN for building, which is NOT the build system used for
8+
# building official binaries.
9+
# Please edit the gyp files if you are making changes to build system.
10+
11+
# The actual configurations are put inside a template in unofficial.gni to
12+
# prevent accidental edits from contributors.
13+
template("base64_gn_build") {
14+
config("base64_external_config") {
15+
include_dirs = [ "base64/include" ]
16+
if (!is_component_build) {
17+
defines = [ "BASE64_STATIC_DEFINE" ]
18+
}
19+
}
20+
21+
config("base64_internal_config") {
22+
include_dirs = [ "base64/lib" ]
23+
if (is_component_build) {
24+
defines = [ "BASE64_EXPORTS" ]
25+
} else {
26+
defines = []
27+
}
28+
if (target_cpu == "x86" || target_cpu == "x64") {
29+
defines += [
30+
"HAVE_SSSE3=1",
31+
"HAVE_SSE41=1",
32+
"HAVE_SSE42=1",
33+
"HAVE_AVX=1",
34+
"HAVE_AVX2=1",
35+
]
36+
}
37+
if (target_cpu == "arm") {
38+
defines += [ "HAVE_NEON32=1" ]
39+
}
40+
if (target_cpu == "arm64") {
41+
defines += [ "HAVE_NEON64=1" ]
42+
}
43+
if (is_clang || !is_win) {
44+
cflags_c = [
45+
"-Wno-implicit-fallthrough",
46+
"-Wno-shadow",
47+
"-Wno-unused-but-set-variable",
48+
]
49+
}
50+
}
51+
52+
gypi_values = exec_script("../../tools/gypi_to_gn.py",
53+
[ rebase_path("base64.gyp") ],
54+
"scope",
55+
[ "base64.gyp" ])
56+
57+
component(target_name) {
58+
forward_variables_from(invoker, "*")
59+
configs += [ ":base64_internal_config" ]
60+
public_configs = [ ":base64_external_config" ]
61+
sources = gypi_values.base64_sources_common
62+
deps = [
63+
":base64_ssse3",
64+
":base64_sse41",
65+
":base64_sse42",
66+
":base64_avx",
67+
":base64_avx2",
68+
":base64_neon32",
69+
":base64_neon64",
70+
]
71+
}
72+
73+
source_set("base64_ssse3") {
74+
configs += [ ":base64_internal_config" ]
75+
sources = [ "base64/lib/arch/ssse3/codec.c" ]
76+
if (target_cpu == "x86" || target_cpu == "x64") {
77+
if (is_clang || !is_win) {
78+
cflags_c = [ "-mssse3" ]
79+
}
80+
}
81+
}
82+
83+
source_set("base64_sse41") {
84+
configs += [ ":base64_internal_config" ]
85+
sources = [ "base64/lib/arch/sse41/codec.c" ]
86+
if (target_cpu == "x86" || target_cpu == "x64") {
87+
if (is_clang || !is_win) {
88+
cflags_c = [ "-msse4.1" ]
89+
}
90+
}
91+
}
92+
93+
source_set("base64_sse42") {
94+
configs += [ ":base64_internal_config" ]
95+
sources = [ "base64/lib/arch/sse42/codec.c" ]
96+
if (target_cpu == "x86" || target_cpu == "x64") {
97+
if (is_clang || !is_win) {
98+
cflags_c = [ "-msse4.2" ]
99+
}
100+
}
101+
}
102+
103+
source_set("base64_avx") {
104+
configs += [ ":base64_internal_config" ]
105+
sources = [ "base64/lib/arch/avx/codec.c" ]
106+
if (target_cpu == "x86" || target_cpu == "x64") {
107+
if (is_clang || !is_win) {
108+
cflags_c = [ "-mavx" ]
109+
} else if (is_win) {
110+
cflags_c = [ "/arch:AVX" ]
111+
}
112+
}
113+
}
114+
source_set("base64_avx2") {
115+
configs += [ ":base64_internal_config" ]
116+
sources = [ "base64/lib/arch/avx2/codec.c" ]
117+
if (target_cpu == "x86" || target_cpu == "x64") {
118+
if (is_clang || !is_win) {
119+
cflags_c = [ "-mavx2" ]
120+
} else if (is_win) {
121+
cflags_c = [ "/arch:AVX2" ]
122+
}
123+
}
124+
}
125+
126+
source_set("base64_neon32") {
127+
configs += [ ":base64_internal_config" ]
128+
sources = [ "base64/lib/arch/neon32/codec.c" ]
129+
if (target_cpu == "arm") {
130+
if (is_clang || !is_win) {
131+
cflags_c = [ "-mfpu=neon" ]
132+
}
133+
}
134+
}
135+
136+
source_set("base64_neon64") {
137+
configs += [ ":base64_internal_config" ]
138+
sources = [ "base64/lib/arch/neon64/codec.c" ]
139+
# NEON is required in arm64, so no -mfpu flag is needed
140+
}
141+
}

‎deps/brotli/BUILD.gn

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
##############################################################################
2+
# #
3+
# DO NOT EDIT THIS FILE! #
4+
# #
5+
##############################################################################
6+
7+
# This file is used by GN for building, which is NOT the build system used for
8+
# building official binaries.
9+
# Please modify the gyp files if you are making changes to build system.
10+
11+
import("unofficial.gni")
12+
13+
brotli_gn_build("brotli") {
14+
}

‎deps/brotli/unofficial.gni

+45
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# Copyright 2014 The Chromium Authors. All rights reserved.
2+
# Copyright 2019 the V8 project authors. All rights reserved.
3+
# Copyright 2023 Microsoft Inc.
4+
# Use of this source code is governed by a BSD-style license that can be
5+
# found in the LICENSE file.
6+
7+
# This file is used by GN for building, which is NOT the build system used for
8+
# building official binaries.
9+
# Please edit the gyp files if you are making changes to build system.
10+
11+
# The actual configurations are put inside a template in unofficial.gni to
12+
# prevent accidental edits from contributors.
13+
template("brotli_gn_build") {
14+
config("brotli_config") {
15+
include_dirs = [ "c/include" ]
16+
}
17+
18+
gypi_values = exec_script("../../tools/gypi_to_gn.py",
19+
[ rebase_path("brotli.gyp") ],
20+
"scope",
21+
[ "brotli.gyp" ])
22+
23+
source_set(target_name) {
24+
forward_variables_from(invoker, "*")
25+
public_configs = [ ":brotli_config" ]
26+
sources = gypi_values.brotli_sources
27+
if (is_linux) {
28+
defines = [ "OS_LINUX" ]
29+
} else if (is_mac) {
30+
defines = [ "OS_MACOSX" ]
31+
} else if (target_os == "freebsd") {
32+
defines = [ "OS_FREEBSD" ]
33+
}
34+
if (!is_win) {
35+
libs = [ "m" ]
36+
}
37+
if (is_clang || !is_win) {
38+
cflags_c = [
39+
"-Wno-implicit-fallthrough",
40+
"-Wno-unreachable-code",
41+
"-Wno-unreachable-code-return",
42+
]
43+
}
44+
}
45+
}

‎deps/cares/BUILD.gn

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
##############################################################################
2+
# #
3+
# DO NOT EDIT THIS FILE! #
4+
# #
5+
##############################################################################
6+
7+
# This file is used by GN for building, which is NOT the build system used for
8+
# building official binaries.
9+
# Please modify the gyp files if you are making changes to build system.
10+
11+
import("unofficial.gni")
12+
13+
cares_gn_build("cares") {
14+
}

‎deps/cares/unofficial.gni

+81
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
# Copyright (c) 2013-2019 GitHub Inc.
2+
# Copyright 2019 the V8 project authors. All rights reserved.
3+
# Copyright 2023 Microsoft Inc.
4+
# Use of this source code is governed by a BSD-style license that can be
5+
# found in the LICENSE file.
6+
7+
# This file is used by GN for building, which is NOT the build system used for
8+
# building official binaries.
9+
# Please edit the gyp files if you are making changes to build system.
10+
11+
# The actual configurations are put inside a template in unofficial.gni to
12+
# prevent accidental edits from contributors.
13+
template("cares_gn_build") {
14+
config("cares_config") {
15+
include_dirs = [ "include" ]
16+
if (!is_component_build) {
17+
defines = [ "CARES_STATICLIB" ]
18+
}
19+
}
20+
21+
gypi_values = exec_script("../../tools/gypi_to_gn.py",
22+
[ rebase_path("cares.gyp") ],
23+
"scope",
24+
[ "cares.gyp" ])
25+
26+
component(target_name) {
27+
forward_variables_from(invoker, "*")
28+
public_configs = [ ":cares_config" ]
29+
if (is_component_build) {
30+
defines = [ "CARES_BUILDING_LIBRARY" ]
31+
} else {
32+
defines = []
33+
}
34+
if (is_win) {
35+
defines += [ "CARES_PULL_WS2TCPIP_H=1" ]
36+
}
37+
if (is_posix) {
38+
defines += [
39+
"_DARWIN_USE_64_BIT_INODE=1",
40+
"_LARGEFILE_SOURCE",
41+
"_FILE_OFFSET_BITS=64",
42+
"_GNU_SOURCE",
43+
"HAVE_CONFIG_H",
44+
]
45+
}
46+
47+
include_dirs = [ "src/lib" ]
48+
if (is_win) {
49+
include_dirs += [ "config/win32" ]
50+
} else if (is_linux) {
51+
include_dirs += [ "config/linux" ]
52+
} else if (is_mac) {
53+
include_dirs += [ "config/darwin" ]
54+
}
55+
56+
if (is_win) {
57+
libs = [
58+
"ws2_32.lib",
59+
"iphlpapi.lib",
60+
]
61+
}
62+
63+
sources = gypi_values.cares_sources_common
64+
if (is_win) {
65+
sources += gypi_values.cares_sources_win
66+
}
67+
if (is_linux) {
68+
sources += [ "config/linux/ares_config.h" ]
69+
}
70+
if (is_mac) {
71+
sources += [ "config/darwin/ares_config.h" ]
72+
}
73+
74+
if (is_clang || !is_win) {
75+
cflags_c = [
76+
"-Wno-implicit-fallthrough",
77+
"-Wno-unreachable-code",
78+
]
79+
}
80+
}
81+
}

‎deps/googletest/BUILD.gn

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
##############################################################################
2+
# #
3+
# DO NOT EDIT THIS FILE! #
4+
# #
5+
##############################################################################
6+
7+
# This file is used by GN for building, which is NOT the build system used for
8+
# building official binaries.
9+
# Please modify the gyp files if you are making changes to build system.
10+
11+
import("unofficial.gni")
12+
13+
googletest_gn_build("googletest") {
14+
}

‎deps/googletest/unofficial.gni

+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# Copyright 2021 the V8 project authors. All rights reserved.
2+
# Use of this source code is governed by a BSD-style license that can be
3+
# found in the LICENSE file.
4+
5+
# This file is used by GN for building, which is NOT the build system used for
6+
# building official binaries.
7+
# Please edit the gyp files if you are making changes to build system.
8+
9+
# The actual configurations are put inside a template in unofficial.gni to
10+
# prevent accidental edits from contributors.
11+
template("googletest_gn_build") {
12+
config("googletest_config") {
13+
include_dirs = [ "include" ]
14+
}
15+
16+
gypi_values = exec_script("../../tools/gypi_to_gn.py",
17+
[ rebase_path("googletest.gyp") ],
18+
"scope",
19+
[ "googletest.gyp" ])
20+
21+
source_set(target_name) {
22+
forward_variables_from(invoker, "*")
23+
testonly = true
24+
include_dirs = [
25+
"include",
26+
".",
27+
]
28+
defines = [
29+
"GTEST_HAS_POSIX_RE=0",
30+
"GTEST_LANG_CXX11=1",
31+
]
32+
sources = gypi_values.googletest_sources
33+
}
34+
35+
source_set("gtest_main") {
36+
testonly = true
37+
deps = [ ":googletest" ]
38+
sources = [ "src/gtest_main.cc" ]
39+
public_configs = [ ":googletest_config" ]
40+
}
41+
}

‎deps/histogram/BUILD.gn

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
##############################################################################
2+
# #
3+
# DO NOT EDIT THIS FILE! #
4+
# #
5+
##############################################################################
6+
7+
# This file is used by GN for building, which is NOT the build system used for
8+
# building official binaries.
9+
# Please modify the gyp files if you are making changes to build system.
10+
11+
import("unofficial.gni")
12+
13+
histogram_gn_build("histogram") {
14+
}

‎deps/histogram/unofficial.gni

+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# Copyright (c) 2013-2019 GitHub Inc.
2+
# Copyright 2019 the V8 project authors. All rights reserved.
3+
# Copyright 2023 Microsoft Inc.
4+
# Use of this source code is governed by a BSD-style license that can be
5+
# found in the LICENSE file.
6+
7+
# This file is used by GN for building, which is NOT the build system used for
8+
# building official binaries.
9+
# Please edit the gyp files if you are making changes to build system.
10+
11+
# The actual configurations are put inside a template in unofficial.gni to
12+
# prevent accidental edits from contributors.
13+
template("histogram_gn_build") {
14+
config("histogram_config") {
15+
include_dirs = [ "include" ]
16+
}
17+
18+
gypi_values = exec_script("../../tools/gypi_to_gn.py",
19+
[ rebase_path("histogram.gyp") ],
20+
"scope",
21+
[ "histogram.gyp" ])
22+
23+
source_set(target_name) {
24+
forward_variables_from(invoker, "*")
25+
public_configs = [ ":histogram_config" ]
26+
sources = gypi_values.histogram_sources
27+
if (is_clang || !is_win) {
28+
cflags_c = [
29+
"-Wno-atomic-alignment",
30+
"-Wno-incompatible-pointer-types",
31+
"-Wno-unused-function",
32+
]
33+
}
34+
if (is_linux) {
35+
libs = [ "atomic" ]
36+
}
37+
}
38+
}

‎deps/llhttp/BUILD.gn

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
##############################################################################
2+
# #
3+
# DO NOT EDIT THIS FILE! #
4+
# #
5+
##############################################################################
6+
7+
# This file is used by GN for building, which is NOT the build system used for
8+
# building official binaries.
9+
# Please modify the gyp files if you are making changes to build system.
10+
11+
import("unofficial.gni")
12+
13+
llhttp_gn_build("llhttp") {
14+
}

‎deps/llhttp/unofficial.gni

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# Copyright (c) 2013-2019 GitHub Inc.
2+
# Copyright 2019 the V8 project authors. All rights reserved.
3+
# Use of this source code is governed by a BSD-style license that can be
4+
# found in the LICENSE file.
5+
6+
# This file is used by GN for building, which is NOT the build system used for
7+
# building official binaries.
8+
# Please edit the gyp files if you are making changes to build system.
9+
10+
# The actual configurations are put inside a template in unofficial.gni to
11+
# prevent accidental edits from contributors.
12+
template("llhttp_gn_build") {
13+
config("llhttp_config") {
14+
include_dirs = [ "include" ]
15+
}
16+
17+
gypi_values = exec_script("../../tools/gypi_to_gn.py",
18+
[ rebase_path("llhttp.gyp") ],
19+
"scope",
20+
[ "llhttp.gyp" ])
21+
22+
source_set(target_name) {
23+
forward_variables_from(invoker, "*")
24+
public_configs = [ ":llhttp_config" ]
25+
include_dirs = [ "include" ]
26+
sources = gypi_values.llhttp_sources
27+
if (is_clang || !is_win) {
28+
cflags_c = [
29+
"-Wno-implicit-fallthrough",
30+
"-Wno-unreachable-code",
31+
]
32+
}
33+
}
34+
}

‎deps/nghttp2/BUILD.gn

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
##############################################################################
2+
# #
3+
# DO NOT EDIT THIS FILE! #
4+
# #
5+
##############################################################################
6+
7+
# This file is used by GN for building, which is NOT the build system used for
8+
# building official binaries.
9+
# Please modify the gyp files if you are making changes to build system.
10+
11+
import("unofficial.gni")
12+
13+
nghttp2_gn_build("nghttp2") {
14+
}

‎deps/nghttp2/unofficial.gni

+45
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# Copyright (c) 2013-2019 GitHub Inc.
2+
# Copyright 2019 the V8 project authors. All rights reserved.
3+
# Use of this source code is governed by a BSD-style license that can be
4+
# found in the LICENSE file.
5+
6+
# This file is used by GN for building, which is NOT the build system used for
7+
# building official binaries.
8+
# Please edit the gyp files if you are making changes to build system.
9+
10+
# The actual configurations are put inside a template in unofficial.gni to
11+
# prevent accidental edits from contributors.
12+
template("nghttp2_gn_build") {
13+
config("nghttp2_config") {
14+
include_dirs = [ "lib/includes" ]
15+
if (!is_component_build) {
16+
defines = [ "NGHTTP2_STATICLIB" ]
17+
}
18+
}
19+
20+
gypi_values = exec_script("../../tools/gypi_to_gn.py",
21+
[ rebase_path("nghttp2.gyp") ],
22+
"scope",
23+
[ "nghttp2.gyp" ])
24+
25+
component(target_name) {
26+
forward_variables_from(invoker, "*")
27+
28+
public_configs = [ ":nghttp2_config" ]
29+
defines = [
30+
"_U_",
31+
"HAVE_CONFIG_H"
32+
]
33+
if (is_component_build) {
34+
defines += [ "BUILDING_NGHTTP2" ]
35+
}
36+
37+
sources = gypi_values.nghttp2_sources
38+
39+
if (is_clang || !is_win) {
40+
cflags_c = [
41+
"-Wno-implicit-fallthrough",
42+
]
43+
}
44+
}
45+
}

‎deps/ngtcp2/BUILD.gn

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
##############################################################################
2+
# #
3+
# DO NOT EDIT THIS FILE! #
4+
# #
5+
##############################################################################
6+
7+
# This file is used by GN for building, which is NOT the build system used for
8+
# building official binaries.
9+
# Please modify the gyp files if you are making changes to build system.
10+
11+
import("unofficial.gni")
12+
13+
ngtcp2_gn_build("ngtcp2") {
14+
}

‎deps/ngtcp2/unofficial.gni

+74
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
# Copyright (c) 2013-2021 GitHub Inc.
2+
# Copyright 2021 the V8 project authors. All rights reserved.
3+
# Use of this source code is governed by a BSD-style license that can be
4+
# found in the LICENSE file.
5+
6+
# This file is used by GN for building, which is NOT the build system used for
7+
# building official binaries.
8+
# Please edit the gyp files if you are making changes to build system.
9+
10+
import("//node/node.gni")
11+
12+
# The actual configurations are put inside a template in unofficial.gni to
13+
# prevent accidental edits from contributors.
14+
template("ngtcp2_gn_build") {
15+
config("ngtcp2_config") {
16+
include_dirs = [
17+
"nghttp3/lib/",
18+
"nghttp3/lib/includes/",
19+
"ngtcp2/crypto/includes/",
20+
"ngtcp2/lib/includes/",
21+
]
22+
defines = [
23+
"NGTCP2_STATICLIB",
24+
"NGHTTP3_STATICLIB",
25+
]
26+
}
27+
28+
gypi_values = exec_script("../../tools/gypi_to_gn.py",
29+
[ rebase_path("ngtcp2.gyp") ],
30+
"scope",
31+
[ "ngtcp2.gyp" ])
32+
33+
# FIXME(zcbenz): Some APIs of ngtcp2 are not marked as export, so can not turn
34+
# into component. This should be fixed in upstream ngtcp2
35+
static_library(target_name) {
36+
forward_variables_from(invoker, "*")
37+
public_configs = [ ":ngtcp2_config" ]
38+
39+
defines = [ "_U_" ]
40+
if (is_win) {
41+
defines += [
42+
"WIN32",
43+
"_WINDOWS",
44+
"HAVE_CONFIG_H",
45+
]
46+
}
47+
if (is_linux) {
48+
defines += [
49+
"HAVE_ARPA_INET_H",
50+
"HAVE_NETINET_IN_H",
51+
]
52+
}
53+
54+
include_dirs = [
55+
".",
56+
"ngtcp2/lib/",
57+
"ngtcp2/crypto/",
58+
"nghttp3/lib/"
59+
]
60+
61+
sources = gypi_values.nghttp3_sources + gypi_values.ngtcp2_sources
62+
if (node_use_openssl) {
63+
sources += gypi_values.ngtcp2_sources_openssl
64+
deps = [ "../openssl" ]
65+
}
66+
67+
if (is_clang || !is_win) {
68+
cflags_c = [
69+
"-Wno-extra-semi",
70+
"-Wno-implicit-fallthrough",
71+
]
72+
}
73+
}
74+
}

‎deps/openssl/BUILD.gn

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
##############################################################################
2+
# #
3+
# DO NOT EDIT THIS FILE! #
4+
# #
5+
##############################################################################
6+
7+
# This file is used by GN for building, which is NOT the build system used for
8+
# building official binaries.
9+
# Please modify the gyp files if you are making changes to build system.
10+
11+
import("unofficial.gni")
12+
13+
openssl_gn_build("openssl") {
14+
}

‎deps/openssl/unofficial.gni

+151
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,151 @@
1+
# Copyright 2019 the V8 project authors. All rights reserved.
2+
# Copyright 2023 Microsoft Inc.
3+
# Use of this source code is governed by a BSD-style license that can be
4+
# found in the LICENSE file.
5+
6+
# This file is used by GN for building, which is NOT the build system used for
7+
# building official binaries.
8+
# Please edit the gyp files if you are making changes to build system.
9+
10+
declare_args() {
11+
# Do not build optimized assembly for OpenSSL
12+
# FIXME(zcbenz): asm code does not compile with clang.
13+
openssl_no_asm = true
14+
}
15+
16+
# The actual configurations are put inside a template in unofficial.gni to
17+
# prevent accidental edits from contributors.
18+
template("openssl_gn_build") {
19+
config("openssl_external_config") {
20+
include_dirs = [
21+
"openssl/crypto/include",
22+
"openssl/include",
23+
]
24+
}
25+
26+
config("openssl_internal_config") {
27+
gypi_values = exec_script("../../tools/gypi_to_gn.py",
28+
[ rebase_path("openssl.gypi") ],
29+
"scope",
30+
[ "openssl.gypi" ])
31+
32+
defines = [
33+
"MODULESDIR=\"deps/openssl/lib/openssl-modules\"",
34+
"OPENSSL_API_COMPAT=0x10100001L",
35+
"STATIC_LEGACY",
36+
] + gypi_values.openssl_default_defines_all
37+
if (is_win) {
38+
defines += [
39+
## default of Win. See INSTALL in openssl repo.
40+
"OPENSSLDIR=\"C:\\\Program\ Files\\\Common\ Files\\\SSL\"",
41+
"ENGINESDIR=\"NUL\"",
42+
"OPENSSL_SYS_WIN32", "WIN32_LEAN_AND_MEAN", "L_ENDIAN",
43+
"_CRT_SECURE_NO_DEPRECATE", "UNICODE", "_UNICODE",
44+
]
45+
} else if (is_mac) {
46+
defines += [
47+
"OPENSSLDIR=\"/System/Library/OpenSSL/\"",
48+
"ENGINESDIR=\"/dev/null\"",
49+
]
50+
} else {
51+
defines += [
52+
"OPENSSLDIR=\"/etc/ssl\"",
53+
"ENGINESDIR=\"/dev/null\"",
54+
"TERMIOS",
55+
]
56+
}
57+
58+
if (is_posix) {
59+
asmflags = [ "-fPIC" ]
60+
cflags = [ "-fPIC" ]
61+
ldflags = [ "-fPIC" ]
62+
}
63+
if (is_clang || !is_win) {
64+
cflags_c = [
65+
"-Wno-atomic-alignment",
66+
"-Wno-constant-conversion",
67+
"-Wno-implicit-fallthrough",
68+
"-Wno-implicit-function-declaration",
69+
"-Wno-sign-compare",
70+
"-Wno-unknown-escape-sequence",
71+
"-Wno-unreachable-code",
72+
"-Wno-unreachable-code-break",
73+
"-Wno-unreachable-code-return",
74+
"-Wno-unused-function",
75+
]
76+
}
77+
if (is_win) {
78+
libs = [ "crypt32.lib" ]
79+
} else if (is_linux) {
80+
libs = [ "atomic" ]
81+
}
82+
83+
common_gypi_values = exec_script("../../tools/gypi_to_gn.py",
84+
[ rebase_path("openssl_common.gypi") ],
85+
"scope",
86+
[ "openssl_common.gypi" ])
87+
include_dirs = common_gypi_values.include_dirs
88+
}
89+
90+
static_library(target_name) {
91+
forward_variables_from(invoker, "*")
92+
93+
configs += [ ":openssl_internal_config" ]
94+
public_configs = [ ":openssl_external_config" ]
95+
96+
config_path_name = ""
97+
if (is_win) {
98+
if (target_cpu == "x86") {
99+
config_path_name = "VC-WIN32"
100+
} else if (target_cpu == "x64") {
101+
config_path_name = "VC-WIN64A"
102+
} else if (target_cpu == "arm64") {
103+
config_path_name = "VC-WIN64-ARM"
104+
}
105+
} else if (is_linux) {
106+
if (target_cpu == "x86") {
107+
config_path_name = "linux-elf"
108+
} else if (target_cpu == "x64") {
109+
config_path_name = "linux-x86_64"
110+
} else if (target_cpu == "arm") {
111+
config_path_name = "linux-armv4"
112+
} else if (target_cpu == "arm64") {
113+
config_path_name = "linux-aarch64"
114+
}
115+
} else if (is_apple) {
116+
if (target_cpu == "x86") {
117+
config_path_name = "darwin-i386-cc"
118+
} else if (target_cpu == "x64") {
119+
config_path_name = "darwin64-x86_64-cc"
120+
} else if (target_cpu == "arm64") {
121+
config_path_name = "darwin64-arm64-cc"
122+
}
123+
}
124+
assert(config_path_name != "", "Unsupported platform")
125+
126+
# GN variables can not have - in name.
127+
config_name = string_replace(config_path_name, "-", "_")
128+
129+
if (openssl_no_asm) {
130+
asm_name = "no-asm"
131+
} else {
132+
# TODO(zcbenz): Check gas_version and nasm_version.
133+
asm_name = "asm_avx2"
134+
}
135+
if (is_win && target_cpu == "arm64") {
136+
asm_name = "no-asm"
137+
}
138+
config_path = "config/archs/" + config_path_name + "/" + asm_name
139+
140+
gypi_values = exec_script("../../tools/gypi_to_gn.py",
141+
[ rebase_path(config_path + "/openssl.gypi"), ],
142+
"scope",
143+
[ config_path + "/openssl.gypi" ])
144+
145+
include_dirs = rebase_path(gypi_values.include_dirs, ".", config_path)
146+
defines = gypi_values["openssl_defines_" + config_name]
147+
sources = filter_exclude(gypi_values.openssl_sources +
148+
gypi_values["openssl_sources_" + config_name],
149+
[ "*.ld" ])
150+
}
151+
}

‎deps/postject/BUILD.gn

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
##############################################################################
2+
# #
3+
# DO NOT EDIT THIS FILE! #
4+
# #
5+
##############################################################################
6+
7+
# This file is used by GN for building, which is NOT the build system used for
8+
# building official binaries.
9+
# Please modify the gyp files if you are making changes to build system.
10+
11+
import("unofficial.gni")
12+
13+
postject_gn_build("postject") {
14+
}

‎deps/postject/unofficial.gni

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Copyright 2023 Microsoft Inc.
2+
# Use of this source code is governed by a BSD-style license that can be
3+
# found in the LICENSE file.
4+
5+
# This file is used by GN for building, which is NOT the build system used for
6+
# building official binaries.
7+
# Please edit the gyp files if you are making changes to build system.
8+
9+
# The actual configurations are put inside a template in unofficial.gni to
10+
# prevent accidental edits from contributors.
11+
template("postject_gn_build") {
12+
config("postject_config") {
13+
include_dirs = [ "." ]
14+
}
15+
16+
source_set(target_name) {
17+
forward_variables_from(invoker, "*")
18+
public_configs = [ ":postject_config" ]
19+
sources = [ "postject-api.h" ]
20+
}
21+
}

‎deps/simdutf/BUILD.gn

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
##############################################################################
2+
# #
3+
# DO NOT EDIT THIS FILE! #
4+
# #
5+
##############################################################################
6+
7+
# This file is used by GN for building, which is NOT the build system used for
8+
# building official binaries.
9+
# Please modify the gyp files if you are making changes to build system.
10+
11+
import("unofficial.gni")
12+
13+
simdutf_gn_build("simdutf") {
14+
}

‎deps/simdutf/unofficial.gni

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# Copyright (c) 2013-2019 GitHub Inc.
2+
# Copyright 2019 the V8 project authors. All rights reserved.
3+
# Use of this source code is governed by a BSD-style license that can be
4+
# found in the LICENSE file.
5+
6+
# This file is used by GN for building, which is NOT the build system used for
7+
# building official binaries.
8+
# Please edit the gyp files if you are making changes to build system.
9+
10+
# The actual configurations are put inside a template in unofficial.gni to
11+
# prevent accidental edits from contributors.
12+
template("simdutf_gn_build") {
13+
config("simdutf_config") {
14+
include_dirs = [ "." ]
15+
}
16+
17+
gypi_values = exec_script("../../tools/gypi_to_gn.py",
18+
[ rebase_path("simdutf.gyp") ],
19+
"scope",
20+
[ "simdutf.gyp" ])
21+
22+
source_set(target_name) {
23+
forward_variables_from(invoker, "*")
24+
public_configs = [ ":simdutf_config" ]
25+
sources = gypi_values.simdutf_sources
26+
if (is_clang || !is_win) {
27+
cflags_cc = [
28+
"-Wno-#pragma-messages",
29+
"-Wno-ambiguous-reversed-operator",
30+
"-Wno-unreachable-code-break",
31+
"-Wno-unused-const-variable",
32+
"-Wno-unused-function",
33+
"-Wno-c++98-compat-extra-semi",
34+
]
35+
}
36+
}
37+
}

‎deps/uv/BUILD.gn

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
##############################################################################
2+
# #
3+
# DO NOT EDIT THIS FILE! #
4+
# #
5+
##############################################################################
6+
7+
# This file is used by GN for building, which is NOT the build system used for
8+
# building official binaries.
9+
# Please modify the gyp files if you are making changes to build system.
10+
11+
import("unofficial.gni")
12+
13+
uv_gn_build("uv") {
14+
}

‎deps/uv/unofficial.gni

+110
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
# Copyright (c) 2013-2019 GitHub Inc.
2+
# Copyright 2019 the V8 project authors. All rights reserved.
3+
# Copyright 2023 Microsoft Inc.
4+
# Use of this source code is governed by a BSD-style license that can be
5+
# found in the LICENSE file.
6+
7+
# This file is used by GN for building, which is NOT the build system used for
8+
# building official binaries.
9+
# Please edit the gyp files if you are making changes to build system.
10+
11+
# The actual configurations are put inside a template in unofficial.gni to
12+
# prevent accidental edits from contributors.
13+
template("uv_gn_build") {
14+
config("uv_external_config") {
15+
include_dirs = [ "include" ]
16+
}
17+
18+
config("uv_internal_config") {
19+
include_dirs = [
20+
"include",
21+
"src",
22+
]
23+
24+
defines = [ "BUILDING_UV_SHARED" ] # always export symbols
25+
if (is_posix) {
26+
defines += [
27+
"_LARGEFILE_SOURCE",
28+
"_FILE_OFFSET_BITS=64",
29+
]
30+
}
31+
if (is_linux) {
32+
defines += [
33+
"_POSIX_C_SOURCE=200112",
34+
"_GNU_SOURCE",
35+
]
36+
}
37+
if (is_apple) {
38+
defines += [
39+
"_DARWIN_USE_64_BIT_INODE=1",
40+
"_DARWIN_UNLIMITED_SELECT=1",
41+
]
42+
}
43+
if (is_clang || !is_win) {
44+
cflags_c = [
45+
"-Wno-deprecated-declarations",
46+
"-Wno-extra-semi",
47+
"-Wno-implicit-fallthrough",
48+
"-Wno-missing-braces",
49+
"-Wno-string-conversion",
50+
"-Wno-shadow",
51+
"-Wno-unreachable-code",
52+
"-Wno-unreachable-code-return",
53+
"-Wno-unused-but-set-variable",
54+
"-Wno-unused-function",
55+
"-Wno-unused-result",
56+
"-Wno-unused-variable",
57+
]
58+
}
59+
}
60+
61+
gypi_values = exec_script("../../tools/gypi_to_gn.py",
62+
[ rebase_path("uv.gyp") ],
63+
"scope",
64+
[ "uv.gyp" ])
65+
66+
component(target_name) {
67+
forward_variables_from(invoker, "*")
68+
69+
configs += [ ":uv_internal_config" ]
70+
public_configs = [ ":uv_external_config" ]
71+
72+
if (is_win) {
73+
libs = [
74+
"advapi32.lib",
75+
"iphlpapi.lib",
76+
"psapi.lib",
77+
"shell32.lib",
78+
"user32.lib",
79+
"userenv.lib",
80+
"ws2_32.lib",
81+
]
82+
}
83+
if (is_posix) {
84+
libs = [ "m" ]
85+
ldflags = [ "-pthread" ]
86+
}
87+
if (is_linux) {
88+
libs += [
89+
"dl",
90+
"rt",
91+
]
92+
}
93+
94+
sources = gypi_values.uv_sources_common
95+
if (is_win) {
96+
sources += gypi_values.uv_sources_win
97+
}
98+
if (is_posix) {
99+
sources += gypi_values.uv_sources_posix +
100+
[ "src/unix/proctitle.c" ]
101+
}
102+
if (is_linux) {
103+
sources += gypi_values.uv_sources_linux
104+
}
105+
if (is_apple) {
106+
sources += gypi_values.uv_sources_apple +
107+
gypi_values.uv_sources_bsd_common
108+
}
109+
}
110+
}

‎deps/uvwasi/BUILD.gn

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
##############################################################################
2+
# #
3+
# DO NOT EDIT THIS FILE! #
4+
# #
5+
##############################################################################
6+
7+
# This file is used by GN for building, which is NOT the build system used for
8+
# building official binaries.
9+
# Please modify the gyp files if you are making changes to build system.
10+
11+
import("unofficial.gni")
12+
13+
uvwasi_gn_build("uvwasi") {
14+
}

‎deps/uvwasi/unofficial.gni

+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# Copyright (c) 2013-2019 GitHub Inc.
2+
# Copyright 2019 the V8 project authors. All rights reserved.
3+
# Copyright 2023 Microsoft Inc.
4+
# Use of this source code is governed by a BSD-style license that can be
5+
# found in the LICENSE file.
6+
7+
# This file is used by GN for building, which is NOT the build system used for
8+
# building official binaries.
9+
# Please edit the gyp files if you are making changes to build system.
10+
11+
# The actual configurations are put inside a template in unofficial.gni to
12+
# prevent accidental edits from contributors.
13+
template("uvwasi_gn_build") {
14+
config("uvwasi_config") {
15+
include_dirs = [ "include" ]
16+
}
17+
18+
gypi_values = exec_script("../../tools/gypi_to_gn.py",
19+
[ rebase_path("uvwasi.gyp") ],
20+
"scope",
21+
[ "uvwasi.gyp" ])
22+
23+
source_set(target_name) {
24+
forward_variables_from(invoker, "*")
25+
26+
public_configs = [ ":uvwasi_config" ]
27+
sources = gypi_values.uvwasi_sources
28+
include_dirs = [ "src" ]
29+
deps = [ "../uv" ]
30+
31+
if (is_clang || !is_win) {
32+
cflags_c = [
33+
"-Wno-extra-semi",
34+
"-Wno-shadow",
35+
]
36+
}
37+
}
38+
}

‎node.gni

+67
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
# Copyright 2019 the V8 project authors. All rights reserved.
2+
# Copyright 2023 Microsoft Inc.
3+
# Use of this source code is governed by a BSD-style license that can be
4+
# found in the LICENSE file.
5+
6+
# This file is used by GN for building, which is NOT the build system used for
7+
# building official binaries.
8+
# Please take a look at node.gyp if you are making changes to build system.
9+
10+
# Embedder options.
11+
declare_args() {
12+
# The location of Node.js in source code tree.
13+
node_path = "//node"
14+
15+
# The location of V8, use the one from node's deps by default.
16+
node_v8_path = "$node_path/deps/v8"
17+
18+
# The NODE_MODULE_VERSION defined in node_version.h.
19+
node_module_version = exec_script("$node_path/tools/getmoduleversion.py", [], "value")
20+
21+
# Support for external shareable builtins.
22+
# TODO(zcbenz): This is currently copied from configure.py, we should share
23+
# the list between configure.py and GN configurations.
24+
node_builtin_shareable_builtins = [
25+
"deps/cjs-module-lexer/lexer.js",
26+
"deps/cjs-module-lexer/dist/lexer.js",
27+
"deps/undici/undici.js",
28+
]
29+
}
30+
31+
# Equivalent of gyp file's configurations.
32+
declare_args() {
33+
# Enable the V8 inspector protocol for use with node.
34+
node_enable_inspector = true
35+
36+
# Build node with SSL support.
37+
# The variable is called "openssl" for parity with node's GYP build.
38+
node_use_openssl = true
39+
40+
# Use the specified path to system CA (PEM format) in addition to
41+
# the BoringSSL supplied CA store or compiled-in Mozilla CA copy.
42+
node_openssl_system_ca_path = ""
43+
44+
# Initialize v8 platform during node.js startup.
45+
node_use_v8_platform = true
46+
47+
# Custom build tag.
48+
node_tag = ""
49+
50+
# V8 options to pass, see `node --v8-options` for examples.
51+
node_v8_options = ""
52+
53+
# Provide a custom URL prefix for the `process.release` properties
54+
# `sourceUrl` and `headersUrl`. When compiling a release build, this will
55+
# default to https://nodejs.org/download/release/').
56+
node_release_urlbase = ""
57+
58+
# Use code cache to speed up startup. Disabled for cross compilation.
59+
node_use_node_code_cache = host_os == target_os && host_cpu == target_cpu
60+
61+
# Use snapshot to speed up startup.
62+
# TODO(zcbenz): node_mksnapshot is not ready for cross-os compilation.
63+
node_use_node_snapshot = host_os == target_os
64+
}
65+
66+
assert(!node_enable_inspector || node_use_openssl,
67+
"node_enable_inspector requires node_use_openssl")

‎src/inspector/BUILD.gn

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
##############################################################################
2+
# #
3+
# DO NOT EDIT THIS FILE! #
4+
# #
5+
##############################################################################
6+
7+
# This file is used by GN for building, which is NOT the build system used for
8+
# building official binaries.
9+
# Please modify the gyp files if you are making changes to build system.
10+
11+
import("unofficial.gni")
12+
13+
inspector_gn_build("inspector") {
14+
}

‎src/inspector/unofficial.gni

+81
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
# Copyright (c) 2013-2019 GitHub Inc.
2+
# Copyright 2019 the V8 project authors. All rights reserved.
3+
# Copyright 2023 Microsoft Inc.
4+
# Use of this source code is governed by a BSD-style license that can be
5+
# found in the LICENSE file.
6+
7+
import("../../node.gni")
8+
import("$node_v8_path/gni/v8.gni")
9+
10+
# The actual configurations are put inside a template in unofficial.gni to
11+
# prevent accidental edits from contributors.
12+
template("inspector_gn_build") {
13+
group(target_name) {
14+
forward_variables_from(invoker, "*")
15+
deps = [
16+
":node_protocol_generated_sources",
17+
":v8_inspector_compress_protocol_json",
18+
]
19+
}
20+
21+
node_gen_dir = get_label_info("../..", "target_gen_dir")
22+
protocol_tool_path = "../../tools/inspector_protocol"
23+
24+
gypi_values = exec_script(
25+
"../../tools/gypi_to_gn.py",
26+
[ rebase_path("node_inspector.gypi"),
27+
"--replace=<(SHARED_INTERMEDIATE_DIR)=$node_gen_dir",
28+
"--replace=<(protocol_tool_path)=$protocol_tool_path" ],
29+
"scope",
30+
[ "node_inspector.gypi" ])
31+
32+
action("node_protocol_generated_sources") {
33+
script = "$protocol_tool_path/code_generator.py"
34+
35+
deps = [ ":node_protocol_json" ]
36+
37+
outputs = gypi_values.node_inspector_generated_sources
38+
inputs = gypi_values.node_protocol_files + [
39+
"node_protocol_config.json",
40+
"$node_gen_dir/src/node_protocol.json",
41+
]
42+
43+
args = [
44+
"--jinja_dir",
45+
# jinja is in third_party.
46+
rebase_path("//third_party/", root_build_dir),
47+
"--output_base",
48+
rebase_path("$node_gen_dir/src", root_build_dir),
49+
"--config",
50+
rebase_path("node_protocol_config.json", root_build_dir),
51+
]
52+
}
53+
54+
action("v8_inspector_compress_protocol_json") {
55+
script = "../../tools/compress_json.py"
56+
deps = [ ":concatenate_protocols" ]
57+
inputs = [ "$target_gen_dir/concatenated_protocol.json" ]
58+
outputs = [ "$target_gen_dir/v8_inspector_protocol_json.h" ]
59+
args = rebase_path(inputs + outputs, root_build_dir)
60+
}
61+
62+
action("concatenate_protocols") {
63+
script = "$protocol_tool_path/concatenate_protocols.py"
64+
deps = [ ":node_protocol_json" ]
65+
inputs = [
66+
"$node_gen_dir/src/js_protocol.json",
67+
"$node_gen_dir/src/node_protocol.json",
68+
]
69+
outputs = [
70+
"$target_gen_dir/concatenated_protocol.json",
71+
]
72+
args = rebase_path(inputs + outputs, root_build_dir)
73+
}
74+
75+
action_foreach("node_protocol_json") {
76+
script = "$node_v8_path/third_party/inspector_protocol/convert_protocol_to_json.py"
77+
sources = [ "node_protocol.pdl", v8_inspector_js_protocol ]
78+
outputs = [ "$node_gen_dir/src/{{source_name_part}}.json" ]
79+
args = [ "{{source}}" ] + rebase_path(outputs, root_build_dir)
80+
}
81+
}

‎tools/generate_config_gypi.py

+75
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
#!/usr/bin/env python3
2+
# Copyright (c) 2013-2019 GitHub Inc.
3+
# Copyright 2019 the V8 project authors. All rights reserved.
4+
# Use of this source code is governed by a BSD-style license that can be
5+
# found in the LICENSE file.
6+
7+
# This script reads the configurations of GN and outputs a config.gypi file that
8+
# will be used to populate process.config.variables.
9+
10+
import re
11+
import os
12+
import subprocess
13+
import sys
14+
15+
root_dir = os.path.dirname(os.path.dirname(__file__))
16+
sys.path.append(os.path.join(root_dir, 'node', 'tools'))
17+
import getmoduleversion
18+
import getnapibuildversion
19+
20+
GN_RE = re.compile(r'(\w+)\s+=\s+(.*?)$', re.MULTILINE)
21+
22+
def bool_string_to_number(v):
23+
return 1 if v == 'true' else 0
24+
25+
def translate_config(config):
26+
return {
27+
'target_defaults': {
28+
'default_configuration':
29+
'Debug' if config['is_debug'] == 'true' else 'Release',
30+
},
31+
'variables': {
32+
'asan': bool_string_to_number(config['is_asan']),
33+
'llvm_version': 13,
34+
'napi_build_version': config['napi_build_version'],
35+
'node_builtin_shareable_builtins':
36+
eval(config['node_builtin_shareable_builtins']),
37+
'node_module_version': int(config['node_module_version']),
38+
'node_shared': bool_string_to_number(config['is_component_build']),
39+
'node_use_openssl': config['node_use_openssl'],
40+
'node_use_node_code_cache': config['node_use_node_code_cache'],
41+
'node_use_node_snapshot': config['node_use_node_snapshot'],
42+
'v8_enable_31bit_smis_on_64bit_arch':
43+
bool_string_to_number(config['v8_enable_31bit_smis_on_64bit_arch']),
44+
'v8_enable_pointer_compression':
45+
bool_string_to_number(config['v8_enable_pointer_compression']),
46+
'v8_enable_i18n_support':
47+
bool_string_to_number(config['v8_enable_i18n_support']),
48+
'v8_enable_inspector': # this is actually a node misnomer
49+
bool_string_to_number(config['node_enable_inspector']),
50+
'shlib_suffix': 'dylib' if sys.platform == 'darwin' else 'so',
51+
}
52+
}
53+
54+
def main(gn_out_dir, output_file, depfile):
55+
# Get GN config and parse into a dictionary.
56+
if sys.platform == 'win32':
57+
gn = 'gn.exe'
58+
else:
59+
gn = 'gn'
60+
gnconfig = subprocess.check_output(
61+
[gn, 'args', '--list', '--short', '-C', gn_out_dir])
62+
config = dict(re.findall(GN_RE, gnconfig.decode('utf-8')))
63+
config['node_module_version'] = getmoduleversion.get_version()
64+
config['napi_build_version'] = getnapibuildversion.get_napi_version()
65+
66+
# Write output.
67+
with open(output_file, 'w') as f:
68+
f.write(repr(translate_config(config)))
69+
70+
# Write depfile. Force regenerating config.gypi when GN configs change.
71+
with open(depfile, 'w') as f:
72+
f.write('%s: %s '%(output_file, 'build.ninja'))
73+
74+
if __name__ == '__main__':
75+
main(sys.argv[1], sys.argv[2], sys.argv[3])

‎tools/gypi_to_gn.py

+219
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,219 @@
1+
#!/usr/bin/env python3
2+
# Copyright 2014 The Chromium Authors. All rights reserved.
3+
# Use of this source code is governed by a BSD-style license that can be
4+
# found in the LICENSE file.
5+
# Deleted from Chromium in https://crrev.com/097f64c631.
6+
7+
"""Converts a given gypi file to a python scope and writes the result to stdout.
8+
USING THIS SCRIPT IN CHROMIUM
9+
Forking Python to run this script in the middle of GN is slow, especially on
10+
Windows, and it makes both the GYP and GN files harder to follow. You can't
11+
use "git grep" to find files in the GN build any more, and tracking everything
12+
in GYP down requires a level of indirection. Any calls will have to be removed
13+
and cleaned up once the GYP-to-GN transition is complete.
14+
As a result, we only use this script when the list of files is large and
15+
frequently-changing. In these cases, having one canonical list outweights the
16+
downsides.
17+
As of this writing, the GN build is basically complete. It's likely that all
18+
large and frequently changing targets where this is appropriate use this
19+
mechanism already. And since we hope to turn down the GYP build soon, the time
20+
horizon is also relatively short. As a result, it is likely that no additional
21+
uses of this script should every be added to the build. During this later part
22+
of the transition period, we should be focusing more and more on the absolute
23+
readability of the GN build.
24+
HOW TO USE
25+
It is assumed that the file contains a toplevel dictionary, and this script
26+
will return that dictionary as a GN "scope" (see example below). This script
27+
does not know anything about GYP and it will not expand variables or execute
28+
conditions.
29+
It will strip conditions blocks.
30+
A variables block at the top level will be flattened so that the variables
31+
appear in the root dictionary. This way they can be returned to the GN code.
32+
Say your_file.gypi looked like this:
33+
{
34+
'sources': [ 'a.cc', 'b.cc' ],
35+
'defines': [ 'ENABLE_DOOM_MELON' ],
36+
}
37+
You would call it like this:
38+
gypi_values = exec_script("//build/gypi_to_gn.py",
39+
[ rebase_path("your_file.gypi") ],
40+
"scope",
41+
[ "your_file.gypi" ])
42+
Notes:
43+
- The rebase_path call converts the gypi file from being relative to the
44+
current build file to being system absolute for calling the script, which
45+
will have a different current directory than this file.
46+
- The "scope" parameter tells GN to interpret the result as a series of GN
47+
variable assignments.
48+
- The last file argument to exec_script tells GN that the given file is a
49+
dependency of the build so Ninja can automatically re-run GN if the file
50+
changes.
51+
Read the values into a target like this:
52+
component("mycomponent") {
53+
sources = gypi_values.sources
54+
defines = gypi_values.defines
55+
}
56+
Sometimes your .gypi file will include paths relative to a different
57+
directory than the current .gn file. In this case, you can rebase them to
58+
be relative to the current directory.
59+
sources = rebase_path(gypi_values.sources, ".",
60+
"//path/gypi/input/values/are/relative/to")
61+
This script will tolerate a 'variables' in the toplevel dictionary or not. If
62+
the toplevel dictionary just contains one item called 'variables', it will be
63+
collapsed away and the result will be the contents of that dictinoary. Some
64+
.gypi files are written with or without this, depending on how they expect to
65+
be embedded into a .gyp file.
66+
This script also has the ability to replace certain substrings in the input.
67+
Generally this is used to emulate GYP variable expansion. If you passed the
68+
argument "--replace=<(foo)=bar" then all instances of "<(foo)" in strings in
69+
the input will be replaced with "bar":
70+
gypi_values = exec_script("//build/gypi_to_gn.py",
71+
[ rebase_path("your_file.gypi"),
72+
"--replace=<(foo)=bar"],
73+
"scope",
74+
[ "your_file.gypi" ])
75+
"""
76+
77+
from __future__ import absolute_import
78+
from __future__ import print_function
79+
from optparse import OptionParser
80+
import os
81+
import sys
82+
83+
84+
# Look for standalone GN distribution.
85+
def FindGNPath():
86+
for i in os.environ['PATH'].split(os.pathsep):
87+
if i.rstrip(os.sep).endswith('gn'):
88+
return i
89+
return None
90+
91+
92+
try:
93+
# May already be in the import path.
94+
import gn_helpers
95+
except ImportError:
96+
# Add src/build to import path.
97+
src_dir = os.path.abspath(os.path.join(os.path.dirname(__file__),
98+
os.pardir, os.pardir))
99+
sys.path.append(os.path.join(src_dir, 'build'))
100+
if FindGNPath():
101+
sys.path.append(os.path.join(FindGNPath(), 'build'))
102+
import gn_helpers
103+
104+
105+
def LoadPythonDictionary(path):
106+
file_string = open(path).read()
107+
try:
108+
file_data = eval(file_string, {'__builtins__': None}, None)
109+
except SyntaxError as e:
110+
e.filename = path
111+
raise
112+
except Exception as e:
113+
raise Exception("Unexpected error while reading %s: %s" % (path, str(e)))
114+
115+
assert isinstance(file_data, dict), "%s does not eval to a dictionary" % path
116+
117+
# Flatten any variables to the top level.
118+
if 'variables' in file_data:
119+
file_data.update(file_data['variables'])
120+
del file_data['variables']
121+
122+
# Strip all elements that this script can't process.
123+
elements_to_strip = [
124+
'conditions',
125+
'direct_dependent_settings',
126+
'target_conditions',
127+
'target_defaults',
128+
'targets',
129+
'includes',
130+
'actions',
131+
]
132+
for element in elements_to_strip:
133+
if element in file_data:
134+
del file_data[element]
135+
136+
return file_data
137+
138+
139+
def ReplaceSubstrings(values, search_for, replace_with):
140+
"""Recursively replaces substrings in a value.
141+
Replaces all substrings of the "search_for" with "repace_with" for all
142+
strings occurring in "values". This is done by recursively iterating into
143+
lists as well as the keys and values of dictionaries."""
144+
if isinstance(values, str):
145+
return values.replace(search_for, replace_with)
146+
147+
if isinstance(values, list):
148+
result = []
149+
for v in values:
150+
# Remove the item from list for complete match.
151+
if v == search_for and replace_with == '':
152+
continue
153+
result.append(ReplaceSubstrings(v, search_for, replace_with))
154+
return result
155+
156+
if isinstance(values, dict):
157+
# For dictionaries, do the search for both the key and values.
158+
result = {}
159+
for key, value in values.items():
160+
new_key = ReplaceSubstrings(key, search_for, replace_with)
161+
new_value = ReplaceSubstrings(value, search_for, replace_with)
162+
result[new_key] = new_value
163+
return result
164+
165+
# Assume everything else is unchanged.
166+
return values
167+
168+
169+
def DeduplicateLists(values):
170+
"""Recursively remove duplicate values in lists."""
171+
if isinstance(values, list):
172+
return sorted(list(set(values)))
173+
174+
if isinstance(values, dict):
175+
for key in values:
176+
values[key] = DeduplicateLists(values[key])
177+
return values
178+
179+
180+
def main():
181+
parser = OptionParser()
182+
parser.add_option("-r", "--replace", action="append",
183+
help="Replaces substrings. If passed a=b, replaces all substrs a with b.")
184+
(options, args) = parser.parse_args()
185+
186+
if len(args) != 1:
187+
raise Exception("Need one argument which is the .gypi file to read.")
188+
189+
data = LoadPythonDictionary(args[0])
190+
if options.replace:
191+
# Do replacements for all specified patterns.
192+
for replace in options.replace:
193+
split = replace.split('=')
194+
# Allow "foo=" to replace with nothing.
195+
if len(split) == 1:
196+
split.append('')
197+
assert len(split) == 2, "Replacement must be of the form 'key=value'."
198+
data = ReplaceSubstrings(data, split[0], split[1])
199+
200+
gn_dict = {}
201+
for key in data:
202+
gn_key = key.replace('-', '_')
203+
# Sometimes .gypi files use the GYP syntax with percents at the end of the
204+
# variable name (to indicate not to overwrite a previously-defined value):
205+
# 'foo%': 'bar',
206+
# Convert these to regular variables.
207+
if len(key) > 1 and key[len(key) - 1] == '%':
208+
gn_dict[gn_key[:-1]] = data[key]
209+
else:
210+
gn_dict[gn_key] = data[key]
211+
212+
print(gn_helpers.ToGNString(DeduplicateLists(gn_dict)))
213+
214+
if __name__ == '__main__':
215+
try:
216+
main()
217+
except Exception as e:
218+
print(str(e))
219+
sys.exit(1)

‎tools/search_files.py

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#!/usr/bin/env python3
2+
# Copyright 2008 the V8 project authors.
3+
# Copyright 2023 Microsoft Inc.
4+
# Use of this source code is governed by a BSD-style license that can be
5+
# found in the LICENSE file.
6+
7+
import os
8+
import sys
9+
10+
from utils import SearchFiles
11+
12+
13+
if __name__ == '__main__':
14+
try:
15+
files = SearchFiles(*sys.argv[2:])
16+
files = [ os.path.relpath(x, sys.argv[1]) for x in files ]
17+
print('\n'.join(files))
18+
except Exception as e:
19+
print(str(e))
20+
sys.exit(1)

‎unofficial.gni

+352
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,352 @@
1+
# Copyright (c) 2013-2019 GitHub Inc.
2+
# Copyright 2019 the V8 project authors. All rights reserved.
3+
# Copyright 2023 Microsoft Inc.
4+
# Use of this source code is governed by a BSD-style license that can be
5+
# found in the LICENSE file.
6+
7+
# This file is used by GN for building, which is NOT the build system used for
8+
# building official binaries.
9+
# Please take a look at node.gyp if you are making changes to build system.
10+
11+
import("node.gni")
12+
import("$node_v8_path/gni/snapshot_toolchain.gni")
13+
import("$node_v8_path/gni/v8.gni")
14+
15+
# The actual configurations are put inside a template in unofficial.gni to
16+
# prevent accidental edits from contributors.
17+
template("node_gn_build") {
18+
config("node_features") {
19+
defines = []
20+
if (is_component_build) {
21+
defines += [
22+
"USING_UV_SHARED",
23+
"USING_V8_SHARED",
24+
]
25+
}
26+
if (node_use_openssl) {
27+
defines += [ "HAVE_OPENSSL=1" ]
28+
} else {
29+
defines += [ "HAVE_OPENSSL=0" ]
30+
}
31+
if (node_use_v8_platform) {
32+
defines += [ "NODE_USE_V8_PLATFORM=1" ]
33+
} else {
34+
defines += [ "NODE_USE_V8_PLATFORM=0" ]
35+
}
36+
if (node_enable_inspector) {
37+
defines += [ "HAVE_INSPECTOR=1" ]
38+
} else {
39+
defines += [ "HAVE_INSPECTOR=0" ]
40+
}
41+
if (node_use_node_code_cache) {
42+
defines += [ "NODE_USE_NODE_CODE_CACHE=1"]
43+
}
44+
if (v8_enable_i18n_support) {
45+
defines += [ "NODE_HAVE_I18N_SUPPORT=1" ]
46+
} else {
47+
defines += [ "NODE_HAVE_I18N_SUPPORT=0" ]
48+
}
49+
}
50+
51+
config("node_external_config") {
52+
include_dirs = [
53+
target_gen_dir,
54+
"src",
55+
]
56+
defines = [
57+
"NODE_WANT_INTERNALS=1",
58+
"NODE_EMBEDDER_MODULE_VERSION=$node_module_version",
59+
]
60+
configs = [
61+
":node_features",
62+
"$node_v8_path:external_config",
63+
]
64+
}
65+
66+
config("node_internal_config") {
67+
visibility = [
68+
":*",
69+
"src/inspector:*",
70+
]
71+
configs = [ ":node_external_config" ]
72+
libs = []
73+
cflags = [ "-Wno-microsoft-include" ]
74+
cflags_cc = [
75+
"-Wno-deprecated-declarations",
76+
"-Wno-extra-semi",
77+
"-Wno-implicit-fallthrough",
78+
"-Wno-macro-redefined",
79+
"-Wno-return-type",
80+
"-Wno-shadow",
81+
"-Wno-sometimes-uninitialized",
82+
"-Wno-string-plus-int",
83+
"-Wno-string-conversion",
84+
"-Wno-unreachable-code",
85+
"-Wno-unreachable-code-break",
86+
"-Wno-unreachable-code-return",
87+
"-Wno-unused-label",
88+
"-Wno-unused-private-field",
89+
"-Wno-unused-variable",
90+
"-Wno-unused-function",
91+
]
92+
93+
if (target_cpu == "x86") {
94+
node_arch = "ia32"
95+
} else {
96+
node_arch = target_cpu
97+
}
98+
if (target_os == "win") {
99+
node_platform = "win32"
100+
} else if (target_os == "mac") {
101+
node_platform = "darwin"
102+
} else {
103+
node_platform = target_os
104+
}
105+
defines = [
106+
"NODE_ARCH=\"$node_arch\"",
107+
"NODE_PLATFORM=\"$node_platform\"",
108+
"NODE_REPORT"
109+
]
110+
111+
if (is_win) {
112+
defines += [
113+
"NOMINMAX",
114+
"_UNICODE=1",
115+
]
116+
} else {
117+
defines += [ "__POSIX__" ]
118+
}
119+
if (node_tag != "") {
120+
defines += [ "NODE_TAG=\"$node_tag\"" ]
121+
}
122+
if (node_v8_options != "") {
123+
defines += [ "NODE_V8_OPTIONS=\"$node_v8_options\"" ]
124+
}
125+
if (node_release_urlbase != "") {
126+
defines += [ "NODE_RELEASE_URLBASE=\"$node_release_urlbase\"" ]
127+
}
128+
if (node_use_openssl) {
129+
defines += [
130+
"NODE_OPENSSL_SYSTEM_CERT_PATH=\"$node_openssl_system_ca_path\"",
131+
]
132+
}
133+
}
134+
135+
gypi_values = exec_script("./tools/gypi_to_gn.py",
136+
[ rebase_path("node.gyp"),
137+
"--replace=<@(node_builtin_shareable_builtins)=" ],
138+
"scope",
139+
[ "node.gyp" ])
140+
141+
source_set("libnode") {
142+
configs += [ ":node_internal_config" ]
143+
public_configs = [
144+
":node_external_config",
145+
"deps/googletest:googletest_config",
146+
]
147+
public_deps = [
148+
"deps/ada",
149+
"deps/uv",
150+
"deps/base64",
151+
"$node_v8_path",
152+
]
153+
deps = [
154+
":run_node_js2c",
155+
"deps/brotli",
156+
"deps/cares",
157+
"deps/histogram",
158+
"deps/llhttp",
159+
"deps/nghttp2",
160+
"deps/ngtcp2",
161+
"deps/postject",
162+
"deps/simdutf",
163+
"deps/uvwasi",
164+
"//third_party/zlib",
165+
"$node_v8_path:v8_libplatform",
166+
]
167+
168+
sources = [
169+
"$target_gen_dir/node_javascript.cc",
170+
] + gypi_values.node_sources
171+
172+
if (is_win) {
173+
libs = [ "psapi.lib" ]
174+
}
175+
if (is_mac) {
176+
frameworks = [ "CoreFoundation.framework" ]
177+
}
178+
179+
if (v8_enable_i18n_support) {
180+
deps += [ "//third_party/icu" ]
181+
}
182+
if (node_use_openssl) {
183+
public_deps += [ "deps/openssl" ]
184+
sources += gypi_values.node_crypto_sources
185+
}
186+
if (node_enable_inspector) {
187+
deps += [
188+
"src/inspector:node_protocol_generated_sources",
189+
"src/inspector:v8_inspector_compress_protocol_json",
190+
]
191+
include_dirs = [
192+
"$target_gen_dir/src",
193+
"$target_gen_dir/src/inspector",
194+
]
195+
node_inspector = exec_script(
196+
"./tools/gypi_to_gn.py",
197+
[ rebase_path("src/inspector/node_inspector.gypi"),
198+
"--replace=<(SHARED_INTERMEDIATE_DIR)=$target_gen_dir" ],
199+
"scope",
200+
[ "src/inspector/node_inspector.gypi" ])
201+
sources += node_inspector.node_inspector_sources +
202+
node_inspector.node_inspector_generated_sources
203+
}
204+
}
205+
206+
executable(target_name) {
207+
forward_variables_from(invoker, "*")
208+
209+
sources = [ "src/node_main.cc" ]
210+
deps = [ ":libnode" ]
211+
if (node_use_node_snapshot) {
212+
sources += [ "$target_gen_dir/node_snapshot.cc" ]
213+
deps += [ ":run_node_mksnapshot" ]
214+
if (is_clang || !is_win) {
215+
cflags_cc = [
216+
"-Wno-c++11-narrowing",
217+
"-Wno-shadow",
218+
]
219+
}
220+
} else {
221+
sources += [ "src/node_snapshot_stub.cc" ]
222+
}
223+
output_name = "node"
224+
}
225+
226+
if (node_use_node_snapshot) {
227+
if (current_toolchain == v8_snapshot_toolchain) {
228+
executable("node_mksnapshot") {
229+
configs += [ ":node_internal_config" ]
230+
sources = [
231+
"src/node_snapshot_stub.cc",
232+
"tools/snapshot/node_mksnapshot.cc",
233+
]
234+
deps = [ ":libnode" ]
235+
}
236+
}
237+
238+
action("run_node_mksnapshot") {
239+
deps = [ ":node_mksnapshot($v8_snapshot_toolchain)" ]
240+
script = "$node_v8_path/tools/run.py"
241+
sources = []
242+
data = []
243+
244+
mksnapshot_dir = get_label_info(":node_mksnapshot($v8_snapshot_toolchain)",
245+
"root_out_dir")
246+
247+
outputs = [ "$target_gen_dir/node_snapshot.cc" ]
248+
args = [
249+
"./" + rebase_path(mksnapshot_dir + "/node_mksnapshot", root_build_dir),
250+
rebase_path("$target_gen_dir/node_snapshot.cc", root_build_dir),
251+
]
252+
}
253+
}
254+
255+
action("generate_config_gypi") {
256+
script = "tools/generate_config_gypi.py"
257+
outputs = [ "$target_gen_dir/config.gypi" ]
258+
depfile = "$target_gen_dir/$target_name.d"
259+
script_args = [ "$root_build_dir" ]
260+
script_args += outputs
261+
script_args += [ depfile ]
262+
args = rebase_path(script_args, root_build_dir)
263+
}
264+
265+
executable("node_js2c") {
266+
deps = [
267+
"deps/simdutf",
268+
"deps/uv",
269+
]
270+
sources = [
271+
"tools/js2c.cc",
272+
"tools/executable_wrapper.h",
273+
]
274+
}
275+
276+
action("run_node_js2c") {
277+
script = "$node_v8_path/tools/run.py"
278+
deps = [
279+
":node_js2c($host_toolchain)",
280+
":generate_config_gypi",
281+
]
282+
283+
node_deps_files = gypi_values.deps_files + node_builtin_shareable_builtins
284+
node_library_files = exec_script("./tools/search_files.py",
285+
[ rebase_path(".", root_build_dir),
286+
rebase_path("lib", root_build_dir),
287+
"js" ],
288+
"list lines")
289+
290+
inputs = node_library_files +
291+
node_deps_files +
292+
[ "$target_gen_dir/config.gypi" ]
293+
outputs = [ "$target_gen_dir/node_javascript.cc" ]
294+
295+
# Get the path to node_js2c executable of the host toolchain.
296+
if (host_os == "win") {
297+
host_executable_suffix = ".exe"
298+
} else {
299+
host_executable_suffix = ""
300+
}
301+
node_js2c_path =
302+
get_label_info(":node_js2c($host_toolchain)", "root_out_dir") + "/" +
303+
get_label_info(":node_js2c($host_toolchain)", "name") +
304+
host_executable_suffix
305+
306+
args = [ rebase_path(node_js2c_path),
307+
rebase_path("$target_gen_dir/node_javascript.cc"),
308+
"--root", rebase_path("."),
309+
"lib", rebase_path("$target_gen_dir/config.gypi") ] +
310+
node_deps_files
311+
}
312+
313+
executable("node_cctest") {
314+
testonly = true
315+
configs += [ ":node_internal_config" ]
316+
317+
deps = [
318+
":libnode",
319+
"deps/googletest",
320+
"deps/googletest:gtest_main",
321+
"deps/simdutf",
322+
]
323+
324+
sources = gypi_values.node_cctest_sources
325+
if (node_use_openssl) {
326+
sources += gypi_values.node_cctest_openssl_sources
327+
}
328+
if (node_enable_inspector) {
329+
sources += gypi_values.node_cctest_inspector_sources
330+
}
331+
}
332+
333+
executable("node_embedtest") {
334+
output_name = "embedtest"
335+
testonly = true
336+
deps = [ ":libnode" ]
337+
sources = [
338+
"src/node_snapshot_stub.cc",
339+
"test/embedding/embedtest.cc",
340+
]
341+
}
342+
343+
executable("overlapped_checker") {
344+
output_name = "overlapped-checker"
345+
testonly = true
346+
if (is_win) {
347+
sources = [ "test/overlapped-checker/main_win.c" ]
348+
} else {
349+
sources = [ "test/overlapped-checker/main_unix.c" ]
350+
}
351+
}
352+
}

0 commit comments

Comments
 (0)
Please sign in to comment.