Skip to content

Commit

Permalink
fix: build native module on Windows only (#29)
Browse files Browse the repository at this point in the history
  • Loading branch information
derevnjuk committed Aug 30, 2023
1 parent 439be6e commit 1884ce2
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 33 deletions.
16 changes: 0 additions & 16 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,28 +15,12 @@ jobs:
fail-fast: false
matrix:
include:
- os: macos-11
node_arch: x64
command: build:gyp
args: --arch x64+arm64
- os: windows-2019
node_arch: x86
command: build:gyp
- os: windows-2019
node_arch: x64
command: build:gyp
- os: ubuntu-20.04
command: build:gyp-cross
args: -i centos7-devtoolset7 -i alpine
- os: ubuntu-20.04
command: build:gyp-cross
args: -i linux-arm64-lts -i linux-armv7 -i linux-armv6
- os: ubuntu-20.04
command: build:gyp-cross
args: --tag-libc musl -i linux-arm64-musl
- os: ubuntu-20.04
command: build:gyp-cross
args: -i android-arm64 -i android-armv7
steps:
- uses: actions/checkout@v3
with:
Expand Down
16 changes: 0 additions & 16 deletions binding.gyp
Original file line number Diff line number Diff line change
Expand Up @@ -9,22 +9,6 @@
"<!(node -e \"require('nan')\")"
],
"conditions": [
[
"OS==\"mac\"",
{
"xcode_settings": {
"MACOSX_DEPLOYMENT_TARGET": "10.7",
"OTHER_CFLAGS": [
"-arch x86_64",
"-arch arm64"
],
"OTHER_LDFLAGS": [
"-arch x86_64",
"-arch arm64"
]
}
}
],
[
"OS==\"win\"",
{
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@
"semantic-release": "semantic-release",
"build:gyp": "prebuildify --strip --target 10.24.1 --target 12.22.12 --target 14.21.3 --target 16.20.2 --target 18.17.1 --target 19.9.0 --target 20.5.1",
"build:gyp-cross": "prebuildify-cross --strip --target 10.24.1 --target 12.22.12 --target 14.21.3 --target 16.20.2 --target 18.17.1 --target 19.9.0 --target 20.5.1",
"install": "node-gyp-build"
"native_install": "node-gyp-build",
"install": "node scripts/install.js"
}
}
38 changes: 38 additions & 0 deletions scripts/install.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
var os = require('os');
var path = require('path');
var child = require('child_process');

if (os.platform() === 'win32') {
var npmProcess = child.spawn('npm', ['run', 'native_install'], {
input: 'Windows detected. Installing native module.',
stdio: 'inherit',
cwd: path.resolve(__dirname, '..'),
env: process.env,
windowsHide: true,
shell: true
});

// Handle child process exit
npmProcess.on('exit', function (code, signal) {
if (code !== null) {
console.log(`Child process exited with code ${code}`);
} else if (signal !== null) {
console.log(`Child process was terminated by signal ${signal}`);
}
});

// Handle child process errors
npmProcess.on('error', function (error) {
console.error('Error occurred:', error);
});

// Forward parent process signals to the child process
function forwardSignal(signal) {
if (npmProcess.pid) {
npmProcess.kill(signal);
}
}

process.on('SIGTERM', forwardSignal);
process.on('SIGINT', forwardSignal);
}

0 comments on commit 1884ce2

Please sign in to comment.