-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest-nodejs-debug.js
More file actions
66 lines (57 loc) · 2.31 KB
/
Copy pathtest-nodejs-debug.js
File metadata and controls
66 lines (57 loc) · 2.31 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
// Debug Node.js SDK library loading
const path = require('path');
const fs = require('fs');
const os = require('os');
// Simulate the findLibrary function
function findLibrary() {
const platform = os.platform();
const arch = os.arch();
let libName;
let platformDir;
// Determine library name and platform-specific path
if (platform === 'win32') {
libName = 'overdrive.dll';
platformDir = 'windows';
} else if (platform === 'darwin') {
libName = 'liboverdrive.dylib';
if (arch === 'arm64') {
platformDir = 'macos/arm64';
} else {
platformDir = 'macos/x64';
}
} else {
libName = 'liboverdrive.so';
if (arch === 'arm64') {
platformDir = 'linux/arm64';
} else {
platformDir = 'linux/x64';
}
}
console.log(`Platform: ${platform}, Arch: ${arch}`);
console.log(`Library name: ${libName}, Platform dir: ${platformDir}`);
// NEW: Primary search paths using centralized native/ directory
const searchPaths = [
// 1. NEW STRUCTURE: Centralized native libraries
path.join(__dirname, 'sdks', 'nodejs', '..', '..', '..', 'native', platformDir, libName),
path.join(__dirname, 'sdks', 'nodejs', '..', '..', '..', 'native', 'windows', libName), // Windows fallback
// 2. BACKWARD COMPATIBILITY: Old locations (for transition period)
path.join(__dirname, 'sdks', 'nodejs', libName),
path.join(__dirname, 'sdks', 'nodejs', 'lib', libName),
path.join(__dirname, 'sdks', 'nodejs', '..', 'target', 'release', libName),
path.join(__dirname, 'sdks', 'nodejs', '..', '..', 'target', 'release', libName),
];
console.log('\nSearch paths:');
for (let i = 0; i < searchPaths.length; i++) {
const p = path.resolve(searchPaths[i]);
const exists = fs.existsSync(p);
const size = exists ? fs.statSync(p).size : 0;
console.log(` ${i + 1}. ${p} - ${exists ? `EXISTS (${size} bytes)` : 'NOT FOUND'}`);
if (exists) {
console.log(` -> This would be selected!`);
return p;
}
}
console.log('\nNo library found, would fall back to system path');
return libName; // Fall back to system path
}
const foundPath = findLibrary();