From 305b154ed6962b1e43aa42bae08a80c97063da04 Mon Sep 17 00:00:00 2001 From: Ezekiel Warren Date: Mon, 9 Dec 2024 16:46:12 -0800 Subject: [PATCH] feat: support openssl from bcr --- .bazelversion | 1 + .github/workflows/bazel.yml | 2 ++ BUILD.bazel | 68 ++++++++++++++++++++++++------------- MODULE.bazel | 1 + test/.bazelversion | 1 + 5 files changed, 49 insertions(+), 24 deletions(-) create mode 100644 .bazelversion create mode 100644 test/.bazelversion diff --git a/.bazelversion b/.bazelversion new file mode 100644 index 0000000000..815da58b7a --- /dev/null +++ b/.bazelversion @@ -0,0 +1 @@ +7.4.1 diff --git a/.github/workflows/bazel.yml b/.github/workflows/bazel.yml index 1049b50444..4d68093c54 100644 --- a/.github/workflows/bazel.yml +++ b/.github/workflows/bazel.yml @@ -17,3 +17,5 @@ jobs: working-directory: test - run: bazelisk test ... --@boost.asio//:ssl=boringssl working-directory: test + - run: bazelisk test ... --@boost.asio//:ssl=openssl + working-directory: test diff --git a/BUILD.bazel b/BUILD.bazel index 61dec16428..d1bef22035 100644 --- a/BUILD.bazel +++ b/BUILD.bazel @@ -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", @@ -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", @@ -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", @@ -78,6 +97,7 @@ cc_library( "@boost.utility", ] + select({ ":boringssl": ["@boringssl//:ssl"], + ":openssl": ["@openssl//:ssl"], ":no_ssl": [], }), ) diff --git a/MODULE.bazel b/MODULE.bazel index 05e50c172c..0076332996 100644 --- a/MODULE.bazel +++ b/MODULE.bazel @@ -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") diff --git a/test/.bazelversion b/test/.bazelversion new file mode 100644 index 0000000000..815da58b7a --- /dev/null +++ b/test/.bazelversion @@ -0,0 +1 @@ +7.4.1