From 045ace8dcb097a37c4c0ce118680e51869685332 Mon Sep 17 00:00:00 2001 From: Christian Blichmann Date: Fri, 9 Jun 2023 03:21:27 -0700 Subject: [PATCH] Update Google dependencies - Abseil - Protobuf - Benchmark - Googletest In turn, some code changes were necessary: - Use absolute imports in `sapi_generator.py` when invoked by Bazel - Add Abseil's source dir as include dir in generated proto `.cc` files - Bazel: Use `@rules_proto` for `proto_library` and use native `cc_proto_library` Drive-by: - Update year in `README.md` - Look for clang versions 16, 15, 14, and 13 as well in `code.py` PiperOrigin-RevId: 539032012 Change-Id: Ib9cd1d7fb38409d884eb45e1fa08927f6af83a21 --- README.md | 2 +- cmake/SapiUtil.cmake | 6 ++-- cmake/abseil-cpp.cmake | 2 +- cmake/benchmark.cmake | 2 +- cmake/googletest.cmake | 2 +- cmake/protobuf.cmake | 2 +- sandboxed_api/bazel/proto.bzl | 12 ++++---- sandboxed_api/bazel/sapi_deps.bzl | 30 +++++++++---------- sandboxed_api/tools/generator2/code.py | 17 ++++++++++- sandboxed_api/tools/generator2/code_test.py | 4 +-- .../tools/generator2/sapi_generator.py | 5 +++- 11 files changed, 53 insertions(+), 31 deletions(-) diff --git a/README.md b/README.md index 332aea1..7e5ea54 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ ![Sandbox](sandboxed_api/docs/images/sapi-lockup-vertical.png) -Copyright 2019-2022 Google LLC +Copyright 2019-2023 Google LLC [![Bazel build status](https://badge.buildkite.com/2f662d7bddfd1c07d25bf92d243538c8344bc6fbf38fe187f8.svg)](https://buildkite.com/bazel/sandboxed-api) [![CMake build status](https://github.com/google/sandboxed-api/workflows/CMake/badge.svg)](https://github.com/google/sandboxed-api/actions?query=workflow%3ACMake) diff --git a/cmake/SapiUtil.cmake b/cmake/SapiUtil.cmake index 1601ba0..e4652fb 100644 --- a/cmake/SapiUtil.cmake +++ b/cmake/SapiUtil.cmake @@ -193,8 +193,10 @@ function(sapi_protobuf_generate) VERBATIM) endforeach() - set_source_files_properties(${_generated_srcs_all} - PROPERTIES GENERATED TRUE) + set_source_files_properties(${_generated_srcs_all} PROPERTIES + GENERATED TRUE + INCLUDE_DIRECTORIES "${absl_SOURCE_DIR}" + ) if(_pb_OUT_VAR) set(${_pb_OUT_VAR} ${_generated_srcs_all} PARENT_SCOPE) endif() diff --git a/cmake/abseil-cpp.cmake b/cmake/abseil-cpp.cmake index 4c92506..feae440 100644 --- a/cmake/abseil-cpp.cmake +++ b/cmake/abseil-cpp.cmake @@ -14,7 +14,7 @@ FetchContent_Declare(absl GIT_REPOSITORY https://github.com/abseil/abseil-cpp - GIT_TAG efeb95f4491740817a1c37345b66d26bce722ae4 # 2023-03-20 + GIT_TAG ae87791869cacbc125aa708108c4721e51ff703d # 2023-06-08 ) set(ABSL_CXX_STANDARD ${SAPI_CXX_STANDARD} CACHE STRING "" FORCE) set(ABSL_PROPAGATE_CXX_STD ON CACHE BOOL "" FORCE) diff --git a/cmake/benchmark.cmake b/cmake/benchmark.cmake index 82cca85..10c8add 100644 --- a/cmake/benchmark.cmake +++ b/cmake/benchmark.cmake @@ -14,7 +14,7 @@ FetchContent_Declare(benchmark GIT_REPOSITORY https://github.com/google/benchmark.git - GIT_TAG 3b3de69400164013199ea448f051d94d7fc7d81f # 2021-12-14 + GIT_TAG 604f6fd3f4b34a84ec4eb4db81d842fa4db829cd # 2023-05-30 ) set(BENCHMARK_ENABLE_TESTING OFF) set(BENCHMARK_ENABLE_EXCEPTIONS OFF) diff --git a/cmake/googletest.cmake b/cmake/googletest.cmake index 9439227..e79eba7 100644 --- a/cmake/googletest.cmake +++ b/cmake/googletest.cmake @@ -14,6 +14,6 @@ FetchContent_Declare(googletest GIT_REPOSITORY https://github.com/google/googletest.git - GIT_TAG 9a32aee22d771387c494be2d8519fbdf46a713b2 # 2021-12-20 + GIT_TAG 334704df263b480a3e9e7441ed3292a5e30a37ec # 2023-06-06 ) FetchContent_MakeAvailable(googletest) diff --git a/cmake/protobuf.cmake b/cmake/protobuf.cmake index 7821b82..71679ef 100644 --- a/cmake/protobuf.cmake +++ b/cmake/protobuf.cmake @@ -14,7 +14,7 @@ FetchContent_Declare(protobuf GIT_REPOSITORY https://github.com/protocolbuffers/protobuf.git - GIT_TAG v3.21.6 # 2022-09-14 + GIT_TAG v23.2 # 2023-05-26 ) set(protobuf_ABSL_PROVIDER "package" CACHE STRING "" FORCE) diff --git a/sandboxed_api/bazel/proto.bzl b/sandboxed_api/bazel/proto.bzl index 115d23a..e67e95e 100644 --- a/sandboxed_api/bazel/proto.bzl +++ b/sandboxed_api/bazel/proto.bzl @@ -14,7 +14,7 @@ """Generates proto targets in various languages.""" -load("@com_google_protobuf//:protobuf.bzl", "cc_proto_library") +load("@rules_proto//proto:defs.bzl", "proto_library") def _cc_proto_library_name_from_proto_name(name): """Converts proto name to cc_proto_library name. @@ -69,16 +69,18 @@ def sapi_proto_library( if kwargs.get("has_services", False): fail("Services are not currently supported.") - cc_proto_library( + proto_library( name = name, srcs = srcs, deps = deps, - alwayslink = alwayslink, - **kwargs + ) + native.cc_proto_library( + name = name + "_sapi_cc_proto", + deps = [name], ) native.cc_library( name = _cc_proto_library_name_from_proto_name(name), - deps = [name], + deps = [name + "_sapi_cc_proto"], alwayslink = alwayslink, **kwargs ) diff --git a/sandboxed_api/bazel/sapi_deps.bzl b/sandboxed_api/bazel/sapi_deps.bzl index 09ad17b..b16ac5a 100644 --- a/sandboxed_api/bazel/sapi_deps.bzl +++ b/sandboxed_api/bazel/sapi_deps.bzl @@ -26,20 +26,20 @@ def sapi_deps(): maybe( http_archive, name = "bazel_skylib", + sha256 = "66ffd9315665bfaafc96b52278f57c7e2dd09f5ede279ea6d39b2be471e7e3aa", urls = [ - "https://github.com/bazelbuild/bazel-skylib/releases/download/1.2.1/bazel-skylib-1.2.1.tar.gz", - "https://mirror.bazel.build/github.com/bazelbuild/bazel-skylib/releases/download/1.2.1/bazel-skylib-1.2.1.tar.gz", + "https://mirror.bazel.build/github.com/bazelbuild/bazel-skylib/releases/download/1.4.2/bazel-skylib-1.4.2.tar.gz", + "https://github.com/bazelbuild/bazel-skylib/releases/download/1.4.2/bazel-skylib-1.4.2.tar.gz", ], - sha256 = "f7be3474d42aae265405a592bb7da8e171919d74c16f082a5457840f06054728", # 2022-03-10 ) # Abseil maybe( http_archive, name = "com_google_absl", - sha256 = "adca6c26a90d6791e36bfe5dbc8573182c5fa0726da29901a6b3949d65116e25", # 2023-03-20 - strip_prefix = "abseil-cpp-efeb95f4491740817a1c37345b66d26bce722ae4", - urls = ["https://github.com/abseil/abseil-cpp/archive/efeb95f4491740817a1c37345b66d26bce722ae4.zip"], + sha256 = "fbe050daabadda2297cea9ace55ccde48e3994887bc0b1e6c7330f1a97ee071b", # 2023-06-08 + strip_prefix = "abseil-cpp-ae87791869cacbc125aa708108c4721e51ff703d", + urls = ["https://github.com/abseil/abseil-cpp/archive/ae87791869cacbc125aa708108c4721e51ff703d.zip"], ) maybe( http_archive, @@ -63,9 +63,9 @@ def sapi_deps(): maybe( http_archive, name = "com_google_protobuf", - sha256 = "0ac0d92cba957fdfc77cab689ffc56d52ce2ff89ebcc384e4e682e6f9d218071", # 2022-09-14 - strip_prefix = "protobuf-3.21.6", - urls = ["https://github.com/protocolbuffers/protobuf/archive/v3.21.6.zip"], + sha256 = "ddf8c9c1ffccb7e80afd183b3bd32b3b62f7cc54b106be190bf49f2bc09daab5", # 2023-05-26 + strip_prefix = "protobuf-23.2", + urls = ["https://github.com/protocolbuffers/protobuf/releases/download/v23.2/protobuf-23.2.tar.gz"], ) # libcap @@ -105,18 +105,18 @@ def sapi_deps(): maybe( http_archive, name = "com_google_googletest", - sha256 = "1009ce4e75a64a4e61bcb2efaa256f9d54e6a859a2985cb6fa57c06d45356866", # 2021-12-20 - strip_prefix = "googletest-9a32aee22d771387c494be2d8519fbdf46a713b2", - urls = ["https://github.com/google/googletest/archive/9a32aee22d771387c494be2d8519fbdf46a713b2.zip"], + sha256 = "a217118c2c36a3632b594af7ff98111a65bb2b980b726a7fa62305e02a998440", # 2023-06-06 + strip_prefix = "googletest-334704df263b480a3e9e7441ed3292a5e30a37ec", + urls = ["https://github.com/google/googletest/archive/334704df263b480a3e9e7441ed3292a5e30a37ec.zip"], ) # Google Benchmark maybe( http_archive, name = "com_google_benchmark", - sha256 = "12663580821c69f5a71217433b58e96f061570f0e18d94891b82115fcdb4284d", # 2021-12-14 - strip_prefix = "benchmark-3b3de69400164013199ea448f051d94d7fc7d81f", - urls = ["https://github.com/google/benchmark/archive/3b3de69400164013199ea448f051d94d7fc7d81f.zip"], + sha256 = "342705876335bf894147e052d0dac141fe15962034b41bef5aa59c4b279ca89c", # 2023-05-30 + strip_prefix = "benchmark-604f6fd3f4b34a84ec4eb4db81d842fa4db829cd", + urls = ["https://github.com/google/benchmark/archive/604f6fd3f4b34a84ec4eb4db81d842fa4db829cd.zip"], ) # LLVM/libclang diff --git a/sandboxed_api/tools/generator2/code.py b/sandboxed_api/tools/generator2/code.py index 961a0a7..b181837 100644 --- a/sandboxed_api/tools/generator2/code.py +++ b/sandboxed_api/tools/generator2/code.py @@ -40,7 +40,22 @@ def _init_libclang(): # Try to find libclang in the standard location and a few versioned paths # that are used on Debian (and others). If LD_LIBRARY_PATH is set, it is # used as well. - for version in ['', '12', '11', '10', '9', '8', '7', '6.0', '5.0', '4.0']: + for version in [ + '', + '16', + '15', + '14', + '13', + '12', + '11', + '10', + '9', + '8', + '7', + '6.0', + '5.0', + '4.0', + ]: libname = 'clang' + ('-' + version if version else '') libclang = util.find_library(libname) if libclang: diff --git a/sandboxed_api/tools/generator2/code_test.py b/sandboxed_api/tools/generator2/code_test.py index 8000c9d..96d4594 100644 --- a/sandboxed_api/tools/generator2/code_test.py +++ b/sandboxed_api/tools/generator2/code_test.py @@ -19,8 +19,8 @@ from __future__ import print_function from absl.testing import absltest from absl.testing import parameterized from clang import cindex -import code -import code_test_util +from com_google_sandboxed_api.sandboxed_api.tools.generator2 import code +from com_google_sandboxed_api.sandboxed_api.tools.generator2 import code_test_util CODE = """ typedef int(fun*)(int,int); diff --git a/sandboxed_api/tools/generator2/sapi_generator.py b/sandboxed_api/tools/generator2/sapi_generator.py index 9eb331b..56a6dab 100644 --- a/sandboxed_api/tools/generator2/sapi_generator.py +++ b/sandboxed_api/tools/generator2/sapi_generator.py @@ -21,7 +21,10 @@ import sys from absl import app from absl import flags from absl import logging -import code +try: + from com_google_sandboxed_api.sandboxed_api.tools.generator2 import code +except: + import code FLAGS = flags.FLAGS