Skip to content

Commit

Permalink
Add zstd-jni 1.5.2-3.bcr.1 to support Windows (#812)
Browse files Browse the repository at this point in the history
* Add 1.5.2-3.bcr.1 to support Windows

* Fix integrity value
  • Loading branch information
meteorcloudy authored Aug 4, 2023
1 parent bf4579c commit 2ce0884
Show file tree
Hide file tree
Showing 7 changed files with 135 additions and 1 deletion.
5 changes: 5 additions & 0 deletions modules/zstd-jni/1.5.2-3.bcr.1/MODULE.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
module(
name = "zstd-jni",
version = "1.5.2-3.bcr.1",
compatibility_level = 1,
)
11 changes: 11 additions & 0 deletions modules/zstd-jni/1.5.2-3.bcr.1/patches/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) {
85 changes: 85 additions & 0 deletions modules/zstd-jni/1.5.2-3.bcr.1/patches/add_build_file.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
--- /dev/null
+++ a/BUILD.bazel
@@ -0,0 +1,82 @@
+genrule(
+ name = "copy_link_jni_md_header",
+ srcs = select({
+ "@bazel_tools//src/conditions:darwin": ["@bazel_tools//tools/jdk:jni_md_header-darwin"],
+ "@bazel_tools//src/conditions:freebsd": ["@bazel_tools//tools/jdk:jni_md_header-freebsd"],
+ "@bazel_tools//src/conditions:openbsd": ["@bazel_tools//tools/jdk:jni_md_header-openbsd"],
+ "@bazel_tools//src/conditions:windows": ["@bazel_tools//tools/jdk:jni_md_header-windows"],
+ "//conditions:default": ["@bazel_tools//tools/jdk:jni_md_header-linux"],
+ }),
+ outs = ["jni_md.h"],
+ cmd = "cp -f $< $@",
+)
+
+genrule(
+ name = "copy_link_jni_header",
+ srcs = ["@bazel_tools//tools/jdk:jni_header"],
+ outs = ["jni.h"],
+ cmd = "cp -f $< $@",
+)
+
+cc_binary(
+ name = "libzstd-jni.so",
+ srcs = glob([
+ "src/main/native/**/*.c",
+ "src/main/native/**/*.h",
+ ]) + [
+ ":jni_md.h",
+ ":jni.h",
+ ] + select({
+ "@bazel_tools//src/conditions:windows": [],
+ "//conditions:default": glob(["src/main/native/**/*.S"]),
+ }),
+ copts = select({
+ "@bazel_tools//src/conditions:windows": [],
+ "@bazel_tools//src/conditions:darwin": [
+ "-std=c99",
+ "-Wno-unused-variable",
+ "-Wno-sometimes-uninitialized",
+ ],
+ "//conditions:default": [
+ "-std=c99",
+ "-Wno-unused-variable",
+ "-Wno-maybe-uninitialized",
+ "-Wno-sometimes-uninitialized",
+ ]
+ }),
+ linkshared = 1,
+ includes = [
+ ".", # For jni headers.
+ "src/main/native",
+ "src/main/native/common",
+ ],
+ local_defines = [
+ "ZSTD_LEGACY_SUPPORT=4",
+ "ZSTD_MULTITHREAD=1",
+ ] + select({
+ "@bazel_tools//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",
+ ],
+)
8 changes: 8 additions & 0 deletions modules/zstd-jni/1.5.2-3.bcr.1/patches/module_dot_bazel.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
--- a/MODULE.bazel
+++ a/MODULE.bazel
@@ -0,0 +1,5 @@
+module(
+ name = "zstd-jni",
+ version = "1.5.2-3.bcr.1",
+ compatibility_level = 1,
+)
13 changes: 13 additions & 0 deletions modules/zstd-jni/1.5.2-3.bcr.1/presubmit.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
matrix:
platform:
- centos7
- debian10
- ubuntu2004
- macos
- windows
tasks:
verify_targets:
name: Verify build targets
platform: ${{ platform }}
build_targets:
- '@zstd-jni//...'
11 changes: 11 additions & 0 deletions modules/zstd-jni/1.5.2-3.bcr.1/source.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"url": "https://github.com/luben/zstd-jni/archive/refs/tags/v1.5.2-3.zip",
"integrity": "sha256-NmAJpDz62jUBXkzECn78S38BfGuN9crD+H0keAJ7IFY=",
"strip_prefix": "zstd-jni-1.5.2-3",
"patches": {
"Native.java.patch": "sha256-HDzZr1BxNacyg+xWvojosR8VgfZdOQ2TDAPW2bCATDs=",
"add_build_file.patch": "sha256-k67/p9wSUWEfSeeLVPabVleF+lH9YLxlog1auvezsts=",
"module_dot_bazel.patch": "sha256-0KGh/q92+gB4AWBFco0+/UkrkRGsZf0QynxMdWvAgPo="
},
"patch_strip": 1
}
3 changes: 2 additions & 1 deletion modules/zstd-jni/metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
],
"versions": [
"1.5.0-4",
"1.5.2-3"
"1.5.2-3",
"1.5.2-3.bcr.1"
],
"yanked_versions": {}
}

0 comments on commit 2ce0884

Please sign in to comment.