Use a different path for zstd natives

This commit is contained in:
s809
2025-12-15 11:21:28 +05:00
parent bcb442e38d
commit 0c45c76ff8
19 changed files with 19 additions and 8 deletions
+5 -8
View File
@@ -372,18 +372,15 @@ subprojects { p ->
// ZStd // ZStd
// librariesLocation isn't used because it's too long for replacing paths in native libraries // librariesLocation isn't used because it's too long for replacing paths in native libraries
// Allowing strings larger than the original string would require shifting the entire binary's contents // Allowing strings larger than the original string would require shifting the entire binary's contents
relocate "com.github.luben", "dhcomgithubluben", { relocate "com.github.luben", "dhcomgithubluben"
exclude "aix.ppc64/**" relocate "libzstd-jni", "libzstd-jni_dh"
exclude "darwin/**" relocate "zstd-jni", "zstd-jni_dh"
exclude "freebsd/**"
exclude "linux/**"
exclude "win/**"
}
transform(NativeTransformer) { transform(NativeTransformer) {
rootDir = project.rootDir rootDir = project.rootDir
matchFiles { it.contains("libzstd-jni") && !it.contains("ppc64") } matchFiles { it.contains("libzstd-jni") && !it.contains("aix/ppc64") }
mapPaths { it.replace("libzstd-jni", "libzstd-jni_dh") }
relocateNative "com/github/luben", "dhcomgithubluben" relocateNative "com/github/luben", "dhcomgithubluben"
relocateNative "com_github_luben", "dhcomgithubluben" relocateNative "com_github_luben", "dhcomgithubluben"
+14
View File
@@ -12,15 +12,29 @@ How to add a library's natives:
Example: Example:
```groovy ```groovy
// Relocate the namespace (Java side)
relocate "org.sqlite", "dh_sqlite", { relocate "org.sqlite", "dh_sqlite", {
// (Specific to SQLite's relocation)
// Make sure that native paths are not changed before steps below
exclude "org/sqlite/native/**" exclude "org/sqlite/native/**"
} }
// Shadow also replaces strings inside the Java code
// See the library's source code to find strings used to call into the native code
// This also includes native library paths, if you use mapPaths {} below they will likely need adjustment as well
relocate "jdbc:sqlite", "jdbc:dh_sqlite"
transform(NativeTransformer) { transform(NativeTransformer) {
// NativeTransformer configuration // NativeTransformer configuration
rootDir = project.rootDir rootDir = project.rootDir
// Match native libraries
matchFiles { it.startsWith("org/sqlite") }
// Replace paths with ones that won't overlap with other mods
// Libraries are the ones choosing the path to use for natives; check the source code to see which paths are acceptable.
mapPaths { it.replace("org/sqlite", "dh_sqlite") }
// Replace native strings, e.g. used in calls back to Java // Replace native strings, e.g. used in calls back to Java
// They must be of the same length or shorter!
relocateNative "org/sqlite", "dh_sqlite" relocateNative "org/sqlite", "dh_sqlite"
// Rename native methods used when calling from Java // Rename native methods used when calling from Java
relocateNative "org_sqlite", "dh_1sqlite" relocateNative "org_sqlite", "dh_1sqlite"
Binary file not shown.
Binary file not shown.