-
Notifications
You must be signed in to change notification settings - Fork 200
Add Bazel build with BoringSSL support #501
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
Open
BYVoid
wants to merge
7
commits into
ClickHouse:master
Choose a base branch
from
BYVoid:bazel-and-boringssl
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+677
−0
Open
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
a2c545a
Bazel and BoringSSL
BYVoid 48735d9
Add GitHub Actions workflow for Bazel build
BYVoid a42d660
Add tls build flag to select between BoringSSL and OpenSSL
BYVoid 0380052
Warn instead of silently ignoring SSL config under BoringSSL
BYVoid 9848feb
Bump Bazel deps to latest BCR versions
BYVoid b6dcf63
Use cityhash from BCR instead of contrib/
BYVoid d6f0faf
Cover both TLS backends and macOS in Bazel CI
BYVoid File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,43 @@ | ||
| name: Bazel | ||
|
|
||
| on: | ||
| schedule: | ||
| - cron: '0 0 * * 1' | ||
| push: | ||
| branches: [ '*' ] | ||
| pull_request: | ||
| branches: [ master ] | ||
|
|
||
| release: | ||
| types: | ||
| - published | ||
| - prereleased | ||
|
|
||
| permissions: | ||
| contents: read | ||
|
|
||
| jobs: | ||
| build: | ||
| strategy: | ||
| fail-fast: false | ||
| matrix: | ||
| os: [ubuntu-24.04, macos-latest] | ||
| tls: [boringssl, openssl] | ||
|
|
||
| runs-on: ${{ matrix.os }} | ||
|
|
||
| steps: | ||
| - uses: actions/checkout@v6 | ||
| with: | ||
| fetch-depth: 100 | ||
| fetch-tags: true | ||
|
|
||
| - name: Setup Bazel | ||
| uses: bazel-contrib/setup-bazel@0.15.0 | ||
| with: | ||
| bazelisk-cache: true | ||
| disk-cache: true | ||
| repository-cache: true | ||
|
|
||
| - name: Build project | ||
| run: bazel build //... --@clickhouse_cpp//:tls=${{ matrix.tls }} |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -281,3 +281,6 @@ BUCKAROO_DEPS | |
|
|
||
| # clangd cache | ||
| /.cache/clangd | ||
|
|
||
| # Bazel | ||
| /bazel-* | ||
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,86 @@ | ||
| load("@bazel_skylib//rules:common_settings.bzl", "string_flag") | ||
| load("@rules_cc//cc:cc_library.bzl", "cc_library") | ||
|
|
||
| # Bazel build for clickhouse-cpp. The canonical build is CMake | ||
| # (top-level CMakeLists.txt); this file mirrors the same library as | ||
| # a bzlmod target so downstream Bazel projects can depend on it via | ||
| # the Bazel Central Registry without standing up CMake. | ||
| # | ||
| # Differences from the CMake build that callers should be aware of: | ||
| # * TLS links against BoringSSL (`@boringssl`) by default; pass | ||
| # `--@clickhouse_cpp//:tls=openssl` to use the BCR OpenSSL module | ||
| # instead. `USE_BORINGSSL` ifdef-guards the two OpenSSL-only | ||
| # surfaces (`SSL_CONF_*` command API and `SSL_read_ex`) that | ||
| # BoringSSL doesn't provide; see clickhouse/base/sslsocket.cpp. | ||
| # * cityhash / lz4 / zstd / abseil come from BCR modules instead of | ||
| # contrib/; the contrib/ trees are only used by the CMake build. | ||
|
|
||
| # Selects the TLS implementation: `--@clickhouse_cpp//:tls=boringssl` | ||
| # (default) or `--@clickhouse_cpp//:tls=openssl`. Both come from BCR | ||
| # modules and are linked statically, keeping the build hermetic. | ||
| string_flag( | ||
| name = "tls", | ||
| build_setting_default = "boringssl", | ||
| values = [ | ||
| "boringssl", | ||
| "openssl", | ||
| ], | ||
| ) | ||
|
|
||
| config_setting( | ||
| name = "tls_boringssl", | ||
| flag_values = {":tls": "boringssl"}, | ||
| ) | ||
|
|
||
| config_setting( | ||
| name = "tls_openssl", | ||
| flag_values = {":tls": "openssl"}, | ||
| ) | ||
|
|
||
| # The main clickhouse-cpp library. Downstream callers use | ||
| # `#include <clickhouse/client.h>` and link `@clickhouse_cpp//:clickhouse`. | ||
| cc_library( | ||
| name = "clickhouse", | ||
| srcs = glob([ | ||
| "clickhouse/*.cpp", | ||
| "clickhouse/base/*.cpp", | ||
| "clickhouse/columns/*.cpp", | ||
| "clickhouse/types/*.cpp", | ||
| ]), | ||
| hdrs = glob([ | ||
| "clickhouse/*.h", | ||
| "clickhouse/base/*.h", | ||
| "clickhouse/columns/*.h", | ||
| "clickhouse/types/*.h", | ||
| ]), | ||
| defines = [ | ||
| # Enable the TLS code paths in client.cpp / sslsocket.cpp. | ||
| # Matches CMake's `option(WITH_OPENSSL ON)`. | ||
| "WITH_OPENSSL", | ||
| ] + select({ | ||
| # Take the BoringSSL-compatible branches in sslsocket.cpp. | ||
| ":tls_boringssl": ["USE_BORINGSSL"], | ||
| ":tls_openssl": [], | ||
| }), | ||
| # Expose headers at their workspace path so both internal | ||
| # (`#include "client.h"` from clickhouse/*.cpp via quote-form | ||
| # source-dir search) and external (`#include <clickhouse/client.h>`) | ||
| # include forms resolve. | ||
| strip_include_prefix = "/", | ||
| visibility = ["//visibility:public"], | ||
| deps = [ | ||
| "@abseil-cpp//absl/numeric:int128", | ||
| "@cityhash//:cityhash", | ||
| "@lz4//:lz4", | ||
| "@zstd//:zstd", | ||
| ] + select({ | ||
| ":tls_boringssl": [ | ||
| "@boringssl//:crypto", | ||
| "@boringssl//:ssl", | ||
| ], | ||
| ":tls_openssl": [ | ||
| "@openssl//:crypto", | ||
| "@openssl//:ssl", | ||
| ], | ||
| }), | ||
| ) | ||
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| module(name = "clickhouse_cpp", version = "2.6.1") | ||
|
|
||
| bazel_dep(name = "abseil-cpp", version = "20260526.0") | ||
| bazel_dep(name = "bazel_skylib", version = "1.9.0") | ||
| bazel_dep(name = "boringssl", version = "0.20260526.0") | ||
| bazel_dep(name = "cityhash", version = "1.0.2") | ||
| bazel_dep(name = "lz4", version = "1.10.0.bcr.1") | ||
| bazel_dep(name = "openssl", version = "3.5.5.bcr.4") | ||
| bazel_dep(name = "rules_cc", version = "0.2.19") | ||
| bazel_dep(name = "zstd", version = "1.5.7.bcr.1") |
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.