Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 20 additions & 2 deletions binding.gyp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
['OS=="win"', {
'javahome%': '<!(node findJavaHome.js)'
}],
['OS=="linux" or OS=="mac" or OS=="freebsd" or OS=="openbsd"', {
['OS=="linux" or OS=="mac" or OS=="freebsd" or OS=="openbsd" or OS=="solaris"' , {
'javahome%': '<!(node findJavaHome.js)'
}],
['OS=="mac"', {
Expand All @@ -35,7 +35,13 @@
}],
['OS=="linux" and (target_arch=="ppc64" or target_arch=="ppc")', {
'javalibdir%': "<!(h=\"`node findJavaHome.js`\" sh -c 'if [ -d \"$h/jre/lib/ppc64/classic\" ]; then echo $h/jre/lib/ppc64/classic; fi')"
}]
}],
['OS=="solaris" and target_arch=="ia32"', {
'javalibdir%': "<!(h=\"`node findJavaHome.js`\" sh -c 'if [ -d \"$h/jre/lib/i386/classic\" ]; then echo $h/jre/lib/i386/classic; else echo $h/jre/lib/i386/server; fi')"
}],
['OS=="solaris" and target_arch=="x64"', {
'javalibdir%': "<!(h=\"`node findJavaHome.js`\" sh -c 'if [ -d \"$h/jre/lib/amd64/classic\" ]; then echo $h/jre/lib/amd64/classic; else echo $h/jre/lib/amd64/server; fi')"
}],
]
},
'targets': [
Expand Down Expand Up @@ -77,6 +83,18 @@
]
}
],
['OS=="solaris"',
{
'include_dirs': [
'<(javahome)/include/solaris',
],
'libraries': [
'-L<(javahome)/jre/lib/<(arch)/server/',
'-Wl,-rpath,<(javahome)/jre/lib/<(arch)/server/',
'-ljvm'
]
}
],
['OS=="freebsd"',
{
'include_dirs': [
Expand Down
42 changes: 40 additions & 2 deletions postInstall.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,20 @@
var glob = require('glob');
var fs = require('fs');
var path = require('path');
var os = require('os');

require('find-java-home')(function(err, home){
var dll;
var dylib;
var so;
var so,soFiles;
var binary;

if(home){
dll = glob.sync('**/jvm.dll', {cwd: home})[0];
so = glob.sync('**/libjvm.so', {cwd: home})[0];
dylib = glob.sync('**/libjvm.dylib', {cwd: home})[0];
soFiles = glob.sync('**/libjvm.so', {cwd: home});
so = getCorrectSoForPlatform(soFiles);

binary = dll || dylib || so;

fs.writeFileSync(
Expand All @@ -25,3 +28,38 @@ require('find-java-home')(function(err, home){
);
}
});

function getCorrectSoForPlatform(soFiles){
var so = _getCorrectSoForPlatform(soFiles);
return removeDuplicateJre(so);
}

function removeDuplicateJre(filePath){
while(filePath.indexOf('jre/jre')>=0){
filePath = filePath.replace('jre/jre','jre');
}
return filePath;
}

function _getCorrectSoForPlatform(soFiles){

var architectureFolderNames = {
'ia32': 'i386',
'x64': 'amd64'
};

if(os.platform() != 'sunos')
return soFiles[0];

var requiredFolderName = architectureFolderNames[os.arch()];

for (var i = 0; i < soFiles.length; i++) {
var so = soFiles[i];

if(so.indexOf('server')>0)
if(so.indexOf(requiredFolderName)>0)
return so;
}

return soFiles[0];
}