Skip to content

Commit

Permalink
Build macos package with dylib
Browse files Browse the repository at this point in the history
  • Loading branch information
intrueder committed Dec 16, 2020
1 parent c93cd2e commit f362812
Show file tree
Hide file tree
Showing 5 changed files with 71 additions and 9 deletions.
36 changes: 34 additions & 2 deletions .github/workflows/npmpublish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,27 @@ on:
jobs:
npm-publish:
runs-on: windows-latest
needs: [prebuild-macos]

steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Set up Node
uses: actions/setup-node@master
with:
node-version: '14.x'
- run: npm ci
- run: npm run prebuild
- name: npm install and build
run: |
npm ci
npm run prebuild
- name: Download artifact
uses: actions/download-artifact@v2
with:
name: prebuilds
- name: Unpack and remove artifact
run: |
powershell Expand-Archive -Path prebuild_macos.zip -DestinationPath .
del prebuild_macos.zip
- name: Publish if version has been updated
uses: intrueder/npm-publish@master
with:
Expand All @@ -25,3 +37,23 @@ jobs:
env:
NODE_AUTH_TOKEN: ${{secrets.NPM_AUTH_TOKEN}}
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}

prebuild-macos:
runs-on: macos-10.15
steps:
- uses: actions/checkout@v2
- name: Set up Node
uses: actions/setup-node@master
with:
node-version: '14.x'
- name: npm install and build
run: |
npm ci
npm run prebuild-mac
- name: Pack artifact
run: zip -r prebuild_macos prebuilds
- name: Upload artifact
uses: actions/upload-artifact@v2
with:
name: prebuilds
path: prebuild_macos.zip
1 change: 1 addition & 0 deletions .npmignore
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,4 @@ test.js
*.md
CUESDK/lib
CUESDK/redist
CUESDK/mac
Binary file added CUESDK/mac/CUESDK.dylib
Binary file not shown.
42 changes: 35 additions & 7 deletions binding.gyp
Original file line number Diff line number Diff line change
@@ -1,19 +1,28 @@
{
"variables": {
"module_name%": "cuesdk",
"prebuilds_path%": "<(module_root_dir)/prebuilds/win32-<(target_arch)"
"win_prebuild_path%": "<(module_root_dir)/prebuilds/win32-<(target_arch)",
"mac_prebuild_path%": "<(module_root_dir)/prebuilds/darwin-<(target_arch)"
},
"targets": [
{
"target_name": "<(module_name)",
"sources": ["src/CorsairSdk.cc"],
"sources": [
"src/CorsairSdk.cc"
],
"include_dirs": [
"<!@(node -p \"require('node-addon-api').include\")",
"<(module_root_dir)/CUESDK/include"
],
"cflags!": ["-fno-exceptions"],
"cflags_cc!": ["-fno-exceptions"],
"defines": ["NAPI_DISABLE_CPP_EXCEPTIONS"],
"cflags!": [
"-fno-exceptions"
],
"cflags_cc!": [
"-fno-exceptions"
],
"defines": [
"NAPI_DISABLE_CPP_EXCEPTIONS"
],
"conditions": [
[
"OS=='win'",
Expand Down Expand Up @@ -43,7 +52,7 @@
],
"copies": [
{
"destination": "<(prebuilds_path)",
"destination": "<(win_prebuild_path)",
"files": [
"<(module_root_dir)/CUESDK/redist/<(sdk_arch_path)/CUESDK<(sdk_arch)_2017.dll"
]
Expand All @@ -54,12 +63,31 @@
[
"OS=='mac'",
{
"libraries": [
"<(module_root_dir)/CUESDK/mac/CUESDK.dylib",
"-Wl,-rpath,<(module_root_dir)"
],
"link_settings": {
"libraries": ["-F/Library/Frameworks", "-framework CUESDK"]
"libraries": [
"-Wl,-rpath,@loader_path",
"-Wl,-rpath,@loader_path/.."
]
}
}
]
]
},
{
"target_name": "action_before_build",
"type": "none",
"copies": [
{
"destination": "<(mac_prebuild_path)",
"files": [
"<(module_root_dir)/CUESDK/mac/CUESDK.dylib"
]
}
]
}
]
}
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"scripts": {
"install": "node-gyp-build",
"prebuild": "prebuildify --napi --arch ia32 && prebuildify --napi --arch x64",
"prebuild-mac": "prebuildify --napi --arch x64",
"test": "node test"
},
"dependencies": {
Expand Down

0 comments on commit f362812

Please sign in to comment.