Find JVM shared library better across versions and operating systems
We now use "-rpath" on both Linux and macOS. This linker flag sets the ELF RPATH on Linux, and the "@rpath" attribute on macOS, but effectively it's doing the same thing, and that same thing is exactly what we want. I think. On Linux, we also now look for the JVM shared library in three different places. The library has moved between Java 8 and 9, and even on Java 9 it goes in a different place on Fedora 28 versus Ubuntu 16.04.
This commit is contained in:
parent
24151e7422
commit
fbac524a02
|
@ -42,11 +42,9 @@ model {
|
|||
switch (targetPlatform.operatingSystem.name) {
|
||||
case 'linux':
|
||||
headers.srcDirs "$jniIncludeDir/linux"
|
||||
switch (targetPlatform.architecture.name) {
|
||||
case 'x86-64':
|
||||
sharedLibraryLinkFile = file("$currentJavaHome/jre/lib/amd64/server/libjvm.so")
|
||||
break
|
||||
}
|
||||
def subdirs = ['jre/lib/amd64/server', 'lib/amd64/server', 'lib/server']
|
||||
def candidates = subdirs.collect { file("$currentJavaHome/$it/libjvm.so") }
|
||||
sharedLibraryLinkFile = candidates.find { it.exists() }
|
||||
break
|
||||
case 'osx':
|
||||
headers.srcDirs "$jniIncludeDir/darwin"
|
||||
|
@ -79,17 +77,11 @@ model {
|
|||
buildable = false
|
||||
}
|
||||
withType(SharedLibraryBinarySpec) {
|
||||
switch ("$targetPlatform.operatingSystem.name/$targetPlatform.architecture.name") {
|
||||
case 'linux/x86-64':
|
||||
$
|
||||
.repositories['libs']
|
||||
.resolveLibrary('jdk')
|
||||
.binaries
|
||||
.withType(SharedLibraryBinary)
|
||||
.findResults { it.sharedLibraryLinkFile }
|
||||
*.parentFile
|
||||
.each { linker.args "-Wl,-rpath=$it" }
|
||||
}
|
||||
def libDir = $.repositories['libs'].resolveLibrary('jdk')
|
||||
.binaries.withType(SharedLibraryBinary)
|
||||
.find { it.targetPlatform.name == targetPlatform.name }
|
||||
.sharedLibraryLinkFile.parent
|
||||
linker.args "-Wl,-rpath,$libDir"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue