Commit a66ac8c
feat: add pure C shim layer for cross-compiler ABI safety (#1)
* feat: add pure C shim layer for cross-compiler ABI safety on Windows
Introduce a shim layer between the Node.js addon (MSVC) and Hamlib
(MinGW), eliminating the MSVC/MinGW struct layout incompatibility
that caused immediate crashes on Windows when importing the module.
Architecture:
Node.js → hamlib.node (C++ NAPI, MSVC) → hamlib_shim (pure C) → libhamlib
Key changes:
- New src/shim/hamlib_shim.{h,c}: ~95 pure C wrapper functions with
opaque handle pattern, replacing all direct Hamlib struct accesses
- Rewrite src/hamlib.cpp to use shim_rig_* functions exclusively
(no conditional compilation, all platforms use same code path)
- New scripts/build-shim.js: cross-platform shim build script
(static .a on Linux/macOS, DLL on Windows via MinGW)
- Simplified binding.gyp: removed complex Hamlib path search logic,
pthread dependency, and MinGW conditional compilation for Windows
- Updated CI: added MSYS2/MinGW setup for Windows shim DLL build
- Removed obsolete hamlib_compat.h and 7 temporary debug scripts
Verified on Windows: module loads and all 84 API methods work correctly.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* fix: separate shim build flow for Windows vs Unix in CI
On Unix, build-all.js handles hamlib setup + shim build + addon build
in sequence. On Windows, shim DLL is built separately via MSYS2 before
the MSVC addon build.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* fix: CI Windows shim build - use pwsh shell with MINGW_CC env var
The MSYS2 shell doesn't have Node.js in PATH. Use pwsh shell instead
and set MINGW_CC to point to the MSYS2 MinGW gcc. Also add fail-fast:
false to allow all platform builds to complete independently.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* fix: move shim output to shim-build/ to survive prebuildify rebuild
prebuildify internally runs node-gyp rebuild which cleans the build/
directory, deleting the previously built shim .a/.lib files. Moving
shim output to a separate shim-build/ directory prevents this.
Also adds pip install setuptools to CI for Python 3.12 compatibility
with node-gyp 9.4.1 (distutils was removed in Python 3.12).
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* fix: copy all libhamlib.so* variants for Linux bundling
The dynamic linker needs the soname-versioned file (e.g., libhamlib.so.5)
but the bundler was only copying a single file. Now copies all
libhamlib.so* files from the lib directory, resolving symlinks.
Also improved findHamlibSo() to search for any version (so.4, so.5, etc.)
instead of hardcoding so.4.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* test: add CI functional test for compiled binary validation
Adds test_ci_functional.js that validates the compiled binary actually
works by exercising core API operations against the Hamlib Dummy device
(Model 1). Tests VFO, frequency, PTT, serial config, power control,
and instance lifecycle - no rigctld or hardware needed.
CI now runs both test_loader.js (API existence) and test_ci_functional.js
(API functionality) to ensure binaries are usable.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* ci: add automated npm publish workflow on tag push
Replaces the manual package/release flow with automated publishing:
- Tag push (v*) triggers: build → validate → npm publish → GitHub Release
- Validates all 5 platform prebuilds before publishing
- Uses NPM_TOKEN secret for npm authentication
- Creates GitHub Release with per-platform tar.gz archives
- Removes cleanup job (artifacts auto-expire)
- Adds PUBLISHING.md with release instructions
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* docs: rewrite CLAUDE.md for shim-layer architecture
Rewrites the project guide to reflect the current shim-layer
architecture. Includes clear step-by-step instructions for adding
new API methods across all 4 layers (shim → C++ → JS → TS).
Condensed from 333 to 131 lines while retaining all essential info.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>1 parent d9583c4 commit a66ac8c
15 files changed
Lines changed: 3399 additions & 1773 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
| 1 | + | |
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
5 | | - | |
6 | | - | |
| 5 | + | |
| 6 | + | |
7 | 7 | | |
8 | | - | |
| 8 | + | |
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
14 | | - | |
15 | 14 | | |
16 | 15 | | |
| 16 | + | |
17 | 17 | | |
18 | 18 | | |
19 | 19 | | |
| |||
38 | 38 | | |
39 | 39 | | |
40 | 40 | | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
41 | 44 | | |
42 | 45 | | |
43 | 46 | | |
| |||
76 | 79 | | |
77 | 80 | | |
78 | 81 | | |
79 | | - | |
| 82 | + | |
80 | 83 | | |
81 | | - | |
82 | | - | |
83 | | - | |
84 | | - | |
85 | | - | |
86 | | - | |
87 | | - | |
88 | | - | |
89 | | - | |
90 | | - | |
91 | | - | |
92 | | - | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
93 | 89 | | |
94 | 90 | | |
95 | 91 | | |
96 | 92 | | |
97 | 93 | | |
98 | 94 | | |
99 | 95 | | |
100 | | - | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
101 | 100 | | |
102 | 101 | | |
| 102 | + | |
| 103 | + | |
103 | 104 | | |
104 | | - | |
105 | | - | |
106 | | - | |
107 | | - | |
108 | | - | |
109 | | - | |
110 | | - | |
111 | | - | |
112 | | - | |
113 | | - | |
114 | | - | |
115 | | - | |
116 | | - | |
117 | | - | |
118 | | - | |
119 | | - | |
120 | | - | |
121 | | - | |
| 105 | + | |
| 106 | + | |
122 | 107 | | |
123 | | - | |
124 | | - | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
125 | 111 | | |
126 | | - | |
| 112 | + | |
127 | 113 | | |
128 | | - | |
129 | | - | |
130 | | - | |
| 114 | + | |
131 | 115 | | |
132 | | - | |
133 | | - | |
| 116 | + | |
134 | 117 | | |
135 | | - | |
136 | | - | |
137 | | - | |
| 118 | + | |
| 119 | + | |
138 | 120 | | |
139 | | - | |
| 121 | + | |
140 | 122 | | |
141 | 123 | | |
142 | | - | |
143 | | - | |
144 | | - | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
145 | 127 | | |
146 | | - | |
| 128 | + | |
| 129 | + | |
147 | 130 | | |
148 | 131 | | |
149 | | - | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
150 | 135 | | |
151 | 136 | | |
152 | 137 | | |
153 | | - | |
154 | | - | |
| 138 | + | |
155 | 139 | | |
156 | 140 | | |
| 141 | + | |
157 | 142 | | |
158 | | - | |
159 | | - | |
| 143 | + | |
160 | 144 | | |
161 | | - | |
| 145 | + | |
162 | 146 | | |
163 | 147 | | |
164 | 148 | | |
165 | 149 | | |
166 | | - | |
167 | | - | |
168 | | - | |
169 | | - | |
170 | | - | |
171 | | - | |
| 150 | + | |
| 151 | + | |
172 | 152 | | |
173 | 153 | | |
174 | | - | |
175 | | - | |
176 | | - | |
177 | | - | |
178 | | - | |
179 | | - | |
180 | | - | |
| 154 | + | |
181 | 155 | | |
182 | | - | |
183 | | - | |
184 | | - | |
185 | | - | |
186 | | - | |
187 | | - | |
188 | | - | |
189 | | - | |
190 | | - | |
191 | | - | |
192 | | - | |
193 | | - | |
194 | | - | |
195 | | - | |
| 156 | + | |
| 157 | + | |
196 | 158 | | |
| 159 | + | |
| 160 | + | |
197 | 161 | | |
198 | | - | |
199 | | - | |
| 162 | + | |
200 | 163 | | |
201 | | - | |
202 | | - | |
203 | | - | |
204 | | - | |
205 | | - | |
206 | | - | |
207 | | - | |
208 | | - | |
209 | | - | |
210 | | - | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
211 | 167 | | |
212 | 168 | | |
213 | | - | |
214 | | - | |
215 | | - | |
216 | | - | |
217 | | - | |
218 | | - | |
219 | | - | |
220 | | - | |
221 | | - | |
222 | | - | |
223 | | - | |
224 | | - | |
225 | | - | |
226 | | - | |
227 | | - | |
228 | | - | |
229 | | - | |
230 | | - | |
231 | | - | |
232 | | - | |
233 | | - | |
234 | | - | |
235 | | - | |
236 | | - | |
237 | | - | |
238 | | - | |
239 | | - | |
240 | | - | |
241 | | - | |
242 | | - | |
243 | | - | |
244 | | - | |
245 | | - | |
246 | | - | |
247 | | - | |
248 | | - | |
249 | | - | |
250 | | - | |
251 | | - | |
252 | | - | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
| 3 | + | |
3 | 4 | | |
4 | 5 | | |
5 | 6 | | |
| |||
50 | 51 | | |
51 | 52 | | |
52 | 53 | | |
53 | | - | |
| 54 | + | |
| 55 | + | |
0 commit comments