From d3f9303fe64a62072eb8e934c98fea2800b473b1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C3=ABl=20Zasso?= Date: Sun, 5 May 2024 11:24:59 +0200 Subject: [PATCH] build: compile with C++20 support --- Makefile | 2 +- common_node.gypi | 16 ++++++++++++++++ node.gyp | 2 ++ tools/create_android_makefiles | 1 + tools/gyp_node.py | 4 ++++ 5 files changed, 24 insertions(+), 1 deletion(-) create mode 100644 common_node.gypi diff --git a/Makefile b/Makefile index 475043ceae7eb6..1824102920b6da 100644 --- a/Makefile +++ b/Makefile @@ -168,7 +168,7 @@ endif with-code-cache test-code-cache: $(warning '$@' target is a noop) -out/Makefile: config.gypi common.gypi node.gyp \ +out/Makefile: config.gypi common.gypi common_node.gypi node.gyp \ deps/uv/uv.gyp deps/llhttp/llhttp.gyp deps/zlib/zlib.gyp \ deps/simdutf/simdutf.gyp deps/ada/ada.gyp \ tools/v8_gypfiles/toolchain.gypi tools/v8_gypfiles/features.gypi \ diff --git a/common_node.gypi b/common_node.gypi new file mode 100644 index 00000000000000..0bfbf7283c0f57 --- /dev/null +++ b/common_node.gypi @@ -0,0 +1,16 @@ +{ + 'target_defaults': { + 'conditions': [ + # Override common.gypi config to use C++20 for Node.js core only. + ['OS in "linux freebsd openbsd solaris android aix os400 cloudabi"', { + 'cflags_cc!': ['-std=gnu++17'], + 'cflags_cc': ['-std=gnu++20'], + }], + ['OS=="mac" and clang==1', { + 'xcode_settings': { + 'CLANG_CXX_LANGUAGE_STANDARD': 'gnu++20', # -std=gnu++20 + }, + }], + ], + }, +} diff --git a/node.gyp b/node.gyp index dc4d77330a811d..fabecda290b37d 100644 --- a/node.gyp +++ b/node.gyp @@ -860,6 +860,7 @@ '<@(deps_files)', # node.gyp is added by default, common.gypi is added for change detection 'common.gypi', + 'common_node.gypi', ], 'variables': { @@ -1347,6 +1348,7 @@ '<@(library_files)', '<@(deps_files)', 'common.gypi', + 'common_node.gypi', ], 'direct_dependent_settings': { 'ldflags': [ '-Wl,-brtl' ], diff --git a/tools/create_android_makefiles b/tools/create_android_makefiles index abf2ecf083c307..6f180aebede655 100755 --- a/tools/create_android_makefiles +++ b/tools/create_android_makefiles @@ -37,6 +37,7 @@ export GYP_DEFINES ./deps/npm/node_modules/node-gyp/gyp/gyp \ -Icommon.gypi \ + -Icommon_node.gypi \ -Iconfig.gypi \ --depth=. \ -Dcomponent=static_library \ diff --git a/tools/gyp_node.py b/tools/gyp_node.py index 097e1a213ca559..905755a617e019 100755 --- a/tools/gyp_node.py +++ b/tools/gyp_node.py @@ -20,11 +20,15 @@ def run_gyp(args): a_path = node_root if sys.platform == 'win32' else os.path.abspath(node_root) args.append(os.path.join(a_path, 'node.gyp')) common_fn = os.path.join(a_path, 'common.gypi') + common_node_fn = os.path.join(a_path, 'common_node.gypi') options_fn = os.path.join(a_path, 'config.gypi') if os.path.exists(common_fn): args.extend(['-I', common_fn]) + if os.path.exists(common_node_fn): + args.extend(['-I', common_node_fn]) + if os.path.exists(options_fn): args.extend(['-I', options_fn])