Compute a library path from the native software model
Previously we were repeating the library path twice, but that's not good for long-term maintenance. That being said, extracting this information from the depths of the native software model seems *far* more complex than it should be. I had hoped for something nicer in response to <https://discuss.gradle.org/t/compute-wl-rpath-flag-suitable-for-native-shared-library/25278>, but so far there's nothing.
This commit is contained in:
parent
50bed1cbe8
commit
817166c128
|
@ -69,11 +69,22 @@ model {
|
|||
exportedHeaders.srcDirs = ["$cSourceDir/include"]
|
||||
lib library: 'jdk'
|
||||
}
|
||||
binaries.all {
|
||||
binaries {
|
||||
withType(StaticLibraryBinarySpec) {
|
||||
buildable = false
|
||||
}
|
||||
withType(SharedLibraryBinarySpec) {
|
||||
switch ("$targetPlatform.operatingSystem.name/$targetPlatform.architecture.name") {
|
||||
case 'linux/x86-64':
|
||||
// TODO: compute path on following line from 'jdk' library properties somehow
|
||||
linker.args '-Wl,-rpath', "$currentJavaHome/jre/lib/amd64/server"
|
||||
$
|
||||
.repositories['libs']
|
||||
.resolveLibrary('jdk')
|
||||
.binaries
|
||||
.withType(SharedLibraryBinary)
|
||||
.findResults { it.sharedLibraryLinkFile }
|
||||
*.parentFile
|
||||
.each { linker.args "-Wl,-rpath=$it" }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue