Skip to content

Commit

Permalink
feat: support Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
aelesbao committed Nov 13, 2023
1 parent bc0dee9 commit f39c137
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 4 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/prebuild.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ jobs:
runner:
- ubuntu-latest
- macos-12
- windows-2019
runs-on: ${{ matrix.runner }}
steps:
- uses: actions/checkout@v3
Expand All @@ -37,6 +38,8 @@ jobs:
run: |
if [[ "$RUNNER_OS" == "macOS" ]]; then
npm run build:arm64 && npm run build:x64
elif [[ "$RUNNER_OS" == "win" ]]; then
npm run build:win
else
npm run build
npm test
Expand Down
8 changes: 8 additions & 0 deletions binding.gyp
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,14 @@
"<!(pwd)/out/darwin-arm64/keyring.a"
],
}],
['OS=="win"', {
'defines': [
'_MSC_VER=1935',
],
"libraries": [
"<!(cd)/out/win/keyring.lib"
],
}]
]
}
]
Expand Down
6 changes: 6 additions & 0 deletions build.cmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
go build -v -trimpath -buildmode=c-archive -o ./build/win/keyring.dll ./src/go

copy ./build/win/keyring.h ./build/keyring.h

gendef ./build/win/keyring.dll
dlltool --input-def ./build/win/keyring.def --output-lib ./build/win/keyring.lib
6 changes: 2 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,11 @@
"build": "prebuildify --napi --strip --preinstall=./build.sh",
"build:x64": "prebuildify --napi --strip --preinstall='./build.sh amd64' --arch=x64",
"build:arm64": "prebuildify --napi --strip --preinstall='./build.sh arm64' --arch=arm64",
"build:win": "prebuildify --napi --strip --preinstall=build.cmd",
"install": "node-gyp-build",
"test": "node --napi-modules ./test/index.js"
},
"engines": {
"node": ">=16"
},
"os": [
"!win32"
]
}
}

0 comments on commit f39c137

Please sign in to comment.