mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-07-06 03:31:43 +00:00
Improve JNI loading efficiency (#1224)
A hash is stored for each native library with the name libraryName.hash. If the library is not found on the system search path, it is extracted to a cache directory. Extracted libraries are named with the hash appended, so the library will not be re-extracted if one with the same hash already exists. Hashing without the hash file requires double traversing if the file is not in the cache, but it is still faster than creating a new file in most cases. This won't be needed after opencv is updated to provide a hash as well.
This commit is contained in:
committed by
Peter Johnson
parent
cbb62fb98f
commit
00c2cd7dab
@@ -268,9 +268,7 @@ ext.createAllCombined = { list, name, base, type, project ->
|
||||
duplicatesStrategy = 'exclude'
|
||||
|
||||
list.each {
|
||||
it.outputs.files.each {
|
||||
from project.zipTree(it)
|
||||
}
|
||||
from project.zipTree(it.archivePath)
|
||||
dependsOn it
|
||||
}
|
||||
}
|
||||
@@ -289,7 +287,7 @@ ext.includeStandardZipFormat = { task, value ->
|
||||
value.each { binary ->
|
||||
if (binary.buildable) {
|
||||
if (binary instanceof SharedLibraryBinarySpec) {
|
||||
task.dependsOn binary.buildTask
|
||||
task.dependsOn binary.tasks.link
|
||||
task.from(new File(binary.sharedLibraryFile.absolutePath + ".debug")) {
|
||||
into getPlatformPath(binary) + '/shared'
|
||||
}
|
||||
@@ -306,7 +304,7 @@ ext.includeStandardZipFormat = { task, value ->
|
||||
into getPlatformPath(binary) + '/shared'
|
||||
}
|
||||
} else if (binary instanceof StaticLibraryBinarySpec) {
|
||||
task.dependsOn binary.buildTask
|
||||
task.dependsOn binary.tasks.createStaticLib
|
||||
task.from(binary.staticLibraryFile) {
|
||||
into getPlatformPath(binary) + '/static'
|
||||
}
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import java.security.MessageDigest
|
||||
apply plugin: 'maven-publish'
|
||||
|
||||
def pubVersion
|
||||
@@ -81,7 +82,16 @@ model {
|
||||
value.each { binary ->
|
||||
if (binary.buildable) {
|
||||
if (binary instanceof SharedLibraryBinarySpec) {
|
||||
task.dependsOn binary.buildTask
|
||||
task.dependsOn binary.tasks.link
|
||||
def hashFile = new File(binary.sharedLibraryFile.parentFile.absolutePath, "${binary.component.baseName}.hash")
|
||||
task.outputs.file(hashFile)
|
||||
task.inputs.file(binary.sharedLibraryFile)
|
||||
task.from(hashFile) {
|
||||
into getPlatformPath(binary)
|
||||
}
|
||||
task.doFirst {
|
||||
hashFile.text = MessageDigest.getInstance("MD5").digest(binary.sharedLibraryFile.bytes).encodeHex().toString()
|
||||
}
|
||||
task.from(binary.sharedLibraryFile) {
|
||||
into getPlatformPath(binary)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user