Skip to content

Adding bazelmod #1009

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
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .bazelversion
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
7.x
51 changes: 51 additions & 0 deletions .github/workflows/build_bazel.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: bazel - Build and test

on:
push:
branches: [ "master" ]
pull_request:
branches: [ "master" ]

env:
BUILD_TYPE: Release
COVERALLS_PULL_REQUEST: ${{ github.event.number }}

jobs:
build:
# The CMake configure and build commands are platform agnostic and should work equally well on Windows or Mac.
# You can convert this to a matrix build if you need cross-platform coverage.
# See: https://docs.github.com/en/free-pro-team@latest/actions/learn-github-actions/managing-complex-workflows#using-a-build-matrix
runs-on: ${{ matrix.os }}
strategy:
fail-fast: true
matrix:
os: [ ubuntu-latest,
ubuntu-20.04,
ubuntu-22.04,
ubuntu-24.04
]
# ubuntu-18.04 & mac-os do not work due to compile error on asio
# windows-2019 not included to spare free minutes
steps:
- uses: actions/checkout@v4
- name: Prepare dependencies
run: |
if [ "$RUNNER_OS" == "Linux" ]; then
curl --tlsv1.2 --proto =https -Lo bazel https://github.com/bazelbuild/bazelisk/releases/download/v1.25.0/bazelisk-linux-amd64
chmod +x bazel

sudo apt-get update && \
sudo apt-get install -yq \
g++ clang
else
echo "$RUNNER_OS not supported"
exit 1
fi
shell: bash

- name: Build bazel
run: |
./bazel build //...
./bazel test //...


4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -59,3 +59,7 @@ cmake-build-debug
.cache
site
venv

#Bazel
bazel-*
MODULE.bazel.lock
48 changes: 48 additions & 0 deletions BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
package(default_visibility = ["//visibility:public"])
load("@bazel_skylib//rules:common_settings.bzl", "bool_flag")

bool_flag(
name = "ssl_enabled_flag",
build_setting_default = True,
visibility = ["//visibility:public"],
)

config_setting(
name = "ssl_enabled",
flag_values = {
"//:ssl_enabled_flag": "True",
},
)

bool_flag(
name = "compression_enabled_flag",
build_setting_default = True,
visibility = ["//visibility:public"],
)

config_setting(
name = "compression_enabled",
flag_values = {
"//:compression_enabled_flag": "True",
},
)

cc_library(
name = "crow",
hdrs = glob(["include/**/*"]),
includes = ["include"],
copts = select({
":ssl_enabled": ["-DASIO_STANDALONE", "-DCROW_ENABLE_SSL"],
"//conditions:default": [],
}) + select({
":compression_enabled": ["-DCROW_ENABLE_COMPRESSION"],
"//conditions:default": [],
}),
deps = select({
":ssl_enabled": ["@asio//:asio"],
"//conditions:default": [],
}) + select({
":compression_enabled": ["@zlib//:zlib"],
"//conditions:default": [],
}),
)
9 changes: 9 additions & 0 deletions MODULE.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
module(name = "crowcpp", version = "1.2.1.2")

bazel_dep(name = "bazel_skylib", version = "1.7.1")
bazel_dep(name = "rules_cc", version = "0.1.1")
bazel_dep(name = "zlib", version = "1.3.1.bcr.5")
bazel_dep(name = "asio", version = "1.32.0")

# testing
bazel_dep(name = "catch2", version = "3.8.0")
13 changes: 13 additions & 0 deletions tests/ssl/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
cc_test(
name = "ssltest",
srcs = select({
"//:ssl_enabled": ["ssltest.cpp"],
"//conditions:default": [],
}),
copts = ["-DASIO_STANDALONE", "-DCROW_ENABLE_SSL"],
deps = [
"//:crow",
"@catch2//:catch2_main",
],
visibility = ["//visibility:public"],
)