Skip to content

Commit

Permalink
feat: support openssl from bcr
Browse files Browse the repository at this point in the history
  • Loading branch information
zaucy committed Dec 10, 2024
1 parent 37ce34c commit 305b154
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 24 deletions.
1 change: 1 addition & 0 deletions .bazelversion
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
7.4.1
2 changes: 2 additions & 0 deletions .github/workflows/bazel.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,5 @@ jobs:
working-directory: test
- run: bazelisk test ... [email protected]//:ssl=boringssl
working-directory: test
- run: bazelisk test ... [email protected]//:ssl=openssl
working-directory: test
68 changes: 44 additions & 24 deletions BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,16 +1,32 @@
load("@rules_cc//cc:defs.bzl", "cc_library")
load("@bazel_skylib//rules:common_settings.bzl", "string_flag")
load("@bazel_skylib//rules:write_file.bzl", "write_file")
load("@rules_cc//cc:defs.bzl", "cc_library")

string_flag(
name = "ssl",
visibility = ["//visibility:public"],
values = ["no_ssl", "boringssl"], # OpenSSL not in BCR yet.
build_setting_default = "no_ssl",
values = [
"no_ssl",
"boringssl",
"openssl",
],
visibility = ["//visibility:public"],
)

config_setting(name = "no_ssl", flag_values = {":ssl": "no_ssl"})
config_setting(name = "boringssl", flag_values = {":ssl": "boringssl"})
config_setting(
name = "no_ssl",
flag_values = {":ssl": "no_ssl"},
)

config_setting(
name = "boringssl",
flag_values = {":ssl": "boringssl"},
)

config_setting(
name = "openssl",
flag_values = {":ssl": "openssl"},
)

write_file(
name = "src",
Expand All @@ -28,25 +44,6 @@ write_file(

cc_library(
name = "boost.asio",
visibility = ["//visibility:public"],
defines = ["BOOST_ASIO_SEPARATE_COMPILATION"],
linkopts = select({
"@platforms//os:windows": [
"-DEFAULTLIB:ws2_32",
"-DEFAULTLIB:mswsock",
],
"//conditions:default": [
"-lpthread",
],
}),
hdrs = glob([
"include/**/*.hpp",
"include/**/*.h",
"include/**/*.ipp",
], exclude = [
"include/boost/asio/impl/src.hpp",
"include/boost/asio/ssl/impl/src.hpp",
]),
srcs = [":src"] + select({
":no_ssl": [
"include/boost/asio/impl/src.hpp",
Expand All @@ -56,7 +53,29 @@ cc_library(
"include/boost/asio/ssl/impl/src.hpp",
],
}),
hdrs = glob(
[
"include/**/*.hpp",
"include/**/*.h",
"include/**/*.ipp",
],
exclude = [
"include/boost/asio/impl/src.hpp",
"include/boost/asio/ssl/impl/src.hpp",
],
),
defines = ["BOOST_ASIO_SEPARATE_COMPILATION"],
includes = ["include"],
linkopts = select({
"@platforms//os:windows": [
"-DEFAULTLIB:ws2_32",
"-DEFAULTLIB:mswsock",
],
"//conditions:default": [
"-lpthread",
],
}),
visibility = ["//visibility:public"],
deps = [
"@boost.align",
"@boost.array",
Expand All @@ -78,6 +97,7 @@ cc_library(
"@boost.utility",
] + select({
":boringssl": ["@boringssl//:ssl"],
":openssl": ["@openssl//:ssl"],
":no_ssl": [],
}),
)
1 change: 1 addition & 0 deletions MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,4 @@ bazel_dep(name = "boost.system", version = "1.83.0.bzl.2")
bazel_dep(name = "boost.throw_exception", version = "1.83.0.bzl.1")
bazel_dep(name = "boost.type_traits", version = "1.83.0.bzl.1")
bazel_dep(name = "boost.utility", version = "1.83.0.bzl.1")
bazel_dep(name = "openssl", version = "3.3.1.bcr.0")
1 change: 1 addition & 0 deletions test/.bazelversion
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
7.4.1

0 comments on commit 305b154

Please sign in to comment.