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
This commit is contained in:
Christian Blichmann 2023-06-09 03:21:27 -07:00 committed by Copybara-Service
parent 4034fd6240
commit 045ace8dcb
11 changed files with 53 additions and 31 deletions

View File

@ -1,6 +1,6 @@
![Sandbox](sandboxed_api/docs/images/sapi-lockup-vertical.png) ![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) [![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) [![CMake build status](https://github.com/google/sandboxed-api/workflows/CMake/badge.svg)](https://github.com/google/sandboxed-api/actions?query=workflow%3ACMake)

View File

@ -193,8 +193,10 @@ function(sapi_protobuf_generate)
VERBATIM) VERBATIM)
endforeach() endforeach()
set_source_files_properties(${_generated_srcs_all} set_source_files_properties(${_generated_srcs_all} PROPERTIES
PROPERTIES GENERATED TRUE) GENERATED TRUE
INCLUDE_DIRECTORIES "${absl_SOURCE_DIR}"
)
if(_pb_OUT_VAR) if(_pb_OUT_VAR)
set(${_pb_OUT_VAR} ${_generated_srcs_all} PARENT_SCOPE) set(${_pb_OUT_VAR} ${_generated_srcs_all} PARENT_SCOPE)
endif() endif()

View File

@ -14,7 +14,7 @@
FetchContent_Declare(absl FetchContent_Declare(absl
GIT_REPOSITORY https://github.com/abseil/abseil-cpp 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_CXX_STANDARD ${SAPI_CXX_STANDARD} CACHE STRING "" FORCE)
set(ABSL_PROPAGATE_CXX_STD ON CACHE BOOL "" FORCE) set(ABSL_PROPAGATE_CXX_STD ON CACHE BOOL "" FORCE)

View File

@ -14,7 +14,7 @@
FetchContent_Declare(benchmark FetchContent_Declare(benchmark
GIT_REPOSITORY https://github.com/google/benchmark.git 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_TESTING OFF)
set(BENCHMARK_ENABLE_EXCEPTIONS OFF) set(BENCHMARK_ENABLE_EXCEPTIONS OFF)

View File

@ -14,6 +14,6 @@
FetchContent_Declare(googletest FetchContent_Declare(googletest
GIT_REPOSITORY https://github.com/google/googletest.git GIT_REPOSITORY https://github.com/google/googletest.git
GIT_TAG 9a32aee22d771387c494be2d8519fbdf46a713b2 # 2021-12-20 GIT_TAG 334704df263b480a3e9e7441ed3292a5e30a37ec # 2023-06-06
) )
FetchContent_MakeAvailable(googletest) FetchContent_MakeAvailable(googletest)

View File

@ -14,7 +14,7 @@
FetchContent_Declare(protobuf FetchContent_Declare(protobuf
GIT_REPOSITORY https://github.com/protocolbuffers/protobuf.git 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) set(protobuf_ABSL_PROVIDER "package" CACHE STRING "" FORCE)

View File

@ -14,7 +14,7 @@
"""Generates proto targets in various languages.""" """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): def _cc_proto_library_name_from_proto_name(name):
"""Converts proto name to cc_proto_library name. """Converts proto name to cc_proto_library name.
@ -69,16 +69,18 @@ def sapi_proto_library(
if kwargs.get("has_services", False): if kwargs.get("has_services", False):
fail("Services are not currently supported.") fail("Services are not currently supported.")
cc_proto_library( proto_library(
name = name, name = name,
srcs = srcs, srcs = srcs,
deps = deps, deps = deps,
alwayslink = alwayslink, )
**kwargs native.cc_proto_library(
name = name + "_sapi_cc_proto",
deps = [name],
) )
native.cc_library( native.cc_library(
name = _cc_proto_library_name_from_proto_name(name), name = _cc_proto_library_name_from_proto_name(name),
deps = [name], deps = [name + "_sapi_cc_proto"],
alwayslink = alwayslink, alwayslink = alwayslink,
**kwargs **kwargs
) )

View File

@ -26,20 +26,20 @@ def sapi_deps():
maybe( maybe(
http_archive, http_archive,
name = "bazel_skylib", name = "bazel_skylib",
sha256 = "66ffd9315665bfaafc96b52278f57c7e2dd09f5ede279ea6d39b2be471e7e3aa",
urls = [ 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.4.2/bazel-skylib-1.4.2.tar.gz",
"https://mirror.bazel.build/github.com/bazelbuild/bazel-skylib/releases/download/1.2.1/bazel-skylib-1.2.1.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 # Abseil
maybe( maybe(
http_archive, http_archive,
name = "com_google_absl", name = "com_google_absl",
sha256 = "adca6c26a90d6791e36bfe5dbc8573182c5fa0726da29901a6b3949d65116e25", # 2023-03-20 sha256 = "fbe050daabadda2297cea9ace55ccde48e3994887bc0b1e6c7330f1a97ee071b", # 2023-06-08
strip_prefix = "abseil-cpp-efeb95f4491740817a1c37345b66d26bce722ae4", strip_prefix = "abseil-cpp-ae87791869cacbc125aa708108c4721e51ff703d",
urls = ["https://github.com/abseil/abseil-cpp/archive/efeb95f4491740817a1c37345b66d26bce722ae4.zip"], urls = ["https://github.com/abseil/abseil-cpp/archive/ae87791869cacbc125aa708108c4721e51ff703d.zip"],
) )
maybe( maybe(
http_archive, http_archive,
@ -63,9 +63,9 @@ def sapi_deps():
maybe( maybe(
http_archive, http_archive,
name = "com_google_protobuf", name = "com_google_protobuf",
sha256 = "0ac0d92cba957fdfc77cab689ffc56d52ce2ff89ebcc384e4e682e6f9d218071", # 2022-09-14 sha256 = "ddf8c9c1ffccb7e80afd183b3bd32b3b62f7cc54b106be190bf49f2bc09daab5", # 2023-05-26
strip_prefix = "protobuf-3.21.6", strip_prefix = "protobuf-23.2",
urls = ["https://github.com/protocolbuffers/protobuf/archive/v3.21.6.zip"], urls = ["https://github.com/protocolbuffers/protobuf/releases/download/v23.2/protobuf-23.2.tar.gz"],
) )
# libcap # libcap
@ -105,18 +105,18 @@ def sapi_deps():
maybe( maybe(
http_archive, http_archive,
name = "com_google_googletest", name = "com_google_googletest",
sha256 = "1009ce4e75a64a4e61bcb2efaa256f9d54e6a859a2985cb6fa57c06d45356866", # 2021-12-20 sha256 = "a217118c2c36a3632b594af7ff98111a65bb2b980b726a7fa62305e02a998440", # 2023-06-06
strip_prefix = "googletest-9a32aee22d771387c494be2d8519fbdf46a713b2", strip_prefix = "googletest-334704df263b480a3e9e7441ed3292a5e30a37ec",
urls = ["https://github.com/google/googletest/archive/9a32aee22d771387c494be2d8519fbdf46a713b2.zip"], urls = ["https://github.com/google/googletest/archive/334704df263b480a3e9e7441ed3292a5e30a37ec.zip"],
) )
# Google Benchmark # Google Benchmark
maybe( maybe(
http_archive, http_archive,
name = "com_google_benchmark", name = "com_google_benchmark",
sha256 = "12663580821c69f5a71217433b58e96f061570f0e18d94891b82115fcdb4284d", # 2021-12-14 sha256 = "342705876335bf894147e052d0dac141fe15962034b41bef5aa59c4b279ca89c", # 2023-05-30
strip_prefix = "benchmark-3b3de69400164013199ea448f051d94d7fc7d81f", strip_prefix = "benchmark-604f6fd3f4b34a84ec4eb4db81d842fa4db829cd",
urls = ["https://github.com/google/benchmark/archive/3b3de69400164013199ea448f051d94d7fc7d81f.zip"], urls = ["https://github.com/google/benchmark/archive/604f6fd3f4b34a84ec4eb4db81d842fa4db829cd.zip"],
) )
# LLVM/libclang # LLVM/libclang

View File

@ -40,7 +40,22 @@ def _init_libclang():
# Try to find libclang in the standard location and a few versioned paths # 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 # that are used on Debian (and others). If LD_LIBRARY_PATH is set, it is
# used as well. # 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 '') libname = 'clang' + ('-' + version if version else '')
libclang = util.find_library(libname) libclang = util.find_library(libname)
if libclang: if libclang:

View File

@ -19,8 +19,8 @@ from __future__ import print_function
from absl.testing import absltest from absl.testing import absltest
from absl.testing import parameterized from absl.testing import parameterized
from clang import cindex from clang import cindex
import code from com_google_sandboxed_api.sandboxed_api.tools.generator2 import code
import code_test_util from com_google_sandboxed_api.sandboxed_api.tools.generator2 import code_test_util
CODE = """ CODE = """
typedef int(fun*)(int,int); typedef int(fun*)(int,int);

View File

@ -21,7 +21,10 @@ import sys
from absl import app from absl import app
from absl import flags from absl import flags
from absl import logging from absl import logging
import code try:
from com_google_sandboxed_api.sandboxed_api.tools.generator2 import code
except:
import code
FLAGS = flags.FLAGS FLAGS = flags.FLAGS