Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 7 additions & 20 deletions cinterop-c/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,34 +1,21 @@
load("@rules_cc//cc:defs.bzl", "cc_library")

cc_binary(
name = "testdemo",
srcs = ["src/main.cpp"],
deps = [
":protowire",
],
)

cc_static_library(
name = "grpcpp_c_static",
name = "kgrpc_static",
deps = [
":grpcpp_c",
":kgrpc",
],
)

cc_library(
name = "grpcpp_c",
srcs = ["src/grpcpp_c.cpp"],
hdrs = glob(["include/**/*.h"]),
name = "kgrpc",
srcs = ["src/kgrpc.cpp"],
hdrs = glob(["include/kgrpc.h"]),
copts = ["-std=c++20"],
includes = ["include"],
visibility = ["//visibility:public"],
deps = [
# TODO: Reduce the dependencies and only use required once. KRPC-185
"@com_github_grpc_grpc//:channelz",
"@com_github_grpc_grpc//:generic_stub",
"@com_github_grpc_grpc//:grpc++",
"@com_github_grpc_grpc//:grpc_credentials_util",
"@com_google_protobuf//:protobuf",
"@com_github_grpc_grpc//:grpc"
],
)

Expand All @@ -42,7 +29,7 @@ cc_static_library(
cc_library(
name = "protowire",
srcs = ["src/protowire.cpp"],
hdrs = glob(["include/*.h"]),
hdrs = glob(["include/protowire.h"]),
copts = ["-std=c++20"],
includes = ["include"],
visibility = ["//visibility:public"],
Expand Down
4 changes: 2 additions & 2 deletions cinterop-c/MODULE.bazel
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module(
name = "grpcpp_c",
name = "kgrpc",
version = "0.1",
)

Expand All @@ -16,7 +16,7 @@ bazel_dep(
repo_name = "com_google_protobuf",
)

# gRPC C++ library
# gRPC library
bazel_dep(
name = "grpc",
version = "1.73.1",
Expand Down
66 changes: 0 additions & 66 deletions cinterop-c/include/grpcpp_c.h

This file was deleted.

37 changes: 37 additions & 0 deletions cinterop-c/include/kgrpc.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/*
* Copyright 2023-2025 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
*/

/*
* Helper functions required for gRPC Core cinterop.
*/

#ifndef GRPCPP_C_H
#define GRPCPP_C_H

#include <stdbool.h>
#include <grpc/grpc.h>

#ifdef __cplusplus
extern "C" {
#endif

/*
* Struct that layouts a grpc_completion_queue_functor and user opaque data pointer,
* to implement the callback mechanism in the K/N CompletionQueue.
*/
typedef struct {
grpc_completion_queue_functor functor;
void *user_data;
} kgrpc_cb_tag;

/*
* Call to grpc_iomgr_run_in_background(), which is not exposed as extern "C" and therefore must be wrapped.
*/
bool kgrpc_iomgr_run_in_background();

#ifdef __cplusplus
}
#endif

#endif //GRPCPP_C_H
4 changes: 4 additions & 0 deletions cinterop-c/include/protowire.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
/*
* Copyright 2023-2025 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
*/

#ifndef PROTOWIRE_H
#define PROTOWIRE_H

Expand Down
201 changes: 0 additions & 201 deletions cinterop-c/src/grpcpp_c.cpp

This file was deleted.

17 changes: 17 additions & 0 deletions cinterop-c/src/kgrpc.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/*
* Copyright 2023-2025 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
*/

#include <kgrpc.h>

#include "src/core/lib/iomgr/iomgr.h"

extern "C" {

bool kgrpc_iomgr_run_in_background() {
return grpc_iomgr_run_in_background();
}

}


Loading
Loading