-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
WIP calling simple grpc client library from zig
- Loading branch information
1 parent
f592803
commit 14ead4b
Showing
12 changed files
with
255 additions
and
70 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
# todo: add this line back when Zig toolchain is working for gRPC builds | ||
#build --action_env BAZEL_DO_NOT_DETECT_CPP_TOOLCHAIN=1 | ||
|
||
build --experimental_show_artifacts | ||
build --cxxopt='-std=c++14' | ||
build --copt=-DGRPC_BAZEL_BUILD | ||
build --disk_cache=~/.cache/zig_grpc_example_bazel |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
zig-cache/ | ||
zig-out/ | ||
bazel-* | ||
.idea/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,14 @@ | ||
// globals here | ||
const std = @import("std"); | ||
const c = std.c; | ||
|
||
pub const grpc = @cImport({ | ||
@cDefine("BAZEL_BUILD", 1); | ||
@cInclude("helloworld.pb.h"); | ||
@cInclude("helloworld.grpc.pb.h"); | ||
@cInclude("keyvaluestore.pb.h"); | ||
@cInclude("keyvaluestore.grpc.pb.h"); | ||
}); | ||
|
||
pub const greeter_client = @cImport({ | ||
@cInclude("greeter_client.h"); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
const cli = @import("cli.zig"); | ||
const global = @import("global.zig"); | ||
const std = @import("std"); | ||
|
||
const debug = std.log.debug; | ||
const grpc = global.grpc; | ||
const greeter_client = global.greeter_client; | ||
|
||
pub fn main() !void { | ||
debug("Greeter Client", .{}); | ||
const args = try cli.parseArgs(); | ||
debug("port {}", .{args.port}); | ||
const target: [*c]const u8 = "localhost:3000"; | ||
const user: [*c]const u8 = "world"; | ||
debug("calling CC...", .{}); | ||
const response: [*c]const u8 = greeter_client.sayHello(target.*, user.*); | ||
debug("response: {s}", .{response}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,11 @@ | ||
const cli = @import("cli.zig"); | ||
const zig_grpc_example = @import("global.zig"); | ||
const global = @import("global.zig"); | ||
const std = @import("std"); | ||
|
||
const grpc = global.grpc; | ||
|
||
pub fn main() !void { | ||
std.log.debug("Greeter Server", .{}); | ||
const args = try cli.parseArgs(); | ||
std.log.debug("port {}", .{args.port}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.