Skip to content

Commit 98b7f62

Browse files
Feature/dir renames (#43)
* Updating directory names when searching for native libs * - Update commit to submodule - Remove support for 32-bit windows + Linux * Update commit of native libs * Explicitly load library dependencies on Windows * Fix loading of extra libs Co-authored-by: Sam Raeburn <sam@rti.com>
1 parent c6ac4fd commit 98b7f62

2 files changed

Lines changed: 17 additions & 23 deletions

File tree

rticonnextdds-connector.js

Lines changed: 16 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -29,48 +29,36 @@ var _ConnectorOptions = StructType({
2929

3030
class _ConnectorBinding {
3131
constructor () {
32-
let libArch = ''
32+
let libDir = ''
3333
let libName = ''
3434
let additionalLib = null
35+
let isWindows = false
3536

3637
// Obtain the name of the library that contains the Connector binding
3738
if (os.arch() === 'x64') {
3839
switch (os.platform()) {
3940
case 'darwin':
40-
libArch = 'x64Darwin16clang8.0'
41+
libDir = 'osx-x64'
4142
libName = 'librtiddsconnector.dylib'
4243
break
4344
case 'linux':
44-
libArch = 'x64Linux2.6gcc4.4.5'
45+
libDir = 'linux-x64'
4546
libName = 'librtiddsconnector.so'
4647
break
4748
// Windows returns win32 even on 64-bit platforms
4849
case 'win32':
49-
libArch = 'x64Win64VS2013'
50+
libDir = 'win-x64'
5051
libName = 'rtiddsconnector.dll'
5152
additionalLib = 'msvcr120.dll'
52-
break
53-
default:
54-
throw new Error(os.platform() + ' not yet supported')
55-
}
56-
} else if (os.arch() === 'ia32') {
57-
switch (os.platform()) {
58-
case 'linux':
59-
libArch = 'i86Linux3.xgcc4.6.3'
60-
libName = 'librtiddsconnector.so'
61-
break
62-
case 'win32':
63-
libArch = 'i86Win32VS2010'
64-
libName = 'rtiddsconnector.dll'
65-
additionalLib = 'msvcr100.dll'
53+
isWindows = true
6654
break
6755
default:
6856
throw new Error(os.platform() + ' not yet supported')
6957
}
7058
} else if (os.arch() === 'arm64') {
7159
switch (os.platform()) {
7260
case 'linux':
73-
libArch = 'armv8Linux4gcc7.3.0'
61+
libDir = 'linux-arm64'
7462
libName = 'librtiddsconnector.so'
7563
break
7664
default:
@@ -79,7 +67,7 @@ class _ConnectorBinding {
7967
} else if (os.arch() === 'arm') {
8068
switch (os.platform()) {
8169
case 'linux':
82-
libArch = 'armv6vfphLinux3.xgcc4.7.2'
70+
libDir = 'linux-arm'
8371
libName = 'librtiddsconnector.so'
8472
break
8573
default:
@@ -91,13 +79,19 @@ class _ConnectorBinding {
9179

9280
if (additionalLib !== null) {
9381
try {
94-
ffi.Library(path.join(__dirname, '/rticonnextdds-connector/lib/', libArch, '/', additionalLib))
82+
ffi.Library(path.join(__dirname, '/rticonnextdds-connector/lib/', libDir, '/', additionalLib))
9583
} catch (_) {
9684
// ignore this error and try to run without explicitly loading the VC++ runtime
9785
}
9886
}
9987

100-
this.library = path.join(__dirname, '/rticonnextdds-connector/lib/', libArch, '/', libName)
88+
// On Windows we need to explicitly load the dependent libraries
89+
if (isWindows) {
90+
ffi.Library(path.join(__dirname, '/rticonnextdds-connector/lib/', libDir, '/', 'nddscore.dll'))
91+
ffi.Library(path.join(__dirname, '/rticonnextdds-connector/lib/', libDir, '/', 'nddsc.dll'))
92+
}
93+
94+
this.library = path.join(__dirname, '/rticonnextdds-connector/lib/', libDir, '/', libName)
10195
// Obtain FFI'd methods for all of the APIs which we require from the binding,
10296
// specifying the argument types and return types. If any of the types are
10397
// not builtin Node types then we have to use the ref module to represent them.

0 commit comments

Comments
 (0)