diff options
-rw-r--r-- | Makefile | 4 | ||||
-rw-r--r-- | bazel/grpc_build_system.bzl | 23 | ||||
-rw-r--r-- | bazel/grpc_deps.bzl | 18 | ||||
-rw-r--r-- | setup.py | 3 | ||||
-rw-r--r-- | src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.cc | 4 | ||||
-rw-r--r-- | src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/load_balancer.pb.h | 2 | ||||
-rw-r--r-- | src/core/tsi/alts/handshaker/alts_handshaker_service_api_util.h | 4 | ||||
-rw-r--r-- | src/core/tsi/alts/handshaker/altscontext.pb.h | 2 | ||||
-rw-r--r-- | src/core/tsi/alts/handshaker/handshaker.pb.h | 2 | ||||
-rw-r--r-- | src/core/tsi/alts/handshaker/transport_security_common.pb.h | 2 | ||||
-rw-r--r-- | src/core/tsi/alts/handshaker/transport_security_common_api.h | 4 | ||||
-rw-r--r-- | src/cpp/server/health/default_health_check_service.cc | 4 | ||||
-rw-r--r-- | src/cpp/server/health/health.pb.h | 2 | ||||
-rw-r--r-- | templates/Makefile.template | 4 | ||||
-rw-r--r-- | third_party/nanopb.BUILD | 19 | ||||
-rw-r--r-- | third_party/nanopb/BUILD | 29 | ||||
-rwxr-xr-x | tools/codegen/core/gen_nano_proto.sh | 3 | ||||
-rwxr-xr-x | tools/run_tests/sanity/check_bazel_workspace.py | 5 |
18 files changed, 80 insertions, 54 deletions
@@ -338,7 +338,9 @@ CPPFLAGS += -g -Wall -Wextra -Werror -Wno-long-long -Wno-unused-parameter -DOSAT COREFLAGS += -fno-rtti -fno-exceptions LDFLAGS += -g -DEFINES += PB_FIELD_16BIT +# nanopb tweaks +DEFINES += PB_FIELD_32BIT +CPPFLAGS += -Ithird_party/nanopb CPPFLAGS += $(CPPFLAGS_$(CONFIG)) CFLAGS += $(CFLAGS_$(CONFIG)) diff --git a/bazel/grpc_build_system.bzl b/bazel/grpc_build_system.bzl index 095b1596c8..a682d89ec9 100644 --- a/bazel/grpc_build_system.bzl +++ b/bazel/grpc_build_system.bzl @@ -36,9 +36,7 @@ def if_not_windows(a): def _get_external_deps(external_deps): ret = [] for dep in external_deps: - if dep == "nanopb": - ret += ["grpc_nanopb"] - elif dep == "address_sorting": + if dep == "address_sorting": ret += ["//third_party/address_sorting"] elif dep == "cares": ret += select({"//:grpc_no_ares": [], @@ -160,24 +158,7 @@ def grpc_cc_binary(name, srcs = [], deps = [], external_deps = [], args = [], da linkopts = if_not_windows(["-pthread"]) + linkopts, ) -def grpc_generate_one_off_targets(): - native.cc_library( - name = "grpc_nanopb", - hdrs = [ - "//third_party/nanopb:pb.h", - "//third_party/nanopb:pb_common.h", - "//third_party/nanopb:pb_decode.h", - "//third_party/nanopb:pb_encode.h", - ], - srcs = [ - "//third_party/nanopb:pb_common.c", - "//third_party/nanopb:pb_decode.c", - "//third_party/nanopb:pb_encode.c", - ], - defines = [ - "PB_FIELD_16BIT=1", - ], - ) +def grpc_generate_one_off_targets(): pass def grpc_sh_test(name, srcs, args = [], data = []): native.sh_test( diff --git a/bazel/grpc_deps.bzl b/bazel/grpc_deps.bzl index 162ec1f5f5..f7e62f1219 100644 --- a/bazel/grpc_deps.bzl +++ b/bazel/grpc_deps.bzl @@ -2,6 +2,12 @@ def grpc_deps(): """Loads dependencies need to compile and test the grpc library.""" + + native.bind( + name = "nanopb", + actual = "@com_github_nanopb_nanopb//:nanopb", + ) + native.bind( name = "libssl", actual = "@boringssl//:ssl", @@ -59,12 +65,12 @@ def grpc_deps(): native.bind( name = "grpc_cpp_plugin", - actual = "@com_github_grpc_grpc//:grpc_cpp_plugin" + actual = "@com_github_grpc_grpc//:grpc_cpp_plugin", ) native.bind( name = "grpc++_codegen_proto", - actual = "@com_github_grpc_grpc//:grpc++_codegen_proto" + actual = "@com_github_grpc_grpc//:grpc++_codegen_proto", ) if "boringssl" not in native.existing_rules(): @@ -87,6 +93,14 @@ def grpc_deps(): name = "com_google_protobuf", strip_prefix = "protobuf-b5fbb742af122b565925987e65c08957739976a7", url = "https://github.com/google/protobuf/archive/b5fbb742af122b565925987e65c08957739976a7.tar.gz", + ) + + if "com_github_nanopb_nanopb" not in native.existing_rules(): + native.new_http_archive( + name = "com_github_nanopb_nanopb", + build_file = "@com_github_grpc_grpc//third_party:nanopb.BUILD", + strip_prefix = "nanopb-f8ac463766281625ad710900479130c7fcb4d63b", + url = "https://github.com/nanopb/nanopb/archive/f8ac463766281625ad710900479130c7fcb4d63b.tar.gz", ) if "com_github_google_googletest" not in native.existing_rules(): @@ -37,6 +37,7 @@ PYTHON_STEM = os.path.join('src', 'python', 'grpcio') CORE_INCLUDE = ('include', '.',) SSL_INCLUDE = (os.path.join('third_party', 'boringssl', 'include'),) ZLIB_INCLUDE = (os.path.join('third_party', 'zlib'),) +NANOPB_INCLUDE = (os.path.join('third_party', 'nanopb'),) CARES_INCLUDE = ( os.path.join('third_party', 'cares'), os.path.join('third_party', 'cares', 'cares'),) @@ -181,7 +182,7 @@ if BUILD_WITH_SYSTEM_CARES: EXTENSION_INCLUDE_DIRECTORIES = ( (PYTHON_STEM,) + CORE_INCLUDE + SSL_INCLUDE + ZLIB_INCLUDE + - CARES_INCLUDE + ADDRESS_SORTING_INCLUDE) + NANOPB_INCLUDE + CARES_INCLUDE + ADDRESS_SORTING_INCLUDE) EXTENSION_LIBRARIES = () if "linux" in sys.platform: diff --git a/src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.cc b/src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.cc index ed246273c9..c854e7a9cf 100644 --- a/src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.cc +++ b/src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.cc @@ -18,9 +18,9 @@ #include <grpc/support/port_platform.h> +#include "pb_decode.h" +#include "pb_encode.h" #include "src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.h" -#include "third_party/nanopb/pb_decode.h" -#include "third_party/nanopb/pb_encode.h" #include <grpc/support/alloc.h> diff --git a/src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/load_balancer.pb.h b/src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/load_balancer.pb.h index 066c076202..088b6f513a 100644 --- a/src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/load_balancer.pb.h +++ b/src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/load_balancer.pb.h @@ -3,7 +3,7 @@ #ifndef PB_GRPC_LB_V1_LOAD_BALANCER_PB_H_INCLUDED #define PB_GRPC_LB_V1_LOAD_BALANCER_PB_H_INCLUDED -#include "third_party/nanopb/pb.h" +#include "pb.h" /* @@protoc_insertion_point(includes) */ #if PB_PROTO_HEADER_VERSION != 30 #error Regenerate this file with the current version of nanopb generator. diff --git a/src/core/tsi/alts/handshaker/alts_handshaker_service_api_util.h b/src/core/tsi/alts/handshaker/alts_handshaker_service_api_util.h index 8fe8f73f8b..966ea45617 100644 --- a/src/core/tsi/alts/handshaker/alts_handshaker_service_api_util.h +++ b/src/core/tsi/alts/handshaker/alts_handshaker_service_api_util.h @@ -21,8 +21,8 @@ #include <grpc/support/port_platform.h> -#include "third_party/nanopb/pb_decode.h" -#include "third_party/nanopb/pb_encode.h" +#include "pb_decode.h" +#include "pb_encode.h" #include <grpc/slice.h> #include <grpc/slice_buffer.h> diff --git a/src/core/tsi/alts/handshaker/altscontext.pb.h b/src/core/tsi/alts/handshaker/altscontext.pb.h index 3e72d7f678..f11b2899e9 100644 --- a/src/core/tsi/alts/handshaker/altscontext.pb.h +++ b/src/core/tsi/alts/handshaker/altscontext.pb.h @@ -3,7 +3,7 @@ #ifndef PB_GRPC_GCP_ALTSCONTEXT_PB_H_INCLUDED #define PB_GRPC_GCP_ALTSCONTEXT_PB_H_INCLUDED -#include "third_party/nanopb/pb.h" +#include "pb.h" #include "src/core/tsi/alts/handshaker/transport_security_common.pb.h" /* @@protoc_insertion_point(includes) */ diff --git a/src/core/tsi/alts/handshaker/handshaker.pb.h b/src/core/tsi/alts/handshaker/handshaker.pb.h index 0805a144de..e2b193463c 100644 --- a/src/core/tsi/alts/handshaker/handshaker.pb.h +++ b/src/core/tsi/alts/handshaker/handshaker.pb.h @@ -3,7 +3,7 @@ #ifndef PB_GRPC_GCP_HANDSHAKER_PB_H_INCLUDED #define PB_GRPC_GCP_HANDSHAKER_PB_H_INCLUDED -#include "third_party/nanopb/pb.h" +#include "pb.h" #include "src/core/tsi/alts/handshaker/transport_security_common.pb.h" /* @@protoc_insertion_point(includes) */ diff --git a/src/core/tsi/alts/handshaker/transport_security_common.pb.h b/src/core/tsi/alts/handshaker/transport_security_common.pb.h index 49096dffa3..87d9abf149 100644 --- a/src/core/tsi/alts/handshaker/transport_security_common.pb.h +++ b/src/core/tsi/alts/handshaker/transport_security_common.pb.h @@ -3,7 +3,7 @@ #ifndef PB_GRPC_GCP_TRANSPORT_SECURITY_COMMON_PB_H_INCLUDED #define PB_GRPC_GCP_TRANSPORT_SECURITY_COMMON_PB_H_INCLUDED -#include "third_party/nanopb/pb.h" +#include "pb.h" /* @@protoc_insertion_point(includes) */ #if PB_PROTO_HEADER_VERSION != 30 #error Regenerate this file with the current version of nanopb generator. diff --git a/src/core/tsi/alts/handshaker/transport_security_common_api.h b/src/core/tsi/alts/handshaker/transport_security_common_api.h index 68228cb3b5..ec2a0b4b5e 100644 --- a/src/core/tsi/alts/handshaker/transport_security_common_api.h +++ b/src/core/tsi/alts/handshaker/transport_security_common_api.h @@ -21,8 +21,8 @@ #include <grpc/support/port_platform.h> -#include "third_party/nanopb/pb_decode.h" -#include "third_party/nanopb/pb_encode.h" +#include "pb_decode.h" +#include "pb_encode.h" #include <grpc/slice.h> #include <grpc/slice_buffer.h> diff --git a/src/cpp/server/health/default_health_check_service.cc b/src/cpp/server/health/default_health_check_service.cc index 0b45a8b714..bfda67d086 100644 --- a/src/cpp/server/health/default_health_check_service.cc +++ b/src/cpp/server/health/default_health_check_service.cc @@ -24,10 +24,10 @@ #include <grpc/support/log.h> #include <grpcpp/impl/codegen/method_handler_impl.h> +#include "pb_decode.h" +#include "pb_encode.h" #include "src/cpp/server/health/default_health_check_service.h" #include "src/cpp/server/health/health.pb.h" -#include "third_party/nanopb/pb_decode.h" -#include "third_party/nanopb/pb_encode.h" namespace grpc { namespace { diff --git a/src/cpp/server/health/health.pb.h b/src/cpp/server/health/health.pb.h index 7051b3260a..29e1f3bacb 100644 --- a/src/cpp/server/health/health.pb.h +++ b/src/cpp/server/health/health.pb.h @@ -3,7 +3,7 @@ #ifndef PB_GRPC_HEALTH_V1_HEALTH_PB_H_INCLUDED #define PB_GRPC_HEALTH_V1_HEALTH_PB_H_INCLUDED -#include "third_party/nanopb/pb.h" +#include "pb.h" /* @@protoc_insertion_point(includes) */ #if PB_PROTO_HEADER_VERSION != 30 #error Regenerate this file with the current version of nanopb generator. diff --git a/templates/Makefile.template b/templates/Makefile.template index 43fa904768..ca3fefb363 100644 --- a/templates/Makefile.template +++ b/templates/Makefile.template @@ -221,7 +221,9 @@ % endif % endfor - DEFINES += PB_FIELD_16BIT + # nanopb tweaks + DEFINES += PB_FIELD_32BIT + CPPFLAGS += -Ithird_party/nanopb CPPFLAGS += $(CPPFLAGS_$(CONFIG)) CFLAGS += $(CFLAGS_$(CONFIG)) diff --git a/third_party/nanopb.BUILD b/third_party/nanopb.BUILD new file mode 100644 index 0000000000..46ca53a8fe --- /dev/null +++ b/third_party/nanopb.BUILD @@ -0,0 +1,19 @@ +cc_library( + name = "nanopb", + srcs = [ + "pb_common.c", + "pb_decode.c", + "pb_encode.c", + ], + hdrs = [ + "pb.h", + "pb_common.h", + "pb_decode.h", + "pb_encode.h", + ], + defines = [ + "PB_FIELD_32BIT=1", + ], + visibility = ["//visibility:public"], +) + diff --git a/third_party/nanopb/BUILD b/third_party/nanopb/BUILD index f9fc57f50a..1dc830eb01 100644 --- a/third_party/nanopb/BUILD +++ b/third_party/nanopb/BUILD @@ -5,17 +5,20 @@ exports_files(["LICENSE.txt"]) package(default_visibility = ["//visibility:public"]) cc_library( - name = "nanopb", - visibility = ["//visibility:public"], - hdrs = [ - "pb.h", - "pb_common.h", - "pb_decode.h", - "pb_encode.h", - ], - srcs = [ - "pb_common.c", - "pb_decode.c", - "pb_encode.c", - ], + name = "nanopb", + srcs = [ + "pb_common.c", + "pb_decode.c", + "pb_encode.c", + ], + hdrs = [ + "pb.h", + "pb_common.h", + "pb_decode.h", + "pb_encode.h", + ], + defines = [ + "PB_FIELD_32BIT=1", + ], + visibility = ["//visibility:public"], ) diff --git a/tools/codegen/core/gen_nano_proto.sh b/tools/codegen/core/gen_nano_proto.sh index 6ce15178bd..c56429a320 100755 --- a/tools/codegen/core/gen_nano_proto.sh +++ b/tools/codegen/core/gen_nano_proto.sh @@ -74,8 +74,7 @@ pushd "$(dirname $INPUT_PROTO)" > /dev/null protoc \ --plugin=protoc-gen-nanopb="$GRPC_ROOT/third_party/nanopb/generator/protoc-gen-nanopb" \ ---nanopb_out='-T -L#include\ \"third_party/nanopb/pb.h\"'":$OUTPUT_DIR" \ -"$(basename $INPUT_PROTO)" +--nanopb_out='-T -L#include\ \"pb.h\"'":$OUTPUT_DIR" "$(basename $INPUT_PROTO)" readonly PROTO_BASENAME=$(basename $INPUT_PROTO .proto) sed -i "s:$PROTO_BASENAME.pb.h:${GRPC_OUTPUT_DIR}/$PROTO_BASENAME.pb.h:g" \ diff --git a/tools/run_tests/sanity/check_bazel_workspace.py b/tools/run_tests/sanity/check_bazel_workspace.py index 555149c820..ea670e4235 100755 --- a/tools/run_tests/sanity/check_bazel_workspace.py +++ b/tools/run_tests/sanity/check_bazel_workspace.py @@ -21,6 +21,7 @@ import os import re import subprocess import sys +import pdb os.chdir(os.path.join(os.path.dirname(sys.argv[0]), '../../..')) @@ -47,6 +48,7 @@ _GRPC_DEP_NAMES = [ 'com_google_protobuf', 'com_github_google_googletest', 'com_github_gflags_gflags', + 'com_github_nanopb_nanopb', 'com_github_google_benchmark', 'com_github_cares_cares', 'com_google_absl', @@ -120,9 +122,12 @@ names_without_bazel_only_deps = names_and_urls.keys() for dep_name in _GRPC_BAZEL_ONLY_DEPS: names_without_bazel_only_deps.remove(dep_name) archive_urls = [names_and_urls[name] for name in names_without_bazel_only_deps] +# Exclude nanopb from the check: it's not a submodule for distribution reasons, +# but it's a workspace dependency to enable users to use their own version. workspace_git_hashes = { re.search(git_hash_pattern, url).group() for url in archive_urls + if 'nanopb' not in url } if len(workspace_git_hashes) == 0: print("(Likely) parse error, did not find any bazel git dependencies.") |