Skip to content

Commit 534c5e3

Browse files
author
jjuzna
committed
support for prebuildify native binary
require does not start default loop trim down package size
1 parent 7debaf9 commit 534c5e3

File tree

7 files changed

+2752
-33
lines changed

7 files changed

+2752
-33
lines changed

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,5 @@ node-java.cbp
99
*.iml
1010
*.kdev4
1111
*/.kdev_include_paths
12+
jvm_dll_path.json
13+
*.tgz

.npmignore

+13
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,16 @@
11
/testIntegration
22
/.idea
33
/build
4+
jvm_dll_path.json
5+
*.tgz
6+
/.devcontainer
7+
/.vscode
8+
/docker
9+
/examples
10+
.travis.yml
11+
/test
12+
/test8
13+
/testAsyncOptions
14+
testJava.js
15+
testRunner.js
16+
testHelpers.js

lib/nodeJavaBridge.js

+6-14
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,17 @@
11
'use strict';
22

3-
process.env.PATH += require('../build/jvm_dll_path.json');
3+
process.env.PATH += require('../jvm_dll_path.json');
44

55
var _ = require('lodash');
66
var async = require('async');
77
var path = require('path');
88
var fs = require('fs');
9-
var binaryPath = null;
10-
try {
11-
if(fs.statSync && fs.statSync(path.join(__dirname, "../build/Debug/nodejavabridge_bindings.node")).isFile()) {
12-
binaryPath = path.resolve(path.join(__dirname, "../build/Debug/nodejavabridge_bindings.node"));
13-
console.log('****** NODE-JAVA RUNNING IN DEBUG MODE ******');
14-
}
15-
} catch(e) {
16-
// do nothing fs.statSync just couldn't find the file
17-
}
18-
if (!binaryPath) {
19-
binaryPath = path.resolve(path.join(__dirname, "../build/Release/nodejavabridge_bindings.node"));
20-
}
21-
var bindings = require(binaryPath);
229

10+
var ngb = require("node-gyp-build");
11+
var nativeLoader = new ngb.Loader(path.join(__dirname, ".."));
12+
13+
var binaryPath = nativeLoader.getNativePath();
14+
var bindings = nativeLoader.execRequire();
2315
var java = module.exports = new bindings.Java();
2416
java.classpath.push(path.resolve(__dirname, "../commons-lang3-node-java.jar"));
2517
java.classpath.push(path.resolve(__dirname, __dirname, "../src-java"));

0 commit comments

Comments
 (0)