Merge pull request #20918 from veblush/absl-flag

Add GRPC_USE_ABSL flag
pull/20927/head
Esun Kim 5 years ago committed by GitHub
commit 03cc0a1024
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 5
      BUILD
  2. 21
      bazel/grpc_build_system.bzl
  3. 7
      include/grpc/impl/codegen/port_platform.h
  4. 13
      src/core/lib/gprpp/inlined_vector.h
  5. 4
      tools/internal_ci/linux/grpc_bazel_build_in_docker.sh

@ -69,6 +69,11 @@ config_setting(
values = {"cpu": "darwin"},
)
config_setting(
name = "grpc_use_absl",
values = {"define": "GRPC_USE_ABSL=1"},
)
python_config_settings()
# This should be updated along with build.yaml

@ -59,6 +59,8 @@ def _get_external_deps(external_deps):
})
elif dep == "cronet_c_for_grpc":
ret += ["//third_party/objective_c/Cronet:cronet_c_for_grpc"]
elif dep.startswith("absl/"):
ret += ["@com_google_absl//" + dep]
else:
ret += ["//external:" + dep]
return ret
@ -86,6 +88,19 @@ def grpc_cc_library(
linkopts = if_not_windows(["-pthread"])
if use_cfstream:
linkopts = linkopts + if_mac(["-framework CoreFoundation"])
# This is a temporary solution to enable absl dependency only for
# Bazel-build with grpc_use_absl enabled to abseilfy in-house classes
# such as inlined_vector before absl is fully supported.
# When https://github.com/grpc/grpc/pull/20184 is merged, it will
# be removed.
more_external_deps = []
if name == "inlined_vector":
more_external_deps += select({
"//:grpc_use_absl": ["@com_google_absl//absl/container:inlined_vector"],
"//conditions:default": [],
})
native.cc_library(
name = name,
srcs = srcs,
@ -101,9 +116,13 @@ def grpc_cc_library(
"//:grpc_allow_exceptions": ["GRPC_ALLOW_EXCEPTIONS=1"],
"//:grpc_disallow_exceptions": ["GRPC_ALLOW_EXCEPTIONS=0"],
"//conditions:default": [],
}) +
select({
"//:grpc_use_absl": ["GRPC_USE_ABSL=1"],
"//conditions:default": [],
}),
hdrs = hdrs + public_hdrs,
deps = deps + _get_external_deps(external_deps),
deps = deps + _get_external_deps(external_deps) + more_external_deps,
copts = copts,
visibility = visibility,
testonly = testonly,

@ -27,6 +27,13 @@
* - some syscalls to be made directly
*/
/*
* Defines GRPC_USE_ABSL to use Abseil Common Libraries (C++)
*/
#ifndef GRPC_USE_ABSL
#define GRPC_USE_ABSL 0
#endif
/* Get windows.h included everywhere (we need it) */
#if defined(_WIN64) || defined(WIN64) || defined(_WIN32) || defined(WIN32)
#ifndef WIN32_LEAN_AND_MEAN

@ -26,8 +26,19 @@
#include "src/core/lib/gprpp/memory.h"
#if GRPC_USE_ABSL
#include "absl/container/inlined_vector.h"
#endif
namespace grpc_core {
#if GRPC_USE_ABSL
template <typename T, size_t N, typename A = std::allocator<T>>
using InlinedVector = absl::InlinedVector<T, N, A>;
#else
// NOTE: We eventually want to use absl::InlinedVector here. However,
// there are currently build problems that prevent us from using absl.
// In the interim, we define a custom implementation as a place-holder,
@ -228,6 +239,8 @@ class InlinedVector {
size_t capacity_;
};
#endif
} // namespace grpc_core
#endif /* GRPC_CORE_LIB_GPRPP_INLINED_VECTOR_H */

@ -25,3 +25,7 @@ git clone /var/local/jenkins/grpc /var/local/git/grpc
${name}')
cd /var/local/git/grpc
bazel build --spawn_strategy=standalone --genrule_strategy=standalone :all test/... examples/...
# This is a temporary build test before full absl support is done
# with https://github.com/grpc/grpc/pull/20918.
bazel build --spawn_strategy=standalone --genrule_strategy=standalone --define=GRPC_USE_ABSL=1 :grpc

Loading…
Cancel
Save