Skip to content

Commit

Permalink
Add abseil
Browse files Browse the repository at this point in the history
  • Loading branch information
veblush committed Dec 18, 2019
1 parent f20cfa8 commit 4aa42f4
Show file tree
Hide file tree
Showing 35 changed files with 882 additions and 306 deletions.
14 changes: 9 additions & 5 deletions BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,6 @@ 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
Expand Down Expand Up @@ -541,6 +536,9 @@ grpc_cc_library(
"src/core/lib/gprpp/thd.h",
"src/core/lib/profiling/timers.h",
],
external_deps = [
"absl/strings",
],
language = "c++",
public_hdrs = GPR_PUBLIC_HDRS,
deps = [
Expand Down Expand Up @@ -595,6 +593,9 @@ grpc_cc_library(

grpc_cc_library(
name = "inlined_vector",
external_deps = [
"absl/container:inlined_vector",
],
language = "c++",
public_hdrs = [
"src/core/lib/gprpp/inlined_vector.h",
Expand All @@ -612,6 +613,9 @@ grpc_cc_library(

grpc_cc_library(
name = "optional",
external_deps = [
"absl/types:optional",
],
language = "c++",
public_hdrs = [
"src/core/lib/gprpp/optional.h",
Expand Down
3 changes: 3 additions & 0 deletions BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,9 @@ config("grpc_config") {
"src/core/lib/profiling/timers.h",
]
deps = [
":absl/container:inlined_vector",
":absl/strings:strings",
":absl/types:optional",
]

public_configs = [
Expand Down
27 changes: 13 additions & 14 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,9 @@ else()
set(gRPC_BENCHMARK_PROVIDER "none")
endif()

set(gRPC_ABSL_PROVIDER "module" CACHE STRING "Provider of absl library")
set_property(CACHE gRPC_ABSL_PROVIDER PROPERTY STRINGS "module" "package")

set(gRPC_USE_PROTO_LITE OFF CACHE BOOL "Use the protobuf-lite library")

if(UNIX)
Expand Down Expand Up @@ -153,6 +156,7 @@ else()
set(_gRPC_CORE_NOSTDCXX_FLAGS "")
endif()

include(cmake/abseil-cpp.cmake)
include(cmake/address_sorting.cmake)
include(cmake/benchmark.cmake)
include(cmake/cares.cmake)
Expand Down Expand Up @@ -1051,6 +1055,9 @@ target_include_directories(gpr
)
target_link_libraries(gpr
${_gRPC_ALLTARGETS_LIBRARIES}
absl::inlined_vector
absl::strings
absl::optional
)
if(_gRPC_PLATFORM_ANDROID)
target_link_libraries(gpr
Expand Down Expand Up @@ -3253,6 +3260,7 @@ target_include_directories(dns_test_util
target_link_libraries(dns_test_util
${_gRPC_PROTOBUF_LIBRARIES}
${_gRPC_ALLTARGETS_LIBRARIES}
gpr
${_gRPC_GFLAGS_LIBRARIES}
)

Expand Down Expand Up @@ -5829,15 +5837,6 @@ target_link_libraries(grpc_csharp_ext
)



if(gRPC_INSTALL)
install(TARGETS grpc_csharp_ext EXPORT gRPCTargets
RUNTIME DESTINATION ${gRPC_INSTALL_BINDIR}
LIBRARY DESTINATION ${gRPC_INSTALL_LIBDIR}
ARCHIVE DESTINATION ${gRPC_INSTALL_LIBDIR}
)
endif()

endif()

add_library(upb
Expand Down Expand Up @@ -18355,7 +18354,7 @@ generate_pkgconfig(
"gRPC platform support library"
"${gRPC_CORE_VERSION}"
""
"-lgpr"
"-lgpr -labsl_strings -labsl_base -labsl_spinlock_wait -labsl_dynamic_annotations -labsl_strings_internal -labsl_throw_delegate -labsl_int128 -labsl_bad_optional_access -labsl_raw_logging_internal -labsl_log_severity"
""
"gpr.pc")

Expand All @@ -18365,7 +18364,7 @@ generate_pkgconfig(
"high performance general RPC framework"
"${gRPC_CORE_VERSION}"
"gpr openssl"
"-lgrpc -laddress_sorting -lupb -lcares -lz"
"-lgrpc -laddress_sorting -lupb -lcares -lz "
""
"grpc.pc")

Expand All @@ -18375,7 +18374,7 @@ generate_pkgconfig(
"high performance general RPC framework without SSL"
"${gRPC_CORE_VERSION}"
"gpr"
"-lgrpc_unsecure"
"-lgrpc_unsecure "
""
"grpc_unsecure.pc")

Expand All @@ -18385,7 +18384,7 @@ generate_pkgconfig(
"C++ wrapper for gRPC"
"${PACKAGE_VERSION}"
"grpc"
"-lgrpc++"
"-lgrpc++ "
""
"grpc++.pc")

Expand All @@ -18395,6 +18394,6 @@ generate_pkgconfig(
"C++ wrapper for gRPC without SSL"
"${PACKAGE_VERSION}"
"grpc_unsecure"
"-lgrpc++_unsecure"
"-lgrpc++_unsecure "
""
"grpc++_unsecure.pc")
310 changes: 203 additions & 107 deletions Makefile

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions PYTHON-MANIFEST.in
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ graft src/python/grpcio/grpcio.egg-info
graft src/core
graft src/boringssl
graft include/grpc
graft third_party/abseil-cpp/absl
graft third_party/address_sorting
graft third_party/boringssl
graft third_party/cares
Expand Down
23 changes: 1 addition & 22 deletions bazel/grpc_build_system.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -85,23 +85,6 @@ def grpc_cc_library(
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": [],
})
if name == "gpr_base":
more_external_deps += select({
"//:grpc_use_absl": ["@com_google_absl//absl/strings:strings"],
"//conditions:default": [],
})

native.cc_library(
name = name,
srcs = srcs,
Expand All @@ -117,13 +100,9 @@ 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) + more_external_deps,
deps = deps + _get_external_deps(external_deps),
copts = copts,
visibility = visibility,
testonly = testonly,
Expand Down
9 changes: 8 additions & 1 deletion build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,10 @@ filegroups:
- src/core/lib/gprpp/thd_windows.cc
- src/core/lib/profiling/basic_timers.cc
- src/core/lib/profiling/stap_timers.cc
deps:
- absl/container:inlined_vector
- absl/strings:strings
- absl/types:optional
uses:
- gpr_base_headers
- name: gpr_base_headers
Expand Down Expand Up @@ -1848,6 +1852,8 @@ libs:
- test/cpp/naming/dns_test_util.h
src:
- test/cpp/naming/dns_test_util.cc
deps:
- gpr
- name: grpc++
build: all
language: c++
Expand Down Expand Up @@ -6227,7 +6233,8 @@ defaults:
global:
CFLAGS: -g
COREFLAGS: -fno-exceptions
CPPFLAGS: -g -Wall -Wextra -DOSATOMIC_USE_INLINED=1 -Ithird_party/upb -Isrc/core/ext/upb-generated
CPPFLAGS: -g -Wall -Wextra -DOSATOMIC_USE_INLINED=1 -Ithird_party/abseil-cpp -Ithird_party/upb
-Isrc/core/ext/upb-generated
LDFLAGS: -g
zlib:
CFLAGS: -fvisibility=hidden
Expand Down
39 changes: 39 additions & 0 deletions cmake/abseil-cpp.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,48 @@ if(gRPC_ABSL_PROVIDER STREQUAL "module")
endif()
if(EXISTS "${ABSL_ROOT_DIR}/CMakeLists.txt")
add_subdirectory(${ABSL_ROOT_DIR} third_party/abseil-cpp)
if(TARGET absl_base)
if(gRPC_INSTALL AND _gRPC_INSTALL_SUPPORTED_FROM_MODULE)
install(TARGETS
absl_algorithm
absl_atomic_hook
absl_bad_optional_access
absl_base
absl_base_internal
absl_bits
absl_compressed_tuple
absl_config
absl_core_headers
absl_dynamic_annotations
absl_endian
absl_inlined_vector
absl_inlined_vector_internal
absl_int128
absl_log_severity
absl_memory
absl_meta
absl_optional
absl_raw_logging_internal
absl_span
absl_spinlock_wait
absl_strings
absl_strings_internal
absl_throw_delegate
absl_type_traits
absl_utility
EXPORT gRPCTargets
RUNTIME DESTINATION ${gRPC_INSTALL_BINDIR}
LIBRARY DESTINATION ${gRPC_INSTALL_LIBDIR}
ARCHIVE DESTINATION ${gRPC_INSTALL_LIBDIR})
endif()
endif()
else()
message(WARNING "gRPC_ABSL_PROVIDER is \"module\" but ABSL_ROOT_DIR is wrong")
endif()
if(gRPC_INSTALL AND NOT _gRPC_INSTALL_SUPPORTED_FROM_MODULE)
message(WARNING "gRPC_INSTALL will be forced to FALSE because gRPC_ABSL_PROVIDER is \"module\" and CMake version (${CMAKE_VERSION}) is less than 3.13.")
set(gRPC_INSTALL FALSE)
endif()
elseif(gRPC_ABSL_PROVIDER STREQUAL "package")
# Use "CONFIG" as there is no built-in cmake module for absl.
find_package(absl REQUIRED CONFIG)
Expand Down
1 change: 1 addition & 0 deletions cmake/gRPCConfig.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_LIST_DIR}/modules)
@_gRPC_FIND_PROTOBUF@
@_gRPC_FIND_SSL@
@_gRPC_FIND_CARES@
@_gRPC_FIND_ABSL@

# Targets
include(${CMAKE_CURRENT_LIST_DIR}/gRPCTargets.cmake)
34 changes: 34 additions & 0 deletions config.m4
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ if test "$PHP_GRPC" != "no"; then
PHP_ADD_INCLUDE(PHP_EXT_SRCDIR()/include)
PHP_ADD_INCLUDE(PHP_EXT_SRCDIR()/src/core/ext/upb-generated)
PHP_ADD_INCLUDE(PHP_EXT_SRCDIR()/src/php/ext/grpc)
PHP_ADD_INCLUDE(PHP_EXT_SRCDIR()/third_party/abseil-cpp)
PHP_ADD_INCLUDE(PHP_EXT_SRCDIR()/third_party/address_sorting/include)
PHP_ADD_INCLUDE(PHP_EXT_SRCDIR()/third_party/boringssl/include)
PHP_ADD_INCLUDE(PHP_EXT_SRCDIR()/third_party/upb)
Expand Down Expand Up @@ -459,6 +460,33 @@ if test "$PHP_GRPC" != "no"; then
src/php/ext/grpc/server.c \
src/php/ext/grpc/server_credentials.c \
src/php/ext/grpc/timeval.c \
third_party/abseil-cpp/absl/base/dynamic_annotations.cc \
third_party/abseil-cpp/absl/base/internal/cycleclock.cc \
third_party/abseil-cpp/absl/base/internal/raw_logging.cc \
third_party/abseil-cpp/absl/base/internal/spinlock.cc \
third_party/abseil-cpp/absl/base/internal/spinlock_wait.cc \
third_party/abseil-cpp/absl/base/internal/sysinfo.cc \
third_party/abseil-cpp/absl/base/internal/thread_identity.cc \
third_party/abseil-cpp/absl/base/internal/throw_delegate.cc \
third_party/abseil-cpp/absl/base/internal/unscaledcycleclock.cc \
third_party/abseil-cpp/absl/base/log_severity.cc \
third_party/abseil-cpp/absl/numeric/int128.cc \
third_party/abseil-cpp/absl/strings/ascii.cc \
third_party/abseil-cpp/absl/strings/charconv.cc \
third_party/abseil-cpp/absl/strings/escaping.cc \
third_party/abseil-cpp/absl/strings/internal/charconv_bigint.cc \
third_party/abseil-cpp/absl/strings/internal/charconv_parse.cc \
third_party/abseil-cpp/absl/strings/internal/memutil.cc \
third_party/abseil-cpp/absl/strings/internal/ostringstream.cc \
third_party/abseil-cpp/absl/strings/internal/utf8.cc \
third_party/abseil-cpp/absl/strings/match.cc \
third_party/abseil-cpp/absl/strings/numbers.cc \
third_party/abseil-cpp/absl/strings/str_cat.cc \
third_party/abseil-cpp/absl/strings/str_replace.cc \
third_party/abseil-cpp/absl/strings/str_split.cc \
third_party/abseil-cpp/absl/strings/string_view.cc \
third_party/abseil-cpp/absl/strings/substitute.cc \
third_party/abseil-cpp/absl/types/bad_optional_access.cc \
third_party/address_sorting/address_sorting.c \
third_party/address_sorting/address_sorting_posix.c \
third_party/address_sorting/address_sorting_windows.c \
Expand Down Expand Up @@ -832,6 +860,12 @@ if test "$PHP_GRPC" != "no"; then
PHP_ADD_BUILD_DIR($ext_builddir/src/core/tsi/alts/zero_copy_frame_protector)
PHP_ADD_BUILD_DIR($ext_builddir/src/core/tsi/ssl/session_cache)
PHP_ADD_BUILD_DIR($ext_builddir/src/php/ext/grpc)
PHP_ADD_BUILD_DIR($ext_builddir/third_party/abseil-cpp/absl/base)
PHP_ADD_BUILD_DIR($ext_builddir/third_party/abseil-cpp/absl/base/internal)
PHP_ADD_BUILD_DIR($ext_builddir/third_party/abseil-cpp/absl/numeric)
PHP_ADD_BUILD_DIR($ext_builddir/third_party/abseil-cpp/absl/strings)
PHP_ADD_BUILD_DIR($ext_builddir/third_party/abseil-cpp/absl/strings/internal)
PHP_ADD_BUILD_DIR($ext_builddir/third_party/abseil-cpp/absl/types)
PHP_ADD_BUILD_DIR($ext_builddir/third_party/address_sorting)
PHP_ADD_BUILD_DIR($ext_builddir/third_party/boringssl/crypto)
PHP_ADD_BUILD_DIR($ext_builddir/third_party/boringssl/crypto/asn1)
Expand Down
36 changes: 36 additions & 0 deletions config.w32
Original file line number Diff line number Diff line change
Expand Up @@ -429,6 +429,33 @@ if (PHP_GRPC != "no") {
"src\\php\\ext\\grpc\\server.c " +
"src\\php\\ext\\grpc\\server_credentials.c " +
"src\\php\\ext\\grpc\\timeval.c " +
"third_party\\abseil-cpp\\absl\\base\\dynamic_annotations.cc " +
"third_party\\abseil-cpp\\absl\\base\\internal\\cycleclock.cc " +
"third_party\\abseil-cpp\\absl\\base\\internal\\raw_logging.cc " +
"third_party\\abseil-cpp\\absl\\base\\internal\\spinlock.cc " +
"third_party\\abseil-cpp\\absl\\base\\internal\\spinlock_wait.cc " +
"third_party\\abseil-cpp\\absl\\base\\internal\\sysinfo.cc " +
"third_party\\abseil-cpp\\absl\\base\\internal\\thread_identity.cc " +
"third_party\\abseil-cpp\\absl\\base\\internal\\throw_delegate.cc " +
"third_party\\abseil-cpp\\absl\\base\\internal\\unscaledcycleclock.cc " +
"third_party\\abseil-cpp\\absl\\base\\log_severity.cc " +
"third_party\\abseil-cpp\\absl\\numeric\\int128.cc " +
"third_party\\abseil-cpp\\absl\\strings\\ascii.cc " +
"third_party\\abseil-cpp\\absl\\strings\\charconv.cc " +
"third_party\\abseil-cpp\\absl\\strings\\escaping.cc " +
"third_party\\abseil-cpp\\absl\\strings\\internal\\charconv_bigint.cc " +
"third_party\\abseil-cpp\\absl\\strings\\internal\\charconv_parse.cc " +
"third_party\\abseil-cpp\\absl\\strings\\internal\\memutil.cc " +
"third_party\\abseil-cpp\\absl\\strings\\internal\\ostringstream.cc " +
"third_party\\abseil-cpp\\absl\\strings\\internal\\utf8.cc " +
"third_party\\abseil-cpp\\absl\\strings\\match.cc " +
"third_party\\abseil-cpp\\absl\\strings\\numbers.cc " +
"third_party\\abseil-cpp\\absl\\strings\\str_cat.cc " +
"third_party\\abseil-cpp\\absl\\strings\\str_replace.cc " +
"third_party\\abseil-cpp\\absl\\strings\\str_split.cc " +
"third_party\\abseil-cpp\\absl\\strings\\string_view.cc " +
"third_party\\abseil-cpp\\absl\\strings\\substitute.cc " +
"third_party\\abseil-cpp\\absl\\types\\bad_optional_access.cc " +
"third_party\\address_sorting\\address_sorting.c " +
"third_party\\address_sorting\\address_sorting_posix.c " +
"third_party\\address_sorting\\address_sorting_windows.c " +
Expand Down Expand Up @@ -724,6 +751,7 @@ if (PHP_GRPC != "no") {
"/I"+configure_module_dirname+"\\include "+
"/I"+configure_module_dirname+"\\src\\core\\ext\\upb-generated "+
"/I"+configure_module_dirname+"\\src\\php\\ext\\grpc "+
"/I"+configure_module_dirname+"\\third_party\\abseil-cpp "+
"/I"+configure_module_dirname+"\\third_party\\address_sorting\\include "+
"/I"+configure_module_dirname+"\\third_party\\boringssl\\include "+
"/I"+configure_module_dirname+"\\third_party\\upb "+
Expand Down Expand Up @@ -858,6 +886,14 @@ if (PHP_GRPC != "no") {
FSO.CreateFolder(base_dir+"\\ext\\grpc\\src\\php\\ext");
FSO.CreateFolder(base_dir+"\\ext\\grpc\\src\\php\\ext\\grpc");
FSO.CreateFolder(base_dir+"\\ext\\grpc\\third_party");
FSO.CreateFolder(base_dir+"\\ext\\grpc\\third_party\\abseil-cpp");
FSO.CreateFolder(base_dir+"\\ext\\grpc\\third_party\\abseil-cpp\\absl");
FSO.CreateFolder(base_dir+"\\ext\\grpc\\third_party\\abseil-cpp\\absl\\base");
FSO.CreateFolder(base_dir+"\\ext\\grpc\\third_party\\abseil-cpp\\absl\\base\\internal");
FSO.CreateFolder(base_dir+"\\ext\\grpc\\third_party\\abseil-cpp\\absl\\numeric");
FSO.CreateFolder(base_dir+"\\ext\\grpc\\third_party\\abseil-cpp\\absl\\strings");
FSO.CreateFolder(base_dir+"\\ext\\grpc\\third_party\\abseil-cpp\\absl\\strings\\internal");
FSO.CreateFolder(base_dir+"\\ext\\grpc\\third_party\\abseil-cpp\\absl\\types");
FSO.CreateFolder(base_dir+"\\ext\\grpc\\third_party\\address_sorting");
FSO.CreateFolder(base_dir+"\\ext\\grpc\\third_party\\boringssl");
FSO.CreateFolder(base_dir+"\\ext\\grpc\\third_party\\boringssl\\crypto");
Expand Down
Loading

0 comments on commit 4aa42f4

Please sign in to comment.