Skip to content

Commit

Permalink
Add patch files for zstd-jni
Browse files Browse the repository at this point in the history
Partial commit for third_party/*, see bazelbuild#14203.

Closes bazelbuild#14203

Signed-off-by: Yun Peng <[email protected]>
  • Loading branch information
coeuvre authored and meteorcloudy committed Nov 2, 2021
1 parent 80b49df commit 2986222
Show file tree
Hide file tree
Showing 2 changed files with 73 additions and 0 deletions.
11 changes: 11 additions & 0 deletions third_party/zstd-jni/Native.java.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
--- a/src/main/java/com/github/luben/zstd/util/Native.java
+++ b/src/main/java/com/github/luben/zstd/util/Native.java
@@ -59,7 +59,7 @@ public enum Native {
if (loaded) {
return;
}
- String resourceName = resourceName();
+ String resourceName = "/libzstd-jni.so";

String overridePath = System.getProperty(nativePathOverride);
if (overridePath != null) {
62 changes: 62 additions & 0 deletions third_party/zstd-jni/zstd-jni.BUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
cc_binary(
name = "libzstd-jni.so",
srcs = glob([
"src/main/native/**/*.c",
"src/main/native/**/*.h",
]) + select({
"@io_bazel//src/conditions:windows": [
"src/windows/include/jni_md.h",
"jni/jni.h",
],
"//conditions:default": [
"jni/jni_md.h",
"jni/jni.h",
]
}),
copts = select({
"@io_bazel//src/conditions:windows": [],
"//conditions:default": [
"-std=c99",
"-Wno-unused-variable",
"-Wno-sometimes-uninitialized",
]
}),
linkshared = 1,
includes = select({
"@io_bazel//src/conditions:windows": ["src/windows/include"],
"//conditions:default": [],
}) + [
"jni",
"src/main/native",
"src/main/native/common",
],
local_defines = [
"ZSTD_LEGACY_SUPPORT=4",
"ZSTD_MULTITHREAD=1",
] + select({
"@io_bazel//src/conditions:windows": ["_JNI_IMPLEMENTATION_"],
"//conditions:default": [],
}),
)


genrule(
name = "version-java",
cmd_bash = 'echo "package com.github.luben.zstd.util;\n\npublic class ZstdVersion {\n\tpublic static final String VERSION = \\"$$(cat $<)\\";\n}" > $@',
cmd_ps = '$$PSDefaultParameterValues.Remove("*:Encoding"); $$version = (Get-Content $<) -join ""; Set-Content -NoNewline -Path $@ -Value "package com.github.luben.zstd.util;\n\npublic class ZstdVersion {\n\tpublic static final String VERSION = `"$${version}`";\n}\n"',
srcs = ["version"],
outs = ["ZstdVersion.java"],
)

java_library(
name = "zstd-jni",
srcs = glob([
"src/main/java/**/*.java",
]) + [
":version-java",
],
resources = [":libzstd-jni.so"],
visibility = [
"//visibility:public",
],
)

0 comments on commit 2986222

Please sign in to comment.