Add architecture detection for loading the correct version of the librdsparser shared library

This commit is contained in:
Mark de Bruijn
2024-02-12 21:33:18 +01:00
parent 7ac76b2c59
commit fcdd7ac5e9
5 changed files with 14 additions and 3 deletions
+14 -3
View File
@@ -4,9 +4,20 @@ const https = require('https');
const koffi = require('koffi');
const path = require('path');
const os = require('os');
const win32 = (os.platform() == "win32");
const unicode_type = (win32 ? 'int16_t' : 'int32_t');
const lib = koffi.load(path.join(__dirname, "librdsparser." + (win32 ? "dll" : "so")));
const platform = os.platform();
const cpuArchitecture = os.arch();
let unicode_type;
let shared_Library;
if (platform === 'win32') {
unicode_type = 'int16_t';
shared_Library=path.join(__dirname, "libraries", "librdsparser.dll");
} else if (platform === 'linux') {
unicode_type = 'int32_t';
shared_Library=path.join(__dirname, "libraries", "librdsparser_" + cpuArchitecture + ".so");
}
const lib = koffi.load(shared_Library);
const { fetchTx } = require('./tx_search.js');
koffi.proto('void callback_pi(void *rds, void *user_data)');
Binary file not shown.
Binary file not shown.