Skip to content

Commit d3f9303

Browse files
committed
build: compile with C++20 support
1 parent 6135ae3 commit d3f9303

File tree

5 files changed

+24
-1
lines changed

5 files changed

+24
-1
lines changed

Makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ endif
168168
with-code-cache test-code-cache:
169169
$(warning '$@' target is a noop)
170170

171-
out/Makefile: config.gypi common.gypi node.gyp \
171+
out/Makefile: config.gypi common.gypi common_node.gypi node.gyp \
172172
deps/uv/uv.gyp deps/llhttp/llhttp.gyp deps/zlib/zlib.gyp \
173173
deps/simdutf/simdutf.gyp deps/ada/ada.gyp \
174174
tools/v8_gypfiles/toolchain.gypi tools/v8_gypfiles/features.gypi \

common_node.gypi

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
'target_defaults': {
3+
'conditions': [
4+
# Override common.gypi config to use C++20 for Node.js core only.
5+
['OS in "linux freebsd openbsd solaris android aix os400 cloudabi"', {
6+
'cflags_cc!': ['-std=gnu++17'],
7+
'cflags_cc': ['-std=gnu++20'],
8+
}],
9+
['OS=="mac" and clang==1', {
10+
'xcode_settings': {
11+
'CLANG_CXX_LANGUAGE_STANDARD': 'gnu++20', # -std=gnu++20
12+
},
13+
}],
14+
],
15+
},
16+
}

node.gyp

+2
Original file line numberDiff line numberDiff line change
@@ -860,6 +860,7 @@
860860
'<@(deps_files)',
861861
# node.gyp is added by default, common.gypi is added for change detection
862862
'common.gypi',
863+
'common_node.gypi',
863864
],
864865

865866
'variables': {
@@ -1347,6 +1348,7 @@
13471348
'<@(library_files)',
13481349
'<@(deps_files)',
13491350
'common.gypi',
1351+
'common_node.gypi',
13501352
],
13511353
'direct_dependent_settings': {
13521354
'ldflags': [ '-Wl,-brtl' ],

tools/create_android_makefiles

+1
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ export GYP_DEFINES
3737

3838
./deps/npm/node_modules/node-gyp/gyp/gyp \
3939
-Icommon.gypi \
40+
-Icommon_node.gypi \
4041
-Iconfig.gypi \
4142
--depth=. \
4243
-Dcomponent=static_library \

tools/gyp_node.py

+4
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,15 @@ def run_gyp(args):
2020
a_path = node_root if sys.platform == 'win32' else os.path.abspath(node_root)
2121
args.append(os.path.join(a_path, 'node.gyp'))
2222
common_fn = os.path.join(a_path, 'common.gypi')
23+
common_node_fn = os.path.join(a_path, 'common_node.gypi')
2324
options_fn = os.path.join(a_path, 'config.gypi')
2425

2526
if os.path.exists(common_fn):
2627
args.extend(['-I', common_fn])
2728

29+
if os.path.exists(common_node_fn):
30+
args.extend(['-I', common_node_fn])
31+
2832
if os.path.exists(options_fn):
2933
args.extend(['-I', options_fn])
3034

0 commit comments

Comments
 (0)