Skip to content

build: add Bazel build files - #4950

Open
karlmoriaty wants to merge 1 commit into
meta:devfrom
karlmoriaty:bazel-build
Open

karlmoriaty wants to merge 1 commit into
meta:devfrom
karlmoriaty:bazel-build

Conversation

@karlmoriaty

Copy link
Copy Markdown

This PR adds Bazel build scripts for the C library. As Cyan4973 mentioned: "a bazel build script in zstd/build/bazel would be a welcomed patch". So here it is.

Quick note on the layout: MODULE.bazel has to stay at the repo root because Bazel enforces the workspace root. It just won't work if we put it under build/bazel/. The rest of the files are lib/BUILD.bazel (sitting right next to the existing lib/BUCK) and a build/bazel/README.md for docs. So yeah, MODULE.bazel is the only thing we had to drop at the root; everything else stays tucked away under lib/ and build/bazel/ just like the contributing guidelines ask.

The config matches exactly what make lib does: ZSTD_LEGACY_SUPPORT=0 and single-threaded. I also used a select for MSVC to make sure it compiles on Windows.

As terrelln pointed out: "It would also need a test in CI". So I added a new workflow to cover it.

Tested locally:

Ran bazel build //lib:zstd and got Build completed successfully, 36 total actions.

Outputs: zstd.lib on Windows and libzstd.a on Linux.

It covers all 33 .c files across 5 dirs under lib/ (excluding legacy/).

Add a Bazel build for the C library, maintained like the existing CMake and
Meson builds under build/. MODULE.bazel stays at the repository root because
Bazel requires it there; the library target lives in lib/BUILD.bazel next to
the existing BUCK and Makefile. A workflow builds //lib:zstd on every change
so the build description does not bit-rot.
@meta-cla meta-cla Bot added the CLA Signed label Nov 13, 2026
@karlmoriaty

Copy link
Copy Markdown
Author

@Cyan4973 the bazel, cmake-tests, dev-* and Android NDK workflows are waiting on first-time contributor approval, so nothing has run yet. Could you approve them when you get a chance? Happy to move things around if MODULE.bazel at the repo root is not what you want.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant