Skip to content

Commit 6798bfc

Browse files
authored
Add grpc package (v1.83.0) (#555)
* Add grpc package (v1.83.0) * apply fixes for coderabbit comments * Remove Test * Add proto grpc compilation tests * Fix lint errors
1 parent 527251f commit 6798bfc

2 files changed

Lines changed: 136 additions & 0 deletions

File tree

packages/grpc/build.ncl

Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
let { subsetOf, BuildSpec, Local, OutputBin, OutputData, OutputLib, Source, Test, .. } = import "minimal.ncl" in
2+
3+
let version = "1.83.0" in
4+
5+
let base = import "../base/build.ncl" in
6+
let binutils = import "../binutils/build.ncl" in
7+
let cmake = import "../cmake/build.ncl" in
8+
let gcc = import "../gcc/build.ncl" in
9+
let glibc = import "../glibc/build.ncl" in
10+
let linux_headers = import "../linux_headers/build.ncl" in
11+
let make = import "../make/build.ncl" in
12+
let toolchain = import "../toolchain/build.ncl" in
13+
14+
let abseil-cpp = import "../abseil-cpp/build.ncl" in
15+
let c-ares = import "../c-ares/build.ncl" in
16+
let openssl = import "../openssl/build.ncl" in
17+
let protobuf = import "../protobuf/build.ncl" in
18+
let re2 = import "../re2/build.ncl" in
19+
let zlib = import "../zlib/build.ncl" in
20+
let python = import "../python/build.ncl" in
21+
22+
{
23+
name = "grpc",
24+
25+
build_deps = [
26+
{ file = "build.sh" } | Local,
27+
{
28+
url = "https://github.com/grpc/grpc/archive/refs/tags/v%{version}.tar.gz",
29+
sha256 = "90d453393a9d41215df546103b10b33b9566df79cdf6f49dc67f6c4d044d090d",
30+
extract = true,
31+
strip_prefix = "grpc-%{version}",
32+
} | Source,
33+
base,
34+
toolchain,
35+
make,
36+
cmake,
37+
abseil-cpp,
38+
c-ares,
39+
openssl,
40+
protobuf,
41+
re2,
42+
zlib,
43+
],
44+
45+
runtime_deps = [
46+
glibc,
47+
subsetOf gcc ["libgcc", "libstdcpp"],
48+
abseil-cpp,
49+
c-ares,
50+
openssl,
51+
protobuf,
52+
re2,
53+
zlib,
54+
],
55+
56+
cmd = "./build.sh",
57+
build_args = {
58+
include version,
59+
},
60+
61+
outputs = {
62+
bins = { glob = "usr/bin/*" } | OutputBin,
63+
libs = { glob = "usr/lib/*.so*" } | OutputLib,
64+
headers = { glob = "usr/include/**" } | OutputData,
65+
cmake = { glob = "usr/lib/cmake/**" } | OutputData,
66+
pkgconfig = { glob = "usr/lib/pkgconfig/**" } | OutputData,
67+
roots = { glob = "usr/share/grpc/roots.pem" } | OutputData,
68+
},
69+
70+
attrs = {
71+
upstream_version = version,
72+
source_provenance = {
73+
category = 'GithubRepo,
74+
owner = "grpc",
75+
repo = "grpc",
76+
},
77+
},
78+
79+
tests = {
80+
link_and_run =
81+
{
82+
class = 'Standalone,
83+
test_deps = [base, toolchain, binutils, linux_headers],
84+
cmds = [
85+
["/bin/bash", "-c", "echo '#include <grpc/grpc.h>\nint main() { grpc_init(); grpc_shutdown(); return 0; }' > test.c"],
86+
["/bin/gcc", "test.c", "-lgrpc", "-o", "test"],
87+
["./test"],
88+
],
89+
} | Test,
90+
plugin_check =
91+
{
92+
class = 'Standalone,
93+
test_deps = [base],
94+
cmds = [
95+
["/bin/bash", "-c", "for p in cpp csharp node objective_c php python ruby; do command -v grpc_${p}_plugin > /dev/null || exit 1; done"],
96+
],
97+
} | Test,
98+
proto_compile =
99+
{
100+
class = 'Standalone,
101+
test_deps = [base, toolchain, binutils, protobuf, python, linux_headers],
102+
cmds = [
103+
["/bin/bash", "-c", "echo 'syntax = \"proto3\"; package test; service Echo { rpc Ping (Message) returns (Message) {} } message Message { string body = 1; }' > test.proto"],
104+
["/bin/bash", "-c", "protoc --cpp_out=. test.proto"],
105+
["/bin/bash", "-c", "for p in cpp csharp node objective_c php python ruby; do protoc --plugin=protoc-gen-grpc_${p}=$(command -v grpc_${p}_plugin) --grpc_${p}_out=. test.proto; done"],
106+
["/bin/bash", "-c", "g++ -c test.pb.cc test.grpc.pb.cc -std=c++17"],
107+
],
108+
} | Test,
109+
},
110+
} | BuildSpec

packages/grpc/build.sh

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
#!/bin/bash
2+
set -euo pipefail
3+
4+
5+
export CFLAGS="-O3 -pipe -ffile-prefix-map=$(pwd)=/builddir -gno-record-gcc-switches"
6+
export CXXFLAGS="$CFLAGS"
7+
export LDFLAGS="-Wl,--build-id=none"
8+
export ARFLAGS=Drc
9+
10+
cmake -B build \
11+
-DCMAKE_INSTALL_PREFIX=/usr \
12+
-DCMAKE_INSTALL_LIBDIR=/usr/lib \
13+
-DCMAKE_BUILD_TYPE=Release \
14+
-DBUILD_SHARED_LIBS=ON \
15+
-DgRPC_INSTALL=ON \
16+
-DgRPC_BUILD_TESTS=OFF \
17+
-DgRPC_ABSL_PROVIDER=package \
18+
-DgRPC_CARES_PROVIDER=package \
19+
-DgRPC_PROTOBUF_PROVIDER=package \
20+
-DgRPC_RE2_PROVIDER=package \
21+
-DgRPC_SSL_PROVIDER=package \
22+
-DgRPC_ZLIB_PROVIDER=package \
23+
-DgRPC_DOWNLOAD_ARCHIVES=OFF \
24+
-DCMAKE_CXX_STANDARD=14
25+
make -C build -j$(nproc)
26+
make DESTDIR=$OUTPUT_DIR -C build install

0 commit comments

Comments
 (0)