hamlib 0.1.11 → 0.1.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/binding.gyp +34 -28
- package/lib/index.js +5 -5
- package/package.json +9 -8
- package/prebuilds/darwin-arm64/libhamlib++.4.dylib +0 -0
- package/prebuilds/darwin-arm64/libhamlib++.dylib +0 -0
- package/prebuilds/darwin-arm64/libhamlib.4.dylib +0 -0
- package/prebuilds/darwin-arm64/libhamlib.dylib +0 -0
- package/prebuilds/darwin-arm64/node.napi.node +0 -0
- package/prebuilds/linux-arm64/libhamlib.so.4 +0 -0
- package/prebuilds/linux-arm64/node.napi.node +0 -0
- package/prebuilds/linux-x64/libhamlib.so.4 +0 -0
- package/prebuilds/linux-x64/node.napi.node +0 -0
- package/src/hamlib.cpp +2 -2
- package/lib/binary-loader.js +0 -95
- package/prebuilds/darwin-arm64/hamlib.node +0 -0
- package/prebuilds/linux-arm64/hamlib.node +0 -0
- package/prebuilds/linux-x64/hamlib.node +0 -0
- package/scripts/install.js +0 -262
package/binding.gyp
CHANGED
|
@@ -21,34 +21,40 @@
|
|
|
21
21
|
"cflags_cc!": [ "-fno-exceptions" ],
|
|
22
22
|
"conditions": [
|
|
23
23
|
# Linux configuration
|
|
24
|
-
["OS==\"linux\"", {
|
|
25
|
-
"include_dirs": [
|
|
26
|
-
"/usr/include",
|
|
27
|
-
"/usr/local/include"
|
|
28
|
-
],
|
|
29
|
-
"libraries": [
|
|
30
|
-
"-L/usr/lib",
|
|
31
|
-
"-L/usr/local/lib",
|
|
32
|
-
"-lhamlib"
|
|
33
|
-
]
|
|
34
|
-
|
|
24
|
+
["OS==\"linux\"", {
|
|
25
|
+
"include_dirs": [
|
|
26
|
+
"/usr/include",
|
|
27
|
+
"/usr/local/include"
|
|
28
|
+
],
|
|
29
|
+
"libraries": [
|
|
30
|
+
"-L/usr/lib",
|
|
31
|
+
"-L/usr/local/lib",
|
|
32
|
+
"-lhamlib"
|
|
33
|
+
],
|
|
34
|
+
"ldflags": [
|
|
35
|
+
"-Wl,-rpath,\\$ORIGIN"
|
|
36
|
+
]
|
|
37
|
+
}],
|
|
35
38
|
# macOS configuration
|
|
36
|
-
["OS==\"mac\"", {
|
|
37
|
-
"include_dirs": [
|
|
38
|
-
"/usr/local/include",
|
|
39
|
-
"/opt/homebrew/include"
|
|
40
|
-
],
|
|
41
|
-
"libraries": [
|
|
42
|
-
"-L/usr/local/lib",
|
|
43
|
-
"-L/opt/homebrew/lib",
|
|
44
|
-
"-lhamlib"
|
|
45
|
-
],
|
|
46
|
-
"xcode_settings": {
|
|
47
|
-
"GCC_ENABLE_CPP_EXCEPTIONS": "YES",
|
|
48
|
-
"CLANG_CXX_LIBRARY": "libc++",
|
|
49
|
-
"MACOSX_DEPLOYMENT_TARGET": "10.15"
|
|
50
|
-
}
|
|
51
|
-
|
|
39
|
+
["OS==\"mac\"", {
|
|
40
|
+
"include_dirs": [
|
|
41
|
+
"/usr/local/include",
|
|
42
|
+
"/opt/homebrew/include"
|
|
43
|
+
],
|
|
44
|
+
"libraries": [
|
|
45
|
+
"-L/usr/local/lib",
|
|
46
|
+
"-L/opt/homebrew/lib",
|
|
47
|
+
"-lhamlib"
|
|
48
|
+
],
|
|
49
|
+
"xcode_settings": {
|
|
50
|
+
"GCC_ENABLE_CPP_EXCEPTIONS": "YES",
|
|
51
|
+
"CLANG_CXX_LIBRARY": "libc++",
|
|
52
|
+
"MACOSX_DEPLOYMENT_TARGET": "10.15"
|
|
53
|
+
},
|
|
54
|
+
"ldflags": [
|
|
55
|
+
"-Wl,-rpath,@loader_path"
|
|
56
|
+
]
|
|
57
|
+
}],
|
|
52
58
|
# Windows configuration
|
|
53
59
|
["OS==\"win\"", {
|
|
54
60
|
"defines": [
|
|
@@ -149,4 +155,4 @@
|
|
|
149
155
|
]
|
|
150
156
|
}
|
|
151
157
|
]
|
|
152
|
-
}
|
|
158
|
+
}
|
package/lib/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
const
|
|
2
|
-
|
|
3
|
-
//
|
|
4
|
-
const nativeModule =
|
|
1
|
+
const path = require('path');
|
|
2
|
+
const nodeGypBuild = require('node-gyp-build');
|
|
3
|
+
// Ensure loader resolves from package root (contains prebuilds/ and build/)
|
|
4
|
+
const nativeModule = nodeGypBuild(path.join(__dirname, '..'));
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* HamLib class for controlling amateur radio devices
|
|
@@ -1076,4 +1076,4 @@ class HamLib {
|
|
|
1076
1076
|
// Export for CommonJS
|
|
1077
1077
|
module.exports = { HamLib };
|
|
1078
1078
|
module.exports.HamLib = HamLib;
|
|
1079
|
-
module.exports.default = { HamLib };
|
|
1079
|
+
module.exports.default = { HamLib };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "hamlib",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.13",
|
|
4
4
|
"description": "Node.js wrapper for hamlib radio control library",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"module": "lib/index.mjs",
|
|
@@ -30,7 +30,6 @@
|
|
|
30
30
|
"lib/",
|
|
31
31
|
"prebuilds/",
|
|
32
32
|
"src/",
|
|
33
|
-
"scripts/",
|
|
34
33
|
"index.js",
|
|
35
34
|
"index.d.ts",
|
|
36
35
|
"binding.gyp",
|
|
@@ -43,16 +42,18 @@
|
|
|
43
42
|
"clean": "node-gyp clean",
|
|
44
43
|
"test": "node test/test_loader.js",
|
|
45
44
|
"test:network": "node test/test_network.js",
|
|
46
|
-
"
|
|
47
|
-
"
|
|
48
|
-
"
|
|
49
|
-
"
|
|
45
|
+
"prebuild": "prebuildify --napi --strip",
|
|
46
|
+
"prepare": "",
|
|
47
|
+
"bundle": "node scripts/bundle-hamlib.js",
|
|
48
|
+
"prebuild:bundle": "npm run prebuild && npm run bundle"
|
|
50
49
|
},
|
|
51
50
|
"dependencies": {
|
|
52
|
-
"node-addon-api": "^4.3.0"
|
|
51
|
+
"node-addon-api": "^4.3.0",
|
|
52
|
+
"node-gyp-build": "^4.8.0"
|
|
53
53
|
},
|
|
54
54
|
"devDependencies": {
|
|
55
|
-
"node-gyp": "^9.4.0"
|
|
55
|
+
"node-gyp": "^9.4.0",
|
|
56
|
+
"prebuildify": "^5.0.0"
|
|
56
57
|
},
|
|
57
58
|
"engines": {
|
|
58
59
|
"node": ">=12.0.0"
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/src/hamlib.cpp
CHANGED
|
@@ -4482,7 +4482,8 @@ public:
|
|
|
4482
4482
|
CHECK_RIG_VALID();
|
|
4483
4483
|
|
|
4484
4484
|
length_ = max_length_;
|
|
4485
|
-
|
|
4485
|
+
// rig_recv_dtmf expects a mutable buffer (char*). Ensure non-const pointer.
|
|
4486
|
+
result_code_ = rig_recv_dtmf(hamlib_instance_->my_rig, vfo_, &digits_[0], &length_);
|
|
4486
4487
|
if (result_code_ != RIG_OK) {
|
|
4487
4488
|
error_message_ = rigerror(result_code_);
|
|
4488
4489
|
}
|
|
@@ -5346,4 +5347,3 @@ Napi::Value NodeHamLib::Reset(const Napi::CallbackInfo& info) {
|
|
|
5346
5347
|
asyncWorker->Queue();
|
|
5347
5348
|
return asyncWorker->GetPromise();
|
|
5348
5349
|
}
|
|
5349
|
-
|
package/lib/binary-loader.js
DELETED
|
@@ -1,95 +0,0 @@
|
|
|
1
|
-
const fs = require('fs');
|
|
2
|
-
const path = require('path');
|
|
3
|
-
const os = require('os');
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Get the platform-specific binary file name
|
|
7
|
-
* @returns {string} Platform-specific binary file name
|
|
8
|
-
*/
|
|
9
|
-
function getPlatformBinaryPath() {
|
|
10
|
-
const platform = os.platform();
|
|
11
|
-
const arch = os.arch();
|
|
12
|
-
|
|
13
|
-
let platformTarget;
|
|
14
|
-
|
|
15
|
-
switch (platform) {
|
|
16
|
-
case 'win32':
|
|
17
|
-
platformTarget = `win32-${arch}`;
|
|
18
|
-
break;
|
|
19
|
-
case 'darwin':
|
|
20
|
-
platformTarget = `darwin-${arch}`;
|
|
21
|
-
break;
|
|
22
|
-
case 'linux':
|
|
23
|
-
platformTarget = `linux-${arch}`;
|
|
24
|
-
break;
|
|
25
|
-
default:
|
|
26
|
-
throw new Error(`Unsupported platform: ${platform}-${arch}`);
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
return path.join(__dirname, '..', 'prebuilds', platformTarget, 'hamlib.node');
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
/**
|
|
33
|
-
* Find and load the native hamlib module
|
|
34
|
-
* @returns {Object} Native hamlib module
|
|
35
|
-
*/
|
|
36
|
-
function loadNativeModule() {
|
|
37
|
-
const possiblePaths = [
|
|
38
|
-
// First try locally compiled binary (prioritize latest features)
|
|
39
|
-
path.join(__dirname, '..', 'build', 'Release', 'hamlib.node'),
|
|
40
|
-
path.join(__dirname, '..', 'build', 'Debug', 'hamlib.node'),
|
|
41
|
-
// Fallback to prebuilt binary
|
|
42
|
-
getPlatformBinaryPath(),
|
|
43
|
-
// Try different possible locations
|
|
44
|
-
path.join(__dirname, '..', 'hamlib.node'),
|
|
45
|
-
path.join(process.cwd(), 'hamlib.node'),
|
|
46
|
-
path.join(process.cwd(), 'build', 'Release', 'hamlib.node'),
|
|
47
|
-
path.join(process.cwd(), 'build', 'Debug', 'hamlib.node')
|
|
48
|
-
];
|
|
49
|
-
|
|
50
|
-
let lastError;
|
|
51
|
-
|
|
52
|
-
for (const binaryPath of possiblePaths) {
|
|
53
|
-
try {
|
|
54
|
-
if (fs.existsSync(binaryPath)) {
|
|
55
|
-
console.log(`Loading hamlib native module from: ${binaryPath}`);
|
|
56
|
-
return require(binaryPath);
|
|
57
|
-
}
|
|
58
|
-
} catch (error) {
|
|
59
|
-
lastError = error;
|
|
60
|
-
console.warn(`Failed to load hamlib from ${binaryPath}: ${error.message}`);
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
// If we get here, we couldn't find any working binary
|
|
65
|
-
const errorMessage = [
|
|
66
|
-
'Failed to load hamlib native module.',
|
|
67
|
-
'Tried the following paths:',
|
|
68
|
-
...possiblePaths.map(p => ` - ${p}`),
|
|
69
|
-
'',
|
|
70
|
-
'This may be due to one of the following reasons:',
|
|
71
|
-
'1. The prebuilt binary is not available for your platform',
|
|
72
|
-
'2. The module needs to be compiled from source',
|
|
73
|
-
'3. Missing system dependencies (libhamlib)',
|
|
74
|
-
'',
|
|
75
|
-
'To compile from source, run:',
|
|
76
|
-
' npm run build',
|
|
77
|
-
'',
|
|
78
|
-
'To install system dependencies:',
|
|
79
|
-
' Linux: sudo apt-get install libhamlib-dev',
|
|
80
|
-
' macOS: brew install hamlib',
|
|
81
|
-
' Windows: Install hamlib via vcpkg or from source'
|
|
82
|
-
].join('\n');
|
|
83
|
-
|
|
84
|
-
const error = new Error(errorMessage);
|
|
85
|
-
if (lastError) {
|
|
86
|
-
error.originalError = lastError;
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
throw error;
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
module.exports = {
|
|
93
|
-
loadNativeModule,
|
|
94
|
-
getPlatformBinaryPath
|
|
95
|
-
};
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/scripts/install.js
DELETED
|
@@ -1,262 +0,0 @@
|
|
|
1
|
-
const fs = require('fs');
|
|
2
|
-
const path = require('path');
|
|
3
|
-
const { execSync } = require('child_process');
|
|
4
|
-
const { getPlatformBinaryPath } = require('../lib/binary-loader');
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Check if a prebuilt binary exists for the current platform
|
|
8
|
-
*/
|
|
9
|
-
function checkPrebuiltBinary() {
|
|
10
|
-
try {
|
|
11
|
-
const binaryPath = getPlatformBinaryPath();
|
|
12
|
-
return fs.existsSync(binaryPath);
|
|
13
|
-
} catch (error) {
|
|
14
|
-
return false;
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
* Check if we can build from source
|
|
20
|
-
*/
|
|
21
|
-
function canBuildFromSource() {
|
|
22
|
-
try {
|
|
23
|
-
// Check if binding.gyp exists
|
|
24
|
-
const bindingGypPath = path.join(__dirname, '..', 'binding.gyp');
|
|
25
|
-
if (!fs.existsSync(bindingGypPath)) {
|
|
26
|
-
return false;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
// Check if source files exist
|
|
30
|
-
const srcPath = path.join(__dirname, '..', 'src');
|
|
31
|
-
if (!fs.existsSync(srcPath)) {
|
|
32
|
-
return false;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
// Check if node-gyp is available
|
|
36
|
-
try {
|
|
37
|
-
execSync('node-gyp --version', { stdio: 'ignore' });
|
|
38
|
-
return true;
|
|
39
|
-
} catch (error) {
|
|
40
|
-
return false;
|
|
41
|
-
}
|
|
42
|
-
} catch (error) {
|
|
43
|
-
return false;
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
/**
|
|
48
|
-
* Check if we're in a MinGW environment
|
|
49
|
-
*/
|
|
50
|
-
function isMinGWEnvironment() {
|
|
51
|
-
return process.env.HAMLIB_ROOT === '/mingw64' ||
|
|
52
|
-
process.env.HAMLIB_ROOT === 'C:\\msys64\\mingw64' ||
|
|
53
|
-
process.env.MSYSTEM === 'MINGW64' ||
|
|
54
|
-
process.env.MINGW_PREFIX === '/mingw64' ||
|
|
55
|
-
process.env.MINGW_PREFIX === 'C:\\msys64\\mingw64';
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
/**
|
|
59
|
-
* Check if hamlib is available in the system
|
|
60
|
-
*/
|
|
61
|
-
function checkHamlibAvailable() {
|
|
62
|
-
try {
|
|
63
|
-
if (isMinGWEnvironment()) {
|
|
64
|
-
// In MinGW environment, try to use pkg-config to check hamlib
|
|
65
|
-
try {
|
|
66
|
-
execSync('pkg-config --exists hamlib', { stdio: 'ignore' });
|
|
67
|
-
console.log('✓ Hamlib found via pkg-config');
|
|
68
|
-
return true;
|
|
69
|
-
} catch (pkgConfigError) {
|
|
70
|
-
// If pkg-config fails, try to check for specific files
|
|
71
|
-
// Note: In MSYS2, /mingw64 might be mapped differently for Node.js
|
|
72
|
-
console.log('pkg-config check failed, trying direct file checks...');
|
|
73
|
-
|
|
74
|
-
// Try common MSYS2 paths
|
|
75
|
-
const possiblePaths = [
|
|
76
|
-
'/mingw64/include/hamlib',
|
|
77
|
-
'C:/msys64/mingw64/include/hamlib',
|
|
78
|
-
'C:\\msys64\\mingw64\\include\\hamlib',
|
|
79
|
-
process.env.MINGW_PREFIX + '/include/hamlib',
|
|
80
|
-
process.env.HAMLIB_ROOT + '/include/hamlib'
|
|
81
|
-
].filter(Boolean);
|
|
82
|
-
|
|
83
|
-
for (const includePath of possiblePaths) {
|
|
84
|
-
try {
|
|
85
|
-
if (fs.existsSync(includePath)) {
|
|
86
|
-
console.log(`✓ Hamlib headers found at: ${includePath}`);
|
|
87
|
-
return true;
|
|
88
|
-
}
|
|
89
|
-
} catch (e) {
|
|
90
|
-
// Continue to next path
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
// If all file checks fail, assume hamlib is available since we're in MinGW
|
|
95
|
-
// and the build process showed it was installed
|
|
96
|
-
console.log('Direct file checks failed, but assuming hamlib is available in MinGW environment');
|
|
97
|
-
return true;
|
|
98
|
-
}
|
|
99
|
-
} else {
|
|
100
|
-
// Check if hamlib is available in standard locations
|
|
101
|
-
const locations = [
|
|
102
|
-
'/usr/include/hamlib',
|
|
103
|
-
'/usr/local/include/hamlib',
|
|
104
|
-
'/opt/homebrew/include/hamlib'
|
|
105
|
-
];
|
|
106
|
-
return locations.some(location => fs.existsSync(location));
|
|
107
|
-
}
|
|
108
|
-
} catch (error) {
|
|
109
|
-
console.log('Error checking hamlib availability:', error.message);
|
|
110
|
-
// In MinGW environment, be more lenient since paths might be mapped differently
|
|
111
|
-
return isMinGWEnvironment();
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
/**
|
|
116
|
-
* Setup Windows dependencies if needed
|
|
117
|
-
*/
|
|
118
|
-
async function setupWindowsDependencies() {
|
|
119
|
-
// Skip if we're in MinGW environment - dependencies should already be set up
|
|
120
|
-
if (isMinGWEnvironment()) {
|
|
121
|
-
console.log('✓ MinGW environment detected, skipping Windows dependency setup...');
|
|
122
|
-
return checkHamlibAvailable();
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
// Check if dependencies are already set up
|
|
126
|
-
if (process.env.HAMLIB_ROOT && fs.existsSync(process.env.HAMLIB_ROOT)) {
|
|
127
|
-
console.log('✓ Windows dependencies already set up, skipping...');
|
|
128
|
-
return true;
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
console.log('Setting up Windows dependencies...');
|
|
132
|
-
|
|
133
|
-
try {
|
|
134
|
-
// Call PowerShell script instead of Node.js script
|
|
135
|
-
const scriptPath = path.join(__dirname, 'setup-windows-deps.ps1');
|
|
136
|
-
const command = `powershell -ExecutionPolicy Bypass -File "${scriptPath}"`;
|
|
137
|
-
|
|
138
|
-
console.log(`Running: ${command}`);
|
|
139
|
-
execSync(command, { stdio: 'inherit' });
|
|
140
|
-
|
|
141
|
-
console.log('✓ Windows dependencies setup completed');
|
|
142
|
-
return true;
|
|
143
|
-
} catch (error) {
|
|
144
|
-
console.error('✗ Failed to setup Windows dependencies:', error.message);
|
|
145
|
-
return false;
|
|
146
|
-
}
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
/**
|
|
150
|
-
* Try to build from source
|
|
151
|
-
*/
|
|
152
|
-
async function buildFromSource() {
|
|
153
|
-
console.log('Building hamlib from source...');
|
|
154
|
-
|
|
155
|
-
try {
|
|
156
|
-
// Setup Windows dependencies first if on Windows and not in MinGW environment
|
|
157
|
-
if (process.platform === 'win32' && !isMinGWEnvironment()) {
|
|
158
|
-
const success = await setupWindowsDependencies();
|
|
159
|
-
if (!success) {
|
|
160
|
-
throw new Error('Windows dependencies setup failed');
|
|
161
|
-
}
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
// For MinGW environment, verify hamlib is available
|
|
165
|
-
if (isMinGWEnvironment()) {
|
|
166
|
-
if (!checkHamlibAvailable()) {
|
|
167
|
-
throw new Error('Hamlib not found in MinGW environment. Please install hamlib first.');
|
|
168
|
-
}
|
|
169
|
-
console.log('✓ Hamlib found in MinGW environment');
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
// Build with node-gyp
|
|
173
|
-
execSync('node-gyp configure', { stdio: 'inherit' });
|
|
174
|
-
execSync('node-gyp build', { stdio: 'inherit' });
|
|
175
|
-
|
|
176
|
-
console.log('✓ Built hamlib successfully');
|
|
177
|
-
return true;
|
|
178
|
-
} catch (error) {
|
|
179
|
-
console.error('✗ Failed to build hamlib from source:', error.message);
|
|
180
|
-
return false;
|
|
181
|
-
}
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
/**
|
|
185
|
-
* Main installation logic
|
|
186
|
-
*/
|
|
187
|
-
async function main() {
|
|
188
|
-
console.log('Installing node-hamlib...');
|
|
189
|
-
|
|
190
|
-
try {
|
|
191
|
-
// Try to find prebuilt binary first
|
|
192
|
-
const prebuiltPath = path.join(__dirname, '..', 'prebuilds');
|
|
193
|
-
const platform = process.platform;
|
|
194
|
-
const arch = process.arch;
|
|
195
|
-
|
|
196
|
-
let targetDir = '';
|
|
197
|
-
if (platform === 'win32' && arch === 'x64') {
|
|
198
|
-
targetDir = 'win32-x64';
|
|
199
|
-
} else if (platform === 'linux' && arch === 'x64') {
|
|
200
|
-
targetDir = 'linux-x64';
|
|
201
|
-
} else if (platform === 'linux' && arch === 'arm64') {
|
|
202
|
-
targetDir = 'linux-arm64';
|
|
203
|
-
} else if (platform === 'darwin' && arch === 'arm64') {
|
|
204
|
-
targetDir = 'darwin-arm64';
|
|
205
|
-
}
|
|
206
|
-
|
|
207
|
-
const prebuiltBinary = path.join(prebuiltPath, targetDir, 'hamlib.node');
|
|
208
|
-
|
|
209
|
-
if (fs.existsSync(prebuiltBinary)) {
|
|
210
|
-
console.log('✓ Found prebuilt binary');
|
|
211
|
-
|
|
212
|
-
// Copy to build directory
|
|
213
|
-
const buildDir = path.join(__dirname, '..', 'build', 'Release');
|
|
214
|
-
if (!fs.existsSync(buildDir)) {
|
|
215
|
-
fs.mkdirSync(buildDir, { recursive: true });
|
|
216
|
-
}
|
|
217
|
-
|
|
218
|
-
const targetPath = path.join(buildDir, 'hamlib.node');
|
|
219
|
-
fs.copyFileSync(prebuiltBinary, targetPath);
|
|
220
|
-
|
|
221
|
-
console.log('✓ Installation completed successfully');
|
|
222
|
-
return;
|
|
223
|
-
}
|
|
224
|
-
|
|
225
|
-
console.log('⚠ No prebuilt binary found for your platform');
|
|
226
|
-
|
|
227
|
-
// Build from source
|
|
228
|
-
const success = await buildFromSource();
|
|
229
|
-
if (!success) {
|
|
230
|
-
throw new Error('Failed to build from source');
|
|
231
|
-
}
|
|
232
|
-
|
|
233
|
-
console.log('✓ Installation completed successfully');
|
|
234
|
-
|
|
235
|
-
} catch (error) {
|
|
236
|
-
console.error('❌ Installation failed!');
|
|
237
|
-
console.error('This could be due to:');
|
|
238
|
-
console.error('1. No prebuilt binary available for your platform');
|
|
239
|
-
console.error('2. Missing system dependencies (libhamlib-dev)');
|
|
240
|
-
console.error('3. Missing build tools (node-gyp, compiler)');
|
|
241
|
-
console.error('');
|
|
242
|
-
console.error('To resolve this:');
|
|
243
|
-
console.error('System dependencies:');
|
|
244
|
-
console.error(' Linux: sudo apt-get install libhamlib-dev');
|
|
245
|
-
console.error(' macOS: brew install hamlib');
|
|
246
|
-
console.error(' Windows: Install hamlib via vcpkg or from source');
|
|
247
|
-
console.error('');
|
|
248
|
-
console.error('Build tools:');
|
|
249
|
-
console.error(' npm install -g node-gyp');
|
|
250
|
-
console.error(' # Follow node-gyp platform-specific setup instructions');
|
|
251
|
-
|
|
252
|
-
process.exit(1);
|
|
253
|
-
}
|
|
254
|
-
}
|
|
255
|
-
|
|
256
|
-
// Run only if this script is called directly
|
|
257
|
-
if (require.main === module) {
|
|
258
|
-
main().catch(error => {
|
|
259
|
-
console.error('Installation failed:', error);
|
|
260
|
-
process.exit(1);
|
|
261
|
-
});
|
|
262
|
-
}
|