Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix zstd BUILD include attr #1394

Merged
merged 13 commits into from
Jan 30, 2024
7 changes: 7 additions & 0 deletions modules/zstd/1.5.5.bcr.1/MODULE.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
module(
name = "zstd",
version = "1.5.5.bcr.1",
compatibility_level = 1,
)
bazel_dep(name = "rules_cc", version = "0.0.9")
bazel_dep(name = "platforms", version = "0.0.8")
133 changes: 133 additions & 0 deletions modules/zstd/1.5.5.bcr.1/patches/add_build_file.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
diff --git BUILD.bazel BUILD.bazel
new file mode 100644
index 00000000..7fca1671
--- /dev/null
+++ BUILD.bazel
@@ -0,0 +1,127 @@
+""" Builds zstd.
+"""
+
+load("@rules_cc//cc:defs.bzl", "cc_binary", "cc_library", "cc_test")
+
+package(default_visibility = ["//visibility:public"])
+
+filegroup(
+ name = "common_sources",
+ srcs = glob([
+ "lib/common/*.c",
+ "lib/common/*.h",
+ ]),
+)
+
+filegroup(
+ name = "compress_sources",
+ srcs = glob([
+ "lib/compress/*.c",
+ "lib/compress/*.h",
+ ]),
+)
+
+filegroup(
+ name = "decompress_sources",
+ srcs = glob([
+ "lib/decompress/*.c",
+ "lib/decompress/*.h",
+ ]) + select({
+ "@platforms//os:windows": [],
+ "//conditions:default": glob(["lib/decompress/*.S"]),
+ }),
+)
+
+filegroup(
+ name = "dictbuilder_sources",
+ srcs = glob([
+ "lib/dictBuilder/*.c",
+ "lib/dictBuilder/*.h",
+ ]),
+)
+
+cc_library(
+ name = "zstd",
+ srcs = [
+ ":common_sources",
+ ":compress_sources",
+ ":decompress_sources",
+ ":dictbuilder_sources",
+ ],
+ hdrs = [
+ "lib/zdict.h",
+ "lib/zstd.h",
+ "lib/zstd_errors.h",
+ ],
+ includes = ["lib"],
+ linkopts = ["-pthread"],
+ linkstatic = True,
+ local_defines = [
+ "XXH_NAMESPACE=ZSTD_",
+ "ZSTD_MULTITHREAD",
+ "ZSTD_BUILD_SHARED=OFF",
+ "ZSTD_BUILD_STATIC=ON",
+ ] + select({
+ "@platforms//os:windows": ["ZSTD_DISABLE_ASM"],
+ "//conditions:default": [],
+ }),
+)
+
+cc_library(
+ name = "util",
+ srcs = [
+ "programs/platform.h",
+ "programs/util.c",
+ ],
+ hdrs = [
+ "lib/common/compiler.h",
+ "lib/common/debug.h",
+ "lib/common/mem.h",
+ "lib/common/portability_macros.h",
+ "lib/common/zstd_deps.h",
+ "programs/util.h",
+ ],
+)
+
+cc_library(
+ name = "datagen",
+ srcs = [
+ "programs/datagen.c",
+ "programs/platform.h",
+ ],
+ hdrs = ["programs/datagen.h"],
+ deps = [":util"],
+)
+
+cc_binary(
+ name = "datagen_cli",
+ srcs = ["tests/datagencli.c"],
+ includes = ["programs"],
+ deps = [":datagen"],
+)
+
+cc_test(
+ name = "fullbench",
+ srcs = [
+ "lib/decompress/zstd_decompress_internal.h",
+ "programs/benchfn.c",
+ "programs/benchfn.h",
+ "programs/benchzstd.c",
+ "programs/benchzstd.h",
+ "programs/timefn.c",
+ "programs/timefn.h",
+ "tests/fullbench.c",
+ ],
+ copts = select({
+ "@platforms//os:windows": [],
+ "//conditions:default": ["-Wno-deprecated-declarations"],
+ }),
+ includes = [
+ "lib/common",
+ "programs",
+ ],
+ deps = [
+ ":datagen",
+ ":zstd",
+ ],
+)
10 changes: 10 additions & 0 deletions modules/zstd/1.5.5.bcr.1/patches/module_dot_bazel.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
--- MODULE.bazel
+++ MODULE.bazel
@@ -0,0 +1,7 @@
+module(
+ name = "zstd",
+ version = "1.5.5.bcr.1",
+ compatibility_level = 1,
+)
+bazel_dep(name = "rules_cc", version = "0.0.9")
+bazel_dep(name = "platforms", version = "0.0.8")
15 changes: 15 additions & 0 deletions modules/zstd/1.5.5.bcr.1/presubmit.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
matrix:
platform:
- debian10
- ubuntu2004
- macos
- macos_arm64
- windows
bazel: [6.x, 7.x]
tasks:
run_tests:
name: Run tests
platform: ${{ platform }}
bazel: ${{ bazel }}
test_targets:
- "@zstd//:fullbench"
10 changes: 10 additions & 0 deletions modules/zstd/1.5.5.bcr.1/source.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"url": "https://github.com/facebook/zstd/releases/download/v1.5.5/zstd-1.5.5.tar.gz",
"integrity": "sha256-nEOWzIKc+uMZpuJhUgLoKq1BNyBzSC/OKG+seGRtPuQ=",
"strip_prefix": "zstd-1.5.5",
"patches": {
"add_build_file.patch": "sha256-Zm8MvkcOsOdnhFmH7jl1iFKx0RX6LouL5SEP5ddmliU=",
"module_dot_bazel.patch": "sha256-+cgXnYCj1fFgNLlMN4v6g6iJ+AYFabXcuL+nIpmtYHs="
},
"patch_strip": 0
}
3 changes: 2 additions & 1 deletion modules/zstd/metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
"github:facebook/zstd"
],
"versions": [
"1.5.5"
"1.5.5",
"1.5.5.bcr.1"
],
"yanked_versions": {}
}