mcpplibs.grpcgen
importprotoc + grpc_cpp_plugin codegen as an importable mcpp build rule (host-module)
import grpcgen;
模块名读自上游 src/grpcgen.cppm 里的 `export module` 声明。
mcpp add mcpplibs.grpcgen@1.83.0
用法
来自本仓库自己的测试项目 —— CI 真的编译并运行过,不是为了网站写的。
// Asserts the generated stubs exist, compile and carry the SERVICE — a
// protobuf-only run would produce echo.pb.* and no Echo::Service, so a
// half-configured codegen cannot pass this.
//
// HAVE_GRPC comes from this project's own cfg-gated cxxflags: the package is
// linux/macOS-only, so elsewhere this file is an empty main().
#ifdef HAVE_GRPC
#include <cstdio>
#include <string>
#include "echo.pb.h"
#include "echo.grpc.pb.h"
int main() {
// The message half: a real generated type, round-tripped.
echotest::EchoRequest req;
req.set_text("mcpp");
std::string wire;
if (!req.SerializeToString(&wire)) return 1;
echotest::EchoRequest back;
if (!back.ParseFromString(wire)) return 1;
// …
tests/examples/grpc-codegen/tests/codegen.cpp · 项目 tests/examples/grpc-codegen
构建 · 上游清单
- modules
grpcgen- targets
grpcgen (lib)- language
c++23- manifest version
1.83.0- 来源
https://raw.githubusercontent.com/mcpplibs/grpc-m/v1.83.0-4/rules/mcpp.toml