Skip to content

Commit

Permalink
Add C++ protobuf runtime to Rust proto deps and add specific #include…
Browse files Browse the repository at this point in the history
…s in the Rust .cc codegen.

PiperOrigin-RevId: 648729688
  • Loading branch information
protobuf-github-bot authored and copybara-github committed Jul 2, 2024
1 parent a9bc366 commit 5bb8c51
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
9 changes: 6 additions & 3 deletions rust/aspects.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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"),
Expand Down
2 changes: 2 additions & 0 deletions src/google/protobuf/compiler/rust/generator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit 5bb8c51

Please sign in to comment.