Repository navigation
build: add Bazel build files - #4950
Open
karlmoriaty wants to merge 1 commit into
Open
karlmoriaty wants to merge 1 commit into
karlmoriaty wants to merge 1 commit into
Conversation
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.
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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/).