Skip to content

Commit

Permalink
Adding support for node-webkit using nw-gyp.
Browse files Browse the repository at this point in the history
  • Loading branch information
saboya committed Jan 28, 2018
1 parent b0670b9 commit b7b4b00
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 3 deletions.
3 changes: 2 additions & 1 deletion gyp.js
Expand Up @@ -4,7 +4,8 @@ var osenv = require('osenv')

var backends = {
'node-gyp': require('node-gyp')(),
'node-ninja': require('node-ninja')()
'node-ninja': require('node-ninja')(),
'nw-gyp': require('nw-gyp')()
}

// Use system installed node-gyp for other JS engines
Expand Down
2 changes: 2 additions & 0 deletions gypbuild.js
Expand Up @@ -25,6 +25,8 @@ function runGyp (opts, target, cb) {
if (opts.runtime === 'electron') {
args.push('--runtime=electron')
args.push('--dist-url=https://atom.io/download/electron')
} else if (opts.runtime === 'node-webkit') {
args.push('--runtime=node-webkit')
}
if (opts.debug) args.push('--debug')

Expand Down
3 changes: 2 additions & 1 deletion package.json
Expand Up @@ -27,11 +27,12 @@
"github-from-package": "0.0.0",
"minimist": "^1.1.2",
"mkdirp": "^0.5.1",
"node-abi": "^2.0.0",
"node-abi": "git+https://github.com/saboya/node-abi.git#node-webkit",
"node-gyp": "^3.0.3",
"node-ninja": "^1.0.1",
"noop-logger": "^0.1.0",
"npmlog": "^4.0.1",
"nw-gyp": "^3.6.3",
"osenv": "^0.1.4",
"rc": "^1.0.3",
"tar-stream": "^1.2.1",
Expand Down
4 changes: 4 additions & 0 deletions prebuild.js
Expand Up @@ -13,6 +13,10 @@ function prebuild (opts, target, runtime, callback) {
opts.target = target
opts.runtime = runtime

if (opts.runtime === 'node-webkit') {
opts.backend = 'nw-gyp'
}

var buildLogMessage = 'Preparing to prebuild ' + pkg.name + '@' + pkg.version + ' for ' + runtime + ' ' + target + ' on ' + opts.platform + '-' + opts.arch + ' using ' + opts.backend
if (opts.libc && opts.libc.length > 0) buildLogMessage += 'using libc ' + opts.libc
buildLog(buildLogMessage)
Expand Down
15 changes: 15 additions & 0 deletions test/integration-test.js
Expand Up @@ -20,3 +20,18 @@ test('can prebuild a native module for electron', function (t) {
t.end()
})
})

test('can prebuild a native module for node-webkit', function (t) {
if (process.versions.modules === '11') {
console.log('Skipping test on node 0.10!')
return t.end()
}
rm.sync(path.join(cwd, 'prebuilds'))
var file = 'native-v1.0.0-node-webkit-v59-' + process.platform + '-' + process.arch + '.tar.gz'
var prebuild = path.join(cwd, 'prebuilds', file)
exec('npm run prebuild-node-webkit', { cwd: cwd }, function (error, stdout, stderr) {
t.equal(error, null)
t.equal(fs.existsSync(prebuild), true)
t.end()
})
})
3 changes: 2 additions & 1 deletion test/native-module/package.json
Expand Up @@ -3,6 +3,7 @@
"version": "1.0.0",
"main": "./index.js",
"scripts": {
"prebuild": "node ../../bin.js --target 1.4.11 --runtime electron"
"prebuild": "node ../../bin.js --target 1.4.11 --runtime electron",
"prebuild-node-webkit": "node ../../bin.js --target 0.26.6 --runtime node-webkit"
}
}

0 comments on commit b7b4b00

Please sign in to comment.