From 830f9b16608d11d98771ec4cf3a20150d0613db7 Mon Sep 17 00:00:00 2001 From: ambrosin Date: Mon, 8 Jan 2024 14:52:44 -0800 Subject: [PATCH] Refactor and update tink-cc dependencies * Move testonly deps to `tink_cc_testonly_deps()` * Upgrade deps: * googletest (=> 1.14) * absl (=> 20230802.1) * BoringSSL (=> commit 667d54c96acda029523c5bf425e8eb9079dbe94a from the `master-with-bazel` branch) * bazel_skylib (=> 1.5.0) * bazel (=> 6.4.0) (this is needed because of [1] and [2]) [1] https://github.com/bazelbuild/bazel/issues/15073 [2] https://github.com/google/boringssl/commit/235ee97b469ca6761e5096ea829f4da032c591fe PiperOrigin-RevId: 596709495 --- cc/.bazelversion | 2 +- cc/WORKSPACE | 4 +- cc/examples/.bazelversion | 2 +- cc/examples/WORKSPACE | 43 +++++++------ cc/tink_cc_deps.bzl | 132 ++++++++++++++++++++------------------ cmake/TinkWorkspace.cmake | 20 +++--- 6 files changed, 106 insertions(+), 97 deletions(-) diff --git a/cc/.bazelversion b/cc/.bazelversion index 09b254e90c..19b860c187 100644 --- a/cc/.bazelversion +++ b/cc/.bazelversion @@ -1 +1 @@ -6.0.0 +6.4.0 diff --git a/cc/WORKSPACE b/cc/WORKSPACE index af5976a2c8..82b860db72 100644 --- a/cc/WORKSPACE +++ b/cc/WORKSPACE @@ -6,10 +6,12 @@ workspace(name = "tink_cc") # path = "third_party/boringssl_fips/", # ) -load("@tink_cc//:tink_cc_deps.bzl", "tink_cc_deps") +load("@tink_cc//:tink_cc_deps.bzl", "tink_cc_deps", "tink_cc_testonly_deps") tink_cc_deps() +tink_cc_testonly_deps() + load("@tink_cc//:tink_cc_deps_init.bzl", "tink_cc_deps_init") tink_cc_deps_init() diff --git a/cc/examples/.bazelversion b/cc/examples/.bazelversion index 09b254e90c..19b860c187 100644 --- a/cc/examples/.bazelversion +++ b/cc/examples/.bazelversion @@ -1 +1 @@ -6.0.0 +6.4.0 diff --git a/cc/examples/WORKSPACE b/cc/examples/WORKSPACE index 5cdbbc9829..737b2a3364 100644 --- a/cc/examples/WORKSPACE +++ b/cc/examples/WORKSPACE @@ -1,36 +1,37 @@ workspace(name = "tink_cc_examples") -# The local_repository() rule is used below because the workspaces referenced -# are all located within the Tink git repository. -# -# To replicate this setup in a workspace located in a separate repository, you -# can: -# -# 1. Load the http_archive() rule by using: -# -# load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") -# -# 2. Use the equivalent, commented-out http_archive() rules below as a starting -# point. -# -# See the Tink C++ HOW-TO for more details: -# https://github.com/google/tink/blob/master/docs/CPP-HOWTO.md - +load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") +load("@bazel_tools//tools/build_defs/repo:utils.bzl", "maybe") local_repository( name = "tink_cc", path = "../", ) -# http_archive( -# name = "tink_cc", -# urls = ["https://github.com/google/tink/archive/master.zip"], -# strip_prefix = "tink-master/cc", -# ) + +# Release from 2023-09-18. +maybe( + http_archive, + name = "com_google_absl", + sha256 = "497ebdc3a4885d9209b9bd416e8c3f71e7a1fb8af249f6c2a80b7cbeefcd7e21", + strip_prefix = "abseil-cpp-20230802.1", + urls = ["https://github.com/abseil/abseil-cpp/archive/refs/tags/20230802.1.zip"], +) + +# Release from 2023-08-02. +maybe( + http_archive, + name = "com_google_googletest", + sha256 = "1f357c27ca988c3f7c6b4bf68a9395005ac6761f034046e9dde0896e3aba00e4", + strip_prefix = "googletest-1.14.0", + url = "https://github.com/google/googletest/archive/refs/tags/v1.14.0.zip", +) # Load Tink dependencies. load("@tink_cc//:tink_cc_deps.bzl", "tink_cc_deps") + tink_cc_deps() load("@tink_cc//:tink_cc_deps_init.bzl", "tink_cc_deps_init") + tink_cc_deps_init() diff --git a/cc/tink_cc_deps.bzl b/cc/tink_cc_deps.bzl index 7e473ce38e..a83c5fd426 100644 --- a/cc/tink_cc_deps.bzl +++ b/cc/tink_cc_deps.bzl @@ -1,21 +1,22 @@ -"""Dependencies of C++ Tink.""" +"""Dependencies of Tink C++.""" load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") +load("@bazel_tools//tools/build_defs/repo:utils.bzl", "maybe") def tink_cc_deps(): """Loads dependencies of C++ Tink.""" # Basic rules we need to add to bazel. - if not native.existing_rule("bazel_skylib"): - # Release from 2022-09-01: https://github.com/bazelbuild/bazel-skylib/releases/tag/1.3.0 - http_archive( - name = "bazel_skylib", - urls = [ - "https://mirror.bazel.build/github.com/bazelbuild/bazel-skylib/releases/download/1.3.0/bazel-skylib-1.3.0.tar.gz", - "https://github.com/bazelbuild/bazel-skylib/releases/download/1.3.0/bazel-skylib-1.3.0.tar.gz", - ], - sha256 = "74d544d96f4a5bb630d465ca8bbcfe231e3594e5aae57e1edbf17a6eb3ca2506", - ) + # Release from 2023-11-06. + maybe( + http_archive, + name = "bazel_skylib", + sha256 = "cd55a062e763b9349921f0f5db8c3933288dc8ba4f76dd9416aac68acee3cb94", + urls = [ + "https://mirror.bazel.build/github.com/bazelbuild/bazel-skylib/releases/download/1.5.0/bazel-skylib-1.5.0.tar.gz", + "https://github.com/bazelbuild/bazel-skylib/releases/download/1.5.0/bazel-skylib-1.5.0.tar.gz", + ], + ) # ------------------------------------------------------------------------- # Protobuf. @@ -26,68 +27,75 @@ def tink_cc_deps(): # * @com_google_protobuf//:cc_toolchain # * @com_google_protobuf//:java_toolchain # This statement defines the @com_google_protobuf repo. - if not native.existing_rule("com_google_protobuf"): - # Release X.25.1 from 2023-11-15. - http_archive( - name = "com_google_protobuf", - strip_prefix = "protobuf-25.1", - urls = ["https://github.com/protocolbuffers/protobuf/releases/download/v25.1/protobuf-25.1.zip"], - sha256 = "5c86c077b0794c3e9bb30cac872cf883043febfb0f992137f0a8b1c3d534617c", - ) + # Release X.25.1 from 2023-11-15. + maybe( + http_archive, + name = "com_google_protobuf", + sha256 = "5c86c077b0794c3e9bb30cac872cf883043febfb0f992137f0a8b1c3d534617c", + strip_prefix = "protobuf-25.1", + urls = ["https://github.com/protocolbuffers/protobuf/releases/download/v25.1/protobuf-25.1.zip"], + ) # ------------------------------------------------------------------------- # Abseil. # ------------------------------------------------------------------------- - if not native.existing_rule("com_google_absl"): - # Release from 2023-08-02. - http_archive( - name = "com_google_absl", - strip_prefix = "abseil-cpp-20230802.0", - urls = ["https://github.com/abseil/abseil-cpp/archive/refs/tags/20230802.0.zip"], - sha256 = "2942db09db29359e0c1982986167167d226e23caac50eea1f07b2eb2181169cf", - ) + # Release from 2023-09-18. + maybe( + http_archive, + name = "com_google_absl", + sha256 = "497ebdc3a4885d9209b9bd416e8c3f71e7a1fb8af249f6c2a80b7cbeefcd7e21", + strip_prefix = "abseil-cpp-20230802.1", + urls = ["https://github.com/abseil/abseil-cpp/archive/refs/tags/20230802.1.zip"], + ) # ------------------------------------------------------------------------- # BoringSSL. # ------------------------------------------------------------------------- - if not native.existing_rule("boringssl"): - # Commit from 2023-02-15. - http_archive( - name = "boringssl", - strip_prefix = "boringssl-5c22014ca513807ed03c657e8ede076164663979", - url = "https://github.com/google/boringssl/archive/5c22014ca513807ed03c657e8ede076164663979.zip", - sha256 = "863fc670c456f30923740c1639305132fdfb9d1b25ba385a67ae3862ef12a8af", - ) + # Commit from 2023-09-08. + maybe( + http_archive, + name = "boringssl", + sha256 = "21b2086e9242b87415767fd6d2d13bd0481e2eb3c336c7ffa24b1f3d7afb09ae", + strip_prefix = "boringssl-667d54c96acda029523c5bf425e8eb9079dbe94a", + url = "https://github.com/google/boringssl/archive/667d54c96acda029523c5bf425e8eb9079dbe94a.zip", + ) # ------------------------------------------------------------------------- - # GoogleTest/GoogleMock. + # Rapidjson. + # ------------------------------------------------------------------------- + # Release from 2016-08-25 (still the latest release as of 2022-05-05). + maybe( + http_archive, + build_file = "@tink_cc//:third_party/rapidjson.BUILD.bazel", + name = "rapidjson", + sha256 = "bf7ced29704a1e696fbccf2a2b4ea068e7774fa37f6d7dd4039d0787f8bed98e", + strip_prefix = "rapidjson-1.1.0", + url = "https://github.com/Tencent/rapidjson/archive/v1.1.0.tar.gz", + ) + +def tink_cc_testonly_deps(): + """Test only dependencies for tink-cc.""" + + # ------------------------------------------------------------------------- + # Wycheproof. # ------------------------------------------------------------------------- - if not native.existing_rule("com_google_googletest"): - # Release from 2021-06-11. - http_archive( - name = "com_google_googletest", - strip_prefix = "googletest-release-1.11.0", - url = "https://github.com/google/googletest/archive/refs/tags/release-1.11.0.tar.gz", - sha256 = "b4870bf121ff7795ba20d20bcdd8627b8e088f2d1dab299a031c1034eddc93d5", - ) + # Commit from 2019-12-17. + maybe( + http_archive, + name = "wycheproof", + sha256 = "eb1d558071acf1aa6d677d7f1cabec2328d1cf8381496c17185bd92b52ce7545", + strip_prefix = "wycheproof-d8ed1ba95ac4c551db67f410c06131c3bc00a97c", + url = "https://github.com/google/wycheproof/archive/d8ed1ba95ac4c551db67f410c06131c3bc00a97c.zip", + ) # ------------------------------------------------------------------------- - # Wycheproof (depends on Rapidjson). + # GoogleTest/GoogleMock. # ------------------------------------------------------------------------- - if not native.existing_rule("rapidjson"): - # Release from 2016-08-25 (still the latest release as of 2022-05-05). - http_archive( - name = "rapidjson", - url = "https://github.com/Tencent/rapidjson/archive/v1.1.0.tar.gz", - sha256 = "bf7ced29704a1e696fbccf2a2b4ea068e7774fa37f6d7dd4039d0787f8bed98e", - strip_prefix = "rapidjson-1.1.0", - build_file = "@tink_cc//:third_party/rapidjson.BUILD.bazel", - ) - if not native.existing_rule("wycheproof"): - # Commit from 2019-12-17. - http_archive( - name = "wycheproof", - strip_prefix = "wycheproof-d8ed1ba95ac4c551db67f410c06131c3bc00a97c", - url = "https://github.com/google/wycheproof/archive/d8ed1ba95ac4c551db67f410c06131c3bc00a97c.zip", - sha256 = "eb1d558071acf1aa6d677d7f1cabec2328d1cf8381496c17185bd92b52ce7545", - ) + # Release from 2023-08-02. + maybe( + http_archive, + name = "com_google_googletest", + sha256 = "1f357c27ca988c3f7c6b4bf68a9395005ac6761f034046e9dde0896e3aba00e4", + strip_prefix = "googletest-1.14.0", + url = "https://github.com/google/googletest/archive/refs/tags/v1.14.0.zip", + ) diff --git a/cmake/TinkWorkspace.cmake b/cmake/TinkWorkspace.cmake index b7410d5882..04de567415 100644 --- a/cmake/TinkWorkspace.cmake +++ b/cmake/TinkWorkspace.cmake @@ -61,8 +61,8 @@ if (TINK_BUILD_TESTS) else() http_archive( NAME googletest - URL https://github.com/google/googletest/archive/refs/tags/release-1.11.0.tar.gz - SHA256 b4870bf121ff7795ba20d20bcdd8627b8e088f2d1dab299a031c1034eddc93d5 + URL https://github.com/google/googletest/archive/refs/tags/v1.14.0.zip + SHA256 1f357c27ca988c3f7c6b4bf68a9395005ac6761f034046e9dde0896e3aba00e4 ) endif() @@ -79,11 +79,11 @@ if (TINK_BUILD_TESTS) endif() if (NOT TINK_USE_INSTALLED_ABSEIL) - # Release from 2023-08-02. + # Release from 2023-09-18. http_archive( NAME abseil - URL https://github.com/abseil/abseil-cpp/archive/refs/tags/20230802.0.zip - SHA256 2942db09db29359e0c1982986167167d226e23caac50eea1f07b2eb2181169cf + URL https://github.com/abseil/abseil-cpp/archive/refs/tags/20230802.1.zip + SHA256 497ebdc3a4885d9209b9bd416e8c3f71e7a1fb8af249f6c2a80b7cbeefcd7e21 ) else() # This is everything that needs to be done here. Abseil already defines its @@ -95,14 +95,12 @@ endif() # defined. if (NOT TARGET crypto) if (NOT TINK_USE_SYSTEM_OPENSSL) - # Commit from Feb 15, 2023. - # NOTE: This is one commit ahead of Bazel; the commit fixes a CMake issue, - # which made build fail on CMake 3.10. - # See https://github.com/google/boringssl/compare/5c22014...e27ff0e. + # Commit from 2023-09-08. + # TODO(b/319145660): Use a later version once we can force /std:c11 on MSVC. http_archive( NAME boringssl - URL https://github.com/google/boringssl/archive/e27ff0e4312c91357778b36bbd8a7ec7bfc67be3.zip - SHA256 11d3c87906bed215a915b0db11cefd0fc7b939ddbec4952a29e343a83ce3bc50 + URL https://github.com/google/boringssl/archive/667d54c96acda029523c5bf425e8eb9079dbe94a.zip + SHA256 21b2086e9242b87415767fd6d2d13bd0481e2eb3c336c7ffa24b1f3d7afb09ae CMAKE_SUBDIR src ) # BoringSSL targets do not carry include directory info, this fixes it.