Skip to content

Commit 7505669

Browse files
committed
feat: implement cross-platform dependency bundling scripts for macOS and Linux
1 parent 44917e6 commit 7505669

File tree

10 files changed

+592
-1534
lines changed

10 files changed

+592
-1534
lines changed

.github/workflows/build.yml

Lines changed: 18 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ jobs:
6969
arch: arm64
7070
target: darwin-arm64
7171
hamlib_install: |
72-
brew install hamlib
72+
brew install hamlib dylibbundler
7373
pip3 install setuptools --break-system-packages || true
7474
7575
runs-on: ${{ matrix.os }}
@@ -111,17 +111,6 @@ jobs:
111111
- name: Install Node.js dependencies (skip scripts)
112112
run: npm ci --ignore-scripts
113113

114-
- name: Ensure node-gyp path (Windows)
115-
if: matrix.os == 'windows-latest'
116-
run: |
117-
$ng = Join-Path $env:GITHUB_WORKSPACE 'scripts\node-gyp-win.cmd'
118-
if (!(Test-Path $ng)) { throw "node-gyp not found in node_modules/.bin" }
119-
Write-Host "Using node-gyp at: $ng"
120-
"PREBUILD_NODE_GYP=$ng" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
121-
"PREBUILD_PLATFORM=win32" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
122-
"PREBUILD_ARCH=x64" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
123-
# PREBUILD_SHELL is not used by prebuildify's build phase; our wrapper handles Windows spawning
124-
125114
- name: Setup Developer Command Prompt (Windows)
126115
if: matrix.os == 'windows-latest'
127116
uses: ilammy/msvc-dev-cmd@v1
@@ -191,39 +180,29 @@ jobs:
191180
exit 1
192181
}
193182
194-
- name: Generate prebuilds and bundle hamlib (Windows)
183+
- name: Generate prebuilds (Windows)
195184
if: matrix.os == 'windows-latest'
196-
run: |
197-
node scripts/run-prebuildify.js
198-
node scripts/bundle-hamlib.js
185+
run: npm run prebuild
199186

200-
- name: Verify node.napi.node dependencies (Windows)
187+
- name: Bundle dependencies (Windows)
201188
if: matrix.os == 'windows-latest'
202-
shell: pwsh
203-
run: |
204-
Write-Host "`n=== Verifying node.napi.node dependencies ===`n"
205-
$nodeBinary = "D:\a\node-hamlib\node-hamlib\prebuilds\win32-x64\node.napi.node"
189+
run: node scripts/bundle-windows.js
206190

207-
if (Test-Path $nodeBinary) {
208-
Write-Host "Analyzing $nodeBinary`n"
209-
dumpbin /dependents $nodeBinary
210-
} else {
211-
Write-Error "node.napi.node not found!"
212-
exit 1
213-
}
191+
- name: Generate prebuilds (macOS)
192+
if: matrix.os == 'macos-latest'
193+
run: npm run prebuild
214194

215-
Write-Host "`n=== Analyzing libhamlib-4.dll dependencies ===`n"
216-
$hamlibDll = Join-Path $env:HAMLIB_ROOT 'bin\libhamlib-4.dll'
217-
if (Test-Path $hamlibDll) {
218-
Write-Host "Analyzing $hamlibDll`n"
219-
dumpbin /dependents $hamlibDll
220-
} else {
221-
Write-Warning "libhamlib-4.dll not found in HAMLIB_ROOT/bin"
222-
}
195+
- name: Bundle dependencies (macOS)
196+
if: matrix.os == 'macos-latest'
197+
run: bash scripts/bundle-macos.sh
198+
199+
- name: Generate prebuilds (Linux)
200+
if: startsWith(matrix.os, 'ubuntu')
201+
run: npm run prebuild
223202

224-
- name: Generate prebuilds and bundle hamlib (Non-Windows)
225-
if: matrix.os != 'windows-latest'
226-
run: npm run prebuild:bundle
203+
- name: Bundle dependencies (Linux)
204+
if: startsWith(matrix.os, 'ubuntu')
205+
run: bash scripts/bundle-linux.sh
227206

228207
- name: List generated prebuilds
229208
shell: bash
@@ -234,10 +213,6 @@ jobs:
234213
- name: Verify dependencies (All platforms)
235214
run: node scripts/verify-dependencies.js
236215

237-
- name: Verify Linux RUNPATH (Linux only - detailed check)
238-
if: startsWith(matrix.os, 'ubuntu')
239-
run: node scripts/verify-linux-rpath.js
240-
241216
# 上传每个平台的预编译产物
242217
- name: Upload platform prebuilds artifact
243218
uses: actions/upload-artifact@v4

package.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,10 @@
4545
"test:network": "node test/test_network.js",
4646
"prebuild": "prebuildify --napi --strip",
4747
"prepare": "",
48-
"bundle": "node scripts/bundle-hamlib.js",
49-
"fix-rpath": "node scripts/fix-linux-rpath.js",
50-
"prebuild:bundle": "npm run prebuild && npm run bundle && npm run fix-rpath"
48+
"bundle:macos": "bash scripts/bundle-macos.sh",
49+
"bundle:linux": "bash scripts/bundle-linux.sh",
50+
"bundle:windows": "node scripts/bundle-windows.js",
51+
"verify": "node scripts/verify-dependencies.js"
5152
},
5253
"dependencies": {
5354
"node-addon-api": "^4.3.0",

0 commit comments

Comments
 (0)