Skip to content

Commit

Permalink
Add zstd module to GCR. (#1085)
Browse files Browse the repository at this point in the history
* Add zstd module to GCR.

BUILD file contents copied from https://github.com/mvukov/rules_ros2/blob/main/repositories/zstd.BUILD.bazel

* Rewrote BUILD

* fixup

* fixup

* fixup
  • Loading branch information
jondo2010 committed Nov 7, 2023
1 parent e7b6502 commit 95f468d
Show file tree
Hide file tree
Showing 6 changed files with 169 additions and 0 deletions.
7 changes: 7 additions & 0 deletions modules/zstd/1.5.5/MODULE.bazel
@@ -0,0 +1,7 @@
module(
name = "zstd",
version = "1.5.5",
compatibility_level = 1,
)
bazel_dep(name = "rules_cc", version = "0.0.9")
bazel_dep(name = "platforms", version = "0.0.8")
118 changes: 118 additions & 0 deletions modules/zstd/1.5.5/patches/add_build_file.patch
@@ -0,0 +1,118 @@
--- /dev/null
+++ BUILD.bazel
@@ -0,0 +1,115 @@
+""" 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",
+ ],
+ local_defines = [
+ "XXH_NAMESPACE=ZSTD_",
+ "ZSTD_MULTITHREAD",
+ "ZSTD_BUILD_SHARED=OFF",
+ "ZSTD_BUILD_STATIC=ON",
+ ] + select({
+ "@platforms//os:windows": ["ZSTD_DISABLE_ASM"],
+ "//conditions:default": [],
+ }),
+ linkopts = [
+ "-pthread",
+ ],
+ linkstatic = True,
+)
+
+cc_library(
+ name = "util",
+ hdrs = [
+ "programs/util.h",
+ "lib/common/mem.h",
+ "lib/common/compiler.h",
+ "lib/common/portability_macros.h",
+ "lib/common/debug.h",
+ "lib/common/zstd_deps.h",
+ ],
+ srcs = [
+ "programs/util.c",
+ "programs/platform.h",
+ ],
+)
+
+cc_library(
+ name = "datagen",
+ hdrs = [
+ "programs/datagen.h",
+ ],
+ srcs = [
+ "programs/datagen.c",
+ "programs/platform.h",
+ ],
+ deps = [":util"],
+)
+
+cc_binary(
+ name = "datagen_cli",
+ srcs = ["tests/datagencli.c"],
+ includes = ["programs"],
+ deps = [":datagen"],
+)
+
+cc_test(
+ name = "fullbench",
+ deps = [":zstd", ":datagen"],
+ srcs = [
+ "programs/timefn.c",
+ "programs/timefn.h",
+ "programs/benchfn.c",
+ "programs/benchfn.h",
+ "programs/benchzstd.c",
+ "programs/benchzstd.h",
+ "tests/fullbench.c",
+ "lib/decompress/zstd_decompress_internal.h",
+ ],
+ includes = ["programs", "lib", "lib/common"],
+ copts = select({
+ "@platforms//os:windows": [],
+ "//conditions:default": ["-Wno-deprecated-declarations"],
+ }),
+)
10 changes: 10 additions & 0 deletions modules/zstd/1.5.5/patches/module_dot_bazel.patch
@@ -0,0 +1,10 @@
--- MODULE.bazel
+++ MODULE.bazel
@@ -0,0 +1,7 @@
+module(
+ name = "zstd",
+ version = "1.5.5",
+ compatibility_level = 1,
+)
+bazel_dep(name = "rules_cc", version = "0.0.9")
+bazel_dep(name = "platforms", version = "0.0.8")
13 changes: 13 additions & 0 deletions modules/zstd/1.5.5/presubmit.yml
@@ -0,0 +1,13 @@
matrix:
platform:
- debian10
- ubuntu2004
- macos
- macos_arm64
- windows
tasks:
run_tests:
name: Run tests
platform: ${{ platform }}
test_targets:
- "@zstd//:fullbench"
10 changes: 10 additions & 0 deletions modules/zstd/1.5.5/source.json
@@ -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-RuZ752brpYGsY08f/54bFx5pJIOGwkLVAmyQCfAUxjg=",
"module_dot_bazel.patch": "sha256-Gow157Ff39hKAZfkLrZfdVAmbfwZYYDlfcHUM0B4a7M="
},
"patch_strip": 0
}
11 changes: 11 additions & 0 deletions modules/zstd/metadata.json
@@ -0,0 +1,11 @@
{
"homepage": "https://github.com/facebook/zstd",
"maintainers": [],
"repository": [
"github:facebook/zstd"
],
"versions": [
"1.5.5"
],
"yanked_versions": {}
}

0 comments on commit 95f468d

Please sign in to comment.