Skip to content

Commit a1c869e

Browse files
build: improve cflags
1 parent 637bf4f commit a1c869e

File tree

1 file changed

+18
-10
lines changed

1 file changed

+18
-10
lines changed

binding.gyp

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -24,30 +24,29 @@
2424
"defines": [
2525
"NAPI_VERSION=<(napi_build_version)",
2626
],
27-
"cflags_cc": [
28-
"-std=c++17"
29-
],
3027
"conditions": [
3128
["OS=='mac'", {
3229
"xcode_settings": {
3330
"GCC_SYMBOLS_PRIVATE_EXTERN": "YES", # -fvisibility=hidden
34-
"CLANG_CXX_LANGUAGE_STANDARD": "c++17",
31+
"CLANG_CXX_LANGUAGE_STANDARD": "<(cxxstd)",
3532
"MACOSX_DEPLOYMENT_TARGET": "10.9",
3633
},
3734
}],
3835
["OS=='win'", {
3936
"msvs_settings": {
4037
"VCCLCompilerTool": {
4138
"AdditionalOptions": [
42-
"/std:c++17",
39+
"/std:<(cxxstd)",
4340
],
4441
"RuntimeLibrary": 0,
4542
},
4643
},
4744
}],
4845
["OS == 'linux'", {
4946
"cflags_cc": [
50-
"-Wno-cast-function-type"
47+
"-std=<(cxxstd)",
48+
"-fvisibility=hidden",
49+
"-Wno-cast-function-type",
5150
]
5251
}],
5352
]
@@ -62,19 +61,28 @@
6261
"vendor/tree-sitter/lib/src",
6362
"vendor/tree-sitter/lib/include",
6463
],
65-
"cflags": [
66-
"-std=c11"
67-
],
6864
"defines": [
6965
"_POSIX_C_SOURCE=200112L",
7066
"_DEFAULT_SOURCE",
71-
]
67+
],
68+
"conditions": [
69+
["OS!='win'", {
70+
"cflags_c": [
71+
"-std=c11",
72+
],
73+
}, { # OS == "win"
74+
"cflags_c": [
75+
"/std:c11",
76+
],
77+
}],
78+
],
7279
}
7380
],
7481
"variables": {
7582
"runtime%": "node",
7683
"openssl_fips": "",
7784
"v8_enable_pointer_compression%": 0,
7885
"v8_enable_31bit_smis_on_64bit_arch%": 0,
86+
"cxxstd%": "<!(node -p \"parseInt(process.env.npm_config_target ?? process.versions.node) > 22 ? 'c++20' : 'c++17'\")",
7987
}
8088
}

0 commit comments

Comments
 (0)