From 6eb561bd50a8ffcf8ef9000bcee619576d1d9941 Mon Sep 17 00:00:00 2001 From: Sebastian Bergt Date: Sat, 29 Mar 2025 09:32:10 +0100 Subject: [PATCH] keeping bazel local and adding options for compression and ssl --- .github/workflows/build_bazel.yml | 6 ++--- BUILD.bazel | 45 +++++++++++++++++++++++++++++-- MODULE.bazel | 6 ++++- 3 files changed, 50 insertions(+), 7 deletions(-) diff --git a/.github/workflows/build_bazel.yml b/.github/workflows/build_bazel.yml index 7e443c26e..39bf062b6 100644 --- a/.github/workflows/build_bazel.yml +++ b/.github/workflows/build_bazel.yml @@ -1,4 +1,4 @@ -name: Build and test +name: bazel - Build and test on: push: @@ -35,7 +35,6 @@ jobs: 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 mv bazel /usr/bin/ sudo apt-get update && \ sudo apt-get install -yq \ @@ -45,7 +44,6 @@ jobs: elif [ "$RUNNER_OS" == "macOS" ]; then curl --tlsv1.2 --proto =https -Lo bazel https://github.com/bazelbuild/bazelisk/releases/download/v1.25.0/bazelisk-darwin-amd64 chmod +x bazel - sudo mv bazel /usr/bin/ brew install asio openssl zlib else @@ -55,6 +53,6 @@ jobs: shell: bash - name: Build bazel - run: bazel build //... + run: ./bazel build //... diff --git a/BUILD.bazel b/BUILD.bazel index 40164620a..ca93a4fae 100644 --- a/BUILD.bazel +++ b/BUILD.bazel @@ -1,7 +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"], - visibility = ["//visibility:public"], - copts = ["-DCROW_ENABLE_SSL"] + 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": [], + }), ) diff --git a/MODULE.bazel b/MODULE.bazel index 3a504b052..bfc0fd815 100644 --- a/MODULE.bazel +++ b/MODULE.bazel @@ -1,2 +1,6 @@ module(name = "crowcpp", version = "1.0") -bazel_dep(name = "rules_cc", version = "0.1.1") \ No newline at end of file + +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") \ No newline at end of file