Add C++ protobuf runtime to Rust proto deps and add specific #includes in the Rust .cc codegen.

PiperOrigin-RevId: 648729688
pull/17279/head
Protobuf Team Bot 8 months ago committed by Copybara-Service
parent a9bc366522
commit 5bb8c51f3f
  1. 9
      rust/aspects.bzl
  2. 2
      src/google/protobuf/compiler/rust/generator.cc

@ -334,7 +334,7 @@ def _rust_proto_aspect_common(target, ctx, is_upb):
ctx = ctx,
attr = attr,
cc_toolchain = cc_toolchain,
cc_infos = [target[CcInfo], ctx.attr._cpp_thunks_deps[CcInfo]] + dep_cc_infos,
cc_infos = [target[CcInfo]] + [dep[CcInfo] for dep in ctx.attr._cpp_thunks_deps] + dep_cc_infos,
) for thunk in thunks])
runtime = proto_lang_toolchain.runtime
@ -385,8 +385,11 @@ def _make_proto_library_aspect(is_upb):
executable = True,
cfg = "exec",
),
"_cpp_thunks_deps": attr.label(
default = Label("//rust/cpp_kernel:cpp_api"),
"_cpp_thunks_deps": attr.label_list(
default = [
Label("//rust/cpp_kernel:cpp_api"),
Label("//src/google/protobuf"),
],
),
"_error_format": attr.label(
default = Label("@rules_rust//:error_format"),

@ -217,6 +217,8 @@ bool RustGenerator::Generate(const FileDescriptor* file,
R"cc(
#include "$proto_h$"
$proto_deps_h$
#include "google/protobuf/map.h"
#include "google/protobuf/repeated_ptr_field.h"
#include "google/protobuf/rust/cpp_kernel/map.h"
#include "google/protobuf/rust/cpp_kernel/serialized_data.h"
#include "google/protobuf/rust/cpp_kernel/strings.h"

Loading…
Cancel
Save