Skip to content

Commit d89601a

Browse files
committed
Incorporate the grpcio-sys crate.
Test: manually build @netsim_crates//:grpcio-sys. Bug: b/402294585
1 parent 95b6c74 commit d89601a

File tree

3 files changed

+65
-1
lines changed

3 files changed

+65
-1
lines changed

base/cvd/MODULE.bazel

Lines changed: 42 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -291,6 +291,47 @@ pica_crates.from_cargo(
291291

292292
use_repo(pica_crates, "pica_crates")
293293

294+
netsim_crates = use_extension("@rules_rust//crate_universe:extensions.bzl", "crate")
295+
netsim_crates.spec(
296+
package = "grpcio-sys",
297+
version = "0.13.0+1.56.2-patched",
298+
)
299+
netsim_crates.annotation(
300+
crate = "grpcio-sys",
301+
gen_build_script = "off",
302+
303+
# Mimic build.rs to use grpc from bazel_dep()
304+
deps = [
305+
":grpc_wrap",
306+
],
307+
rustc_env = {
308+
"BINDING_PATH": "$(execpath bindings/bindings.rs)",
309+
},
310+
additive_build_file_content = """
311+
312+
cc_library(
313+
name = "grpc_wrap",
314+
srcs = [
315+
"grpc_wrap.cc",
316+
"@@//build_external/grpcio-sys:gpr_assert",
317+
],
318+
copts = [
319+
"-include",
320+
"$(execpath @@//build_external/grpcio-sys:gpr_assert)",
321+
],
322+
deps = ["@@//build_external/grpcio-sys:grpc_wrap_deps"],
323+
)
324+
""",
325+
)
326+
netsim_crates.from_specs(
327+
name = "netsim_crates",
328+
# Needed because it shares the extension with crosvm
329+
cargo_config = "@//build_external/crosvm:crosvm.config.toml",
330+
host_tools_repo = "rust_host_tools_nightly",
331+
)
332+
333+
use_repo(netsim_crates, "netsim_crates")
334+
294335
http_archive = use_repo_rule("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
295336

296337
# Upstream mtools is in subversion, which bazel doesn't support
@@ -624,7 +665,7 @@ git_repository(
624665
git_repository(
625666
name = "ms-tpm-20-ref",
626667
build_file = "@//:BUILD.ms-tpm-20-ref.bazel",
627-
commit = "ee21db0a941decd3cac67925ea3310873af60ab3", # v1.83r1
668+
commit = "ee21db0a941decd3cac67925ea3310873af60ab3", # v1.83r1
628669
remote = "https://github.com/microsoft/ms-tpm-20-ref",
629670
patches = [
630671
"@//build_external/ms-tpm-20-ref:0001-Turn-off-ALG_CAMELLIA.patch",
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
load("@rules_cc//cc:cc_library.bzl", "cc_library")
2+
3+
cc_library(
4+
name = "grpc_wrap_deps",
5+
visibility = ["//visibility:public"],
6+
deps = [
7+
"@abseil-cpp//absl/log",
8+
"@grpc//:grpc_unsecure",
9+
],
10+
)
11+
12+
filegroup(
13+
name = "gpr_assert",
14+
srcs = ["gpr_assert.h"],
15+
visibility = ["//visibility:public"],
16+
)
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
2+
// grpcio-sys 0.13.0 uses grpc 1.56.2 which has GPR_ASSERT. According to
3+
// https://github.com/grpc/grpc/commit/a3aa81e179c49d26d2604fcc4ffb97a099b6602f
4+
// GPR_ASSERT is replaced with absl CHECK.
5+
6+
#include "absl/log/check.h"
7+
#define GPR_ASSERT(...) CHECK(__VA_ARGS__)

0 commit comments

Comments
 (0)