mirror of https://github.com/grpc/grpc-web.git
Upgrade protobuf to 27.1 and modernize codegen using new APIs (e.g. has_presence()) (#1445)
Fixes https://github.com/grpc/grpc-web/issues/1437.
This commit is contained in:
parent
8ab32b945c
commit
2c39859be8
|
@ -0,0 +1 @@
|
|||
build --copt=-Wno-error=deprecated-declarations --host_copt=-Wno-error=deprecated-declarations
|
|
@ -13,10 +13,10 @@ http_archive(
|
|||
|
||||
http_archive(
|
||||
name = "com_google_protobuf",
|
||||
sha256 = "7beed9c511d632cff7c22ac0094dd7720e550153039d5da7e059bcceb488474a",
|
||||
strip_prefix = "protobuf-25.0",
|
||||
sha256 = "6fbe2e6f703bcd3a246529c2cab586ca12a98c4e641f5f71d51fde09eb48e9e7",
|
||||
strip_prefix = "protobuf-27.1",
|
||||
urls = [
|
||||
"https://github.com/protocolbuffers/protobuf/releases/download/v25.0/protobuf-25.0.tar.gz",
|
||||
"https://github.com/protocolbuffers/protobuf/releases/download/v27.1/protobuf-27.1.tar.gz",
|
||||
],
|
||||
)
|
||||
|
||||
|
|
|
@ -841,13 +841,11 @@ void PrintProtoDtsMessage(Printer* printer, const Descriptor* desc,
|
|||
"set$js_field_name$(value?: $js_field_type$): "
|
||||
"$class_name$;\n");
|
||||
}
|
||||
if (field->has_optional_keyword() ||
|
||||
(field->type() == FieldDescriptor::TYPE_MESSAGE &&
|
||||
!field->is_repeated() && !field->is_map())) {
|
||||
if (field->has_presence()) {
|
||||
printer->Print(vars, "has$js_field_name$(): boolean;\n");
|
||||
}
|
||||
if (field->type() == FieldDescriptor::TYPE_MESSAGE || field->has_optional_keyword() ||
|
||||
field->is_repeated() || field->is_map()) {
|
||||
if (field->type() == FieldDescriptor::TYPE_MESSAGE ||
|
||||
field->has_presence() || field->is_repeated() || field->is_map()) {
|
||||
printer->Print(vars, "clear$js_field_name$(): $class_name$;\n");
|
||||
}
|
||||
if (field->is_repeated() && !field->is_map()) {
|
||||
|
@ -867,14 +865,12 @@ void PrintProtoDtsMessage(Printer* printer, const Descriptor* desc,
|
|||
printer->Print("\n");
|
||||
}
|
||||
|
||||
for (int i = 0; i < desc->oneof_decl_count(); i++) {
|
||||
const OneofDescriptor* oneof = desc->oneof_decl(i);
|
||||
if (!oneof->is_synthetic()) {
|
||||
vars["js_oneof_name"] = ToUpperCamel(ParseLowerUnderscore(oneof->name()));
|
||||
printer->Print(
|
||||
vars, "get$js_oneof_name$Case(): $class_name$.$js_oneof_name$Case;\n");
|
||||
printer->Print("\n");
|
||||
}
|
||||
for (int i = 0; i < desc->real_oneof_decl_count(); i++) {
|
||||
const OneofDescriptor *oneof = desc->real_oneof_decl(i);
|
||||
vars["js_oneof_name"] = ToUpperCamel(ParseLowerUnderscore(oneof->name()));
|
||||
printer->Print(
|
||||
vars, "get$js_oneof_name$Case(): $class_name$.$js_oneof_name$Case;\n");
|
||||
printer->Print("\n");
|
||||
}
|
||||
|
||||
printer->Print(
|
||||
|
@ -904,8 +900,7 @@ void PrintProtoDtsMessage(Printer* printer, const Descriptor* desc,
|
|||
}
|
||||
vars["js_field_name"] = js_field_name;
|
||||
vars["js_field_type"] = AsObjectFieldType(field, file);
|
||||
if ((field->type() != FieldDescriptor::TYPE_MESSAGE && !field->has_optional_keyword()) ||
|
||||
field->is_repeated()) {
|
||||
if (!field->has_presence()) {
|
||||
printer->Print(vars, "$js_field_name$: $js_field_type$,\n");
|
||||
} else {
|
||||
printer->Print(vars, "$js_field_name$?: $js_field_type$,\n");
|
||||
|
|
|
@ -75,6 +75,7 @@ WORKDIR /github/grpc-web
|
|||
# Copy only files necessary to build the protoc-gen-grpc-web first as an optimization because they
|
||||
# are rarely updated compared with the javascript files.
|
||||
COPY ./WORKSPACE ./WORKSPACE
|
||||
COPY ./.bazelrc ./.bazelrc
|
||||
COPY ./javascript/net/grpc/web/generator javascript/net/grpc/web/generator
|
||||
|
||||
RUN bazel build javascript/net/grpc/web/generator:protoc-gen-grpc-web && \
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit 6aa539bf0195f188ff86efe6fb8bfa2b676cdd46
|
||||
Subproject commit 3d9f7c430a5ae1385512908801492d4421c3cdb7
|
Loading…
Reference in New Issue