Skip to content

Commit

Permalink
gyp
Browse files Browse the repository at this point in the history
  • Loading branch information
ailieg committed Oct 17, 2024
1 parent 0ee2f99 commit f4fe03d
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 38 deletions.
48 changes: 10 additions & 38 deletions binding.gyp
Original file line number Diff line number Diff line change
@@ -1,43 +1,15 @@
{
"targets": [
{
"target_name": "tuntap2Addon",
"sources": [
"src/cpp/tuntap-napi.cpp",
"src/cpp/tuntap-linux.cpp",
"src/cpp/tun-win.cpp"
],
'cflags!': [ '-fno-exceptions', '--std=c++17', '-Wno-stringop-truncation' ],
'cflags_cc!': [ '-fno-exceptions', '--std=c++17', '-Wno-stringop-truncation' ],
"cflags+": [
"-fvisibility=hidden",
'--std=c++17',
'-Wno-stringop-truncation'
],
'cflags!': [ '-fno-exceptions' ],
'cflags_cc!': [ '-fno-exceptions' ],
'include_dirs': [
"<!@(node -p \"require('node-addon-api').include\")"
],
'dependencies': [
"<!(node -p \"require('node-addon-api').gyp\")"
],
'conditions': [
['OS=="win"', {
"msvs_settings": {
"VCCLCompilerTool": {
"ExceptionHandling": 1
}
}
}],
['OS=="mac"', {
"xcode_settings": {
"CLANG_CXX_LIBRARY": "libc++",
'GCC_ENABLE_CPP_EXCEPTIONS': 'YES',
#'MACOSX_DEPLOYMENT_TARGET': '10.7'
}
}]
]
}
"target_name": "tuntap2Addon",
"sources": [
"src/cpp/tuntap-napi.cpp",
"src/cpp/tuntap-linux.cpp",
"src/cpp/tun-win.cpp"
],
'includes': [
'./common.gypi'
]
},
]
}
34 changes: 34 additions & 0 deletions common.gypi
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{
# 为什么要这个配置 https://github.com/nodejs/node-gyp/issues/26
'cflags!': ['-fno-exceptions'],
'cflags_cc!': ['-fno-exceptions'],
"include_dirs": [
"<!@(node -p \"require('node-addon-api').include\")",
],
"dependencies": [
"<!(node -p \"require('node-addon-api').gyp\")"
],
'conditions': [
['OS=="mac"', {
'cflags+': ['-fvisibility=hidden'],
'xcode_settings': {
'GCC_ENABLE_CPP_EXCEPTIONS': 'YES',
'CLANG_CXX_LIBRARY': 'libc++',
'MACOSX_DEPLOYMENT_TARGET': '10.7',
'GCC_SYMBOLS_PRIVATE_EXTERN': 'YES', # -fvisibility=hidden
}
}],
['OS=="win"', {
'msvs_settings': {
'VCCLCompilerTool': {
'ExceptionHandling': 1,
'AdditionalOptions': ['/source-charset:utf-8']
},
},
'defines':[
'_HAS_EXCEPTIONS=1',
'NOMINMAX'
]
}]
]
}

0 comments on commit f4fe03d

Please sign in to comment.