Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added .DS_Store
Binary file not shown.
27 changes: 14 additions & 13 deletions binding.gyp
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,26 @@
'targets': [
{
'target_name': 'vad',
'product_extension': 'node',
'type': 'loadable_module',
'defines': [],
'include_dirs': ["<!(node -e \"require('nan')\")", "./src"],
'defines': ["NAPI_VERSION=<(napi_build_version)",],
'include_dirs': ["<!@(node -p \"require('node-addon-api').include\")", "<!(node -e \"require('nan')\")", "./src"],
'sources': [
'src/simplevad.c',
'src/vad_bindings.cc'
],
'dependencies': [
'./vendor/webrtc_vad/webrtc_vad.gyp:webrtc_vad'
"./vendor/webrtc_vad/webrtc_vad.gyp:webrtc_vad",
"<!(node -p \"require('node-addon-api').gyp\")"
],
'conditions': [
['OS=="mac"', {
"xcode_settings": {
"MACOSX_DEPLOYMENT_TARGET": "10.9",
"CLANG_CXX_LIBRARY": "libc++"
}
}]
]
'cflags!': [ '-fno-exceptions' ],
'cflags_cc!': [ '-fno-exceptions' ],
'xcode_settings': {
'GCC_ENABLE_CPP_EXCEPTIONS': 'YES',
'CLANG_CXX_LIBRARY': 'libc++',
'MACOSX_DEPLOYMENT_TARGET': '11.0'
},
'msvs_settings': {
'VCCLCompilerTool': { 'ExceptionHandling': 1 },
}
}
]
}
49 changes: 49 additions & 0 deletions check.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
/// dummy copy of internal function
function Module(id, parent) {
this.id = id;
this.exports = {};
this.parent = parent;
// updateChildren(parent, this, false);
this.filename = null;
this.loaded = false;
this.children = [];
}


// try to determine the ABI version for a native module
const getNativeABI = (filename) => {
var moduleVersion = 0
try {
var test = new Module(filename, null);
process.dlopen(module, filename) //,os.constants.dlopen.RTLD_NOW);
// if this works the node version is the same
moduleVersion = process.versions['modules']
// but now we need to unload it :-(
return moduleVersion
} catch (error) {
var match
var versionRegexp = /NODE_MODULE_VERSION (\d*)./gm
var platformRegexp = /(is not a valid Win32 application|invalid ELF header|wrong ELF class)/g
// check for ABI version mismatch
// Uncaught Error: The module '..\bindings.node'
// was compiled against a different Node.js version using
// NODE_MODULE_VERSION 47. This version of Node.js requires
// NODE_MODULE_VERSION 70. Please try re-compiling or re-installing
match = versionRegexp.exec(error.message)
if (match != null){
return match[1] // first version is that of the module
}
// not for valid on this win32 / linux
match = platformRegexp.exec(error.message)
if (match != null){
// todo: @linux : use error for elfclass to determine architecture :: wrong ELF class: ELFCLASS32
return 0 // can't validate cross platform
}
// other error
console.debug( error.message)
}
return moduleVersion // just in case
}


console.log(getNativeABI("./prebuilds/build/Release/vad.node"));
Loading