diff --git a/build.gradle b/build.gradle index 22c83bf13..1b23e21ff 100644 --- a/build.gradle +++ b/build.gradle @@ -372,18 +372,15 @@ subprojects { p -> // ZStd // 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 - relocate "com.github.luben", "dhcomgithubluben", { - exclude "aix.ppc64/**" - exclude "darwin/**" - exclude "freebsd/**" - exclude "linux/**" - exclude "win/**" - } + relocate "com.github.luben", "dhcomgithubluben" + relocate "libzstd-jni", "libzstd-jni_dh" + relocate "zstd-jni", "zstd-jni_dh" transform(NativeTransformer) { 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" diff --git a/relocate_natives/README.md b/relocate_natives/README.md index 6c1366f7e..7aa4cd2f7 100644 --- a/relocate_natives/README.md +++ b/relocate_natives/README.md @@ -12,15 +12,29 @@ How to add a library's natives: Example: ```groovy +// Relocate the namespace (Java side) 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/**" } +// 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) { // NativeTransformer configuration 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 + // They must be of the same length or shorter! relocateNative "org/sqlite", "dh_sqlite" // Rename native methods used when calling from Java relocateNative "org_sqlite", "dh_1sqlite" diff --git a/relocate_natives/cache/darwin/aarch64/libzstd-jni-1.5.7-6.dylib b/relocate_natives/cache/darwin/aarch64/libzstd-jni_dh-1.5.7-6.dylib similarity index 99% rename from relocate_natives/cache/darwin/aarch64/libzstd-jni-1.5.7-6.dylib rename to relocate_natives/cache/darwin/aarch64/libzstd-jni_dh-1.5.7-6.dylib index 7a069b302..10f02a77f 100644 Binary files a/relocate_natives/cache/darwin/aarch64/libzstd-jni-1.5.7-6.dylib and b/relocate_natives/cache/darwin/aarch64/libzstd-jni_dh-1.5.7-6.dylib differ diff --git a/relocate_natives/cache/darwin/x86_64/libzstd-jni-1.5.7-6.dylib b/relocate_natives/cache/darwin/x86_64/libzstd-jni_dh-1.5.7-6.dylib similarity index 99% rename from relocate_natives/cache/darwin/x86_64/libzstd-jni-1.5.7-6.dylib rename to relocate_natives/cache/darwin/x86_64/libzstd-jni_dh-1.5.7-6.dylib index 87c06a130..400761575 100644 Binary files a/relocate_natives/cache/darwin/x86_64/libzstd-jni-1.5.7-6.dylib and b/relocate_natives/cache/darwin/x86_64/libzstd-jni_dh-1.5.7-6.dylib differ diff --git a/relocate_natives/cache/freebsd/amd64/libzstd-jni-1.5.7-6.so b/relocate_natives/cache/freebsd/amd64/libzstd-jni_dh-1.5.7-6.so similarity index 100% rename from relocate_natives/cache/freebsd/amd64/libzstd-jni-1.5.7-6.so rename to relocate_natives/cache/freebsd/amd64/libzstd-jni_dh-1.5.7-6.so diff --git a/relocate_natives/cache/freebsd/i386/libzstd-jni-1.5.7-6.so b/relocate_natives/cache/freebsd/i386/libzstd-jni_dh-1.5.7-6.so similarity index 100% rename from relocate_natives/cache/freebsd/i386/libzstd-jni-1.5.7-6.so rename to relocate_natives/cache/freebsd/i386/libzstd-jni_dh-1.5.7-6.so diff --git a/relocate_natives/cache/linux/aarch64/libzstd-jni-1.5.7-6.so b/relocate_natives/cache/linux/aarch64/libzstd-jni_dh-1.5.7-6.so similarity index 100% rename from relocate_natives/cache/linux/aarch64/libzstd-jni-1.5.7-6.so rename to relocate_natives/cache/linux/aarch64/libzstd-jni_dh-1.5.7-6.so diff --git a/relocate_natives/cache/linux/amd64/libzstd-jni-1.5.7-6.so b/relocate_natives/cache/linux/amd64/libzstd-jni_dh-1.5.7-6.so similarity index 100% rename from relocate_natives/cache/linux/amd64/libzstd-jni-1.5.7-6.so rename to relocate_natives/cache/linux/amd64/libzstd-jni_dh-1.5.7-6.so diff --git a/relocate_natives/cache/linux/arm/libzstd-jni-1.5.7-6.so b/relocate_natives/cache/linux/arm/libzstd-jni_dh-1.5.7-6.so similarity index 100% rename from relocate_natives/cache/linux/arm/libzstd-jni-1.5.7-6.so rename to relocate_natives/cache/linux/arm/libzstd-jni_dh-1.5.7-6.so diff --git a/relocate_natives/cache/linux/i386/libzstd-jni-1.5.7-6.so b/relocate_natives/cache/linux/i386/libzstd-jni_dh-1.5.7-6.so similarity index 100% rename from relocate_natives/cache/linux/i386/libzstd-jni-1.5.7-6.so rename to relocate_natives/cache/linux/i386/libzstd-jni_dh-1.5.7-6.so diff --git a/relocate_natives/cache/linux/loongarch64/libzstd-jni-1.5.7-6.so b/relocate_natives/cache/linux/loongarch64/libzstd-jni_dh-1.5.7-6.so similarity index 100% rename from relocate_natives/cache/linux/loongarch64/libzstd-jni-1.5.7-6.so rename to relocate_natives/cache/linux/loongarch64/libzstd-jni_dh-1.5.7-6.so diff --git a/relocate_natives/cache/linux/mips64/libzstd-jni-1.5.7-6.so b/relocate_natives/cache/linux/mips64/libzstd-jni_dh-1.5.7-6.so similarity index 100% rename from relocate_natives/cache/linux/mips64/libzstd-jni-1.5.7-6.so rename to relocate_natives/cache/linux/mips64/libzstd-jni_dh-1.5.7-6.so diff --git a/relocate_natives/cache/linux/ppc64/libzstd-jni_dh-1.5.7-6.so b/relocate_natives/cache/linux/ppc64/libzstd-jni_dh-1.5.7-6.so new file mode 100644 index 000000000..c7349a6ed Binary files /dev/null and b/relocate_natives/cache/linux/ppc64/libzstd-jni_dh-1.5.7-6.so differ diff --git a/relocate_natives/cache/linux/ppc64le/libzstd-jni_dh-1.5.7-6.so b/relocate_natives/cache/linux/ppc64le/libzstd-jni_dh-1.5.7-6.so new file mode 100644 index 000000000..b97b116c2 Binary files /dev/null and b/relocate_natives/cache/linux/ppc64le/libzstd-jni_dh-1.5.7-6.so differ diff --git a/relocate_natives/cache/linux/riscv64/libzstd-jni-1.5.7-6.so b/relocate_natives/cache/linux/riscv64/libzstd-jni_dh-1.5.7-6.so similarity index 100% rename from relocate_natives/cache/linux/riscv64/libzstd-jni-1.5.7-6.so rename to relocate_natives/cache/linux/riscv64/libzstd-jni_dh-1.5.7-6.so diff --git a/relocate_natives/cache/linux/s390x/libzstd-jni-1.5.7-6.so b/relocate_natives/cache/linux/s390x/libzstd-jni_dh-1.5.7-6.so similarity index 100% rename from relocate_natives/cache/linux/s390x/libzstd-jni-1.5.7-6.so rename to relocate_natives/cache/linux/s390x/libzstd-jni_dh-1.5.7-6.so diff --git a/relocate_natives/cache/win/aarch64/libzstd-jni-1.5.7-6.dll b/relocate_natives/cache/win/aarch64/libzstd-jni_dh-1.5.7-6.dll similarity index 100% rename from relocate_natives/cache/win/aarch64/libzstd-jni-1.5.7-6.dll rename to relocate_natives/cache/win/aarch64/libzstd-jni_dh-1.5.7-6.dll diff --git a/relocate_natives/cache/win/amd64/libzstd-jni-1.5.7-6.dll b/relocate_natives/cache/win/amd64/libzstd-jni_dh-1.5.7-6.dll similarity index 100% rename from relocate_natives/cache/win/amd64/libzstd-jni-1.5.7-6.dll rename to relocate_natives/cache/win/amd64/libzstd-jni_dh-1.5.7-6.dll diff --git a/relocate_natives/cache/win/x86/libzstd-jni-1.5.7-6.dll b/relocate_natives/cache/win/x86/libzstd-jni_dh-1.5.7-6.dll similarity index 100% rename from relocate_natives/cache/win/x86/libzstd-jni-1.5.7-6.dll rename to relocate_natives/cache/win/x86/libzstd-jni_dh-1.5.7-6.dll