Skip to content

Commit

Permalink
add bazel support
Browse files Browse the repository at this point in the history
  • Loading branch information
wzl12356 committed Aug 15, 2021
1 parent 53377f8 commit 7771384
Show file tree
Hide file tree
Showing 40 changed files with 500 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,4 @@ SRCVERSION
CMakeCache.txt
Makefile

bazel-*
295 changes: 295 additions & 0 deletions BUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,295 @@
load("@rules_cc//cc:defs.bzl", "cc_proto_library")
load("@rules_proto//proto:defs.bzl", "proto_library")
load(":srpc.bzl", "gen_srpc_pb_cc")
load(":srpc.bzl", "gen_srpc_thrift_cc")

proto_library(
name = "message_proto",
srcs = [
'src/message/rpc_meta.proto',
'src/message/rpc_meta_brpc.proto',
'src/message/rpc_meta_trpc.proto',
'src/message/rpc_span.proto',
],
strip_import_prefix = "src/message",
)

cc_proto_library(
name = "MessageProto",
deps = [":message_proto"],
)

cc_library(
name = 'srpc_hdrs',
hdrs = glob(['src/include/srpc/*']),
includes = ['src/include'],
deps = [
'@workflow//:workflow_hdrs',
],
visibility = ["//visibility:public"],
)

cc_library(
name = 'libsrpc',
srcs = glob(['src/**/*.cc']),
hdrs = glob([
'src/**/*.h',
'src/**/*.inl',
]),
includes = ['src', 'src/thrift', 'src/compress', 'src/message', 'src/module'],
deps = [
'@workflow//:http',
'@workflow//:upstream',
'@lz4//:lz4',
'@snappy//:snappy',
':MessageProto',
],
visibility = ["//visibility:public"],
)

cc_binary(
name ='srpc_generator',
srcs = glob(['src/generator/*.cc']),
deps = [':libsrpc'],
)

proto_library(
name = "echo_pb_proto",
srcs = [
'tutorial/echo_pb.proto',
],
strip_import_prefix = "tutorial",
)

cc_proto_library(
name = "EchoProto",
deps = [":echo_pb_proto"],
)

gen_srpc_pb_cc(
name = "echo_pb",
files = ["tutorial/echo_pb.proto",],
deps_lib = [':EchoProto'],
)

cc_binary(
name = 'srpc_pb_server',
srcs = ['tutorial/tutorial-01-srpc_pb_server.cc'],
deps = [
':libsrpc',
':echo_pb_server_cc',
],
linkopts = [
'-lpthread',
'-lssl',
'-lcrypto',
],
)

cc_binary(
name = 'srpc_pb_client',
srcs = ['tutorial/tutorial-02-srpc_pb_client.cc'],
deps = [
':libsrpc',
':echo_pb_client_cc',
],
linkopts = [
'-lpthread',
'-lssl',
'-lcrypto',
],
)

gen_srpc_thrift_cc(
name = "echo_thrift",
files = ["tutorial/echo_thrift.thrift",],
deps_lib = [],
)

cc_binary(
name = 'srpc_thrift_server',
srcs = ['tutorial/tutorial-03-srpc_thrift_server.cc'],
deps = [
':libsrpc',
':echo_thrift_server_cc',
],
linkopts = [
'-lpthread',
'-lssl',
'-lcrypto',
],
)

cc_binary(
name = 'srpc_thrift_client',
srcs = ['tutorial/tutorial-04-srpc_thrift_client.cc'],
deps = [
':libsrpc',
':echo_thrift_client_cc',
],
linkopts = [
'-lpthread',
'-lssl',
'-lcrypto',
],
)

cc_binary(
name = 'brpc_pb_server',
srcs = ['tutorial/tutorial-05-brpc_pb_server.cc'],
deps = [
':libsrpc',
':echo_pb_server_cc',
],
linkopts = [
'-lpthread',
'-lssl',
'-lcrypto',
],
)

cc_binary(
name = 'brpc_pb_client',
srcs = ['tutorial/tutorial-06-brpc_pb_client.cc'],
deps = [
':libsrpc',
':echo_pb_client_cc',
],
linkopts = [
'-lpthread',
'-lssl',
'-lcrypto',
],
)

cc_binary(
name = 'thrift_thrift_server',
srcs = ['tutorial/tutorial-07-thrift_thrift_server.cc'],
deps = [
':libsrpc',
':echo_thrift_server_cc',
],
linkopts = [
'-lpthread',
'-lssl',
'-lcrypto',
],
)

cc_binary(
name = 'thrift_thrift_client',
srcs = ['tutorial/tutorial-08-thrift_thrift_client.cc'],
deps = [
':libsrpc',
':echo_thrift_client_cc',
],
linkopts = [
'-lpthread',
'-lssl',
'-lcrypto',
],
)

cc_binary(
name = 'client_task',
srcs = ['tutorial/tutorial-09-client_task.cc'],
deps = [
':libsrpc',
':echo_pb_client_cc',
],
linkopts = [
'-lpthread',
'-lssl',
'-lcrypto',
],
)

cc_binary(
name = 'server_async',
srcs = ['tutorial/tutorial-10-server_async.cc'],
deps = [
':libsrpc',
':echo_pb_server_cc',
],
linkopts = [
'-lpthread',
'-lssl',
'-lcrypto',
],
)

proto_library(
name = "helloworld_proto",
srcs = [
'tutorial/helloworld.proto',
],
strip_import_prefix = "tutorial",
)

cc_proto_library(
name = "HelloworldProto",
deps = [":helloworld_proto"],
)

gen_srpc_pb_cc(
name = "helloworld",
files = ["tutorial/helloworld.proto",],
deps_lib = [':HelloworldProto'],
)

cc_binary(
name = 'trpc_pb_server',
srcs = ['tutorial/tutorial-11-trpc_pb_server.cc'],
deps = [
':libsrpc',
':helloworld_server_cc',
],
linkopts = [
'-lpthread',
'-lssl',
'-lcrypto',
],
)

cc_binary(
name = 'trpc_pb_client',
srcs = ['tutorial/tutorial-12-trpc_pb_client.cc'],
deps = [
':libsrpc',
':helloworld_client_cc',
],
linkopts = [
'-lpthread',
'-lssl',
'-lcrypto',
],
)

cc_binary(
name = 'trpc_http_server',
srcs = ['tutorial/tutorial-13-trpc_http_server.cc'],
deps = [
':libsrpc',
':helloworld_server_cc',
],
linkopts = [
'-lpthread',
'-lssl',
'-lcrypto',
],
)

cc_binary(
name = 'trpc_http_client',
srcs = ['tutorial/tutorial-14-trpc_http_client.cc'],
deps = [
':libsrpc',
':helloworld_client_cc',
],
linkopts = [
'-lpthread',
'-lssl',
'-lcrypto',
],
)

32 changes: 32 additions & 0 deletions WORKSPACE
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
load("@bazel_tools//tools/build_defs/repo:git.bzl", "git_repository")
load("@bazel_tools//tools/build_defs/repo:git.bzl", "new_git_repository")
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")

http_archive(
name = "rules_proto",
sha256 = "d8992e6eeec276d49f1d4e63cfa05bbed6d4a26cfe6ca63c972827a0d141ea3b",
strip_prefix = "rules_proto-cfdc2fa31879c0aebe31ce7702b1a9c8a4be02d2",
urls = [
"https://github.com/bazelbuild/rules_proto/archive/cfdc2fa31879c0aebe31ce7702b1a9c8a4be02d2.tar.gz",
],
)
load("@rules_proto//proto:repositories.bzl", "rules_proto_dependencies", "rules_proto_toolchains")
rules_proto_dependencies()
rules_proto_toolchains()

git_repository(
name = "workflow",
commit = "bbcf8173be22f26e7b8f4da95d80011f748f5e8b",
remote = "https://github.com/sogou/workflow.git")

new_git_repository(
name = "lz4",
build_file = "@//third_party:lz4.BUILD",
commit = "bdc9d3b0c10cbf7e1ff40fc6e27dad5f693a00e7",
remote = "https://github.com/lz4/lz4.git")

new_git_repository(
name = "snappy",
build_file = "@//third_party:snappy.BUILD",
commit = "78650d126afc55f834d15d018b430985f0c8c87c",
remote = "https://github.com/google/snappy.git")
1 change: 1 addition & 0 deletions src/include/srpc/descriptor.h
1 change: 1 addition & 0 deletions src/include/srpc/generator.h
1 change: 1 addition & 0 deletions src/include/srpc/parser.h
1 change: 1 addition & 0 deletions src/include/srpc/printer.h
1 change: 1 addition & 0 deletions src/include/srpc/rpc_basic.h
1 change: 1 addition & 0 deletions src/include/srpc/rpc_buffer.h
1 change: 1 addition & 0 deletions src/include/srpc/rpc_client.h
1 change: 1 addition & 0 deletions src/include/srpc/rpc_compress.h
1 change: 1 addition & 0 deletions src/include/srpc/rpc_compress_gzip.h
1 change: 1 addition & 0 deletions src/include/srpc/rpc_compress_lz4.h
1 change: 1 addition & 0 deletions src/include/srpc/rpc_compress_snappy.h
1 change: 1 addition & 0 deletions src/include/srpc/rpc_context.h
1 change: 1 addition & 0 deletions src/include/srpc/rpc_context.inl
1 change: 1 addition & 0 deletions src/include/srpc/rpc_define.h
1 change: 1 addition & 0 deletions src/include/srpc/rpc_global.h
1 change: 1 addition & 0 deletions src/include/srpc/rpc_message.h
1 change: 1 addition & 0 deletions src/include/srpc/rpc_message_brpc.h
1 change: 1 addition & 0 deletions src/include/srpc/rpc_message_srpc.h
1 change: 1 addition & 0 deletions src/include/srpc/rpc_message_thrift.h
1 change: 1 addition & 0 deletions src/include/srpc/rpc_message_trpc.h
1 change: 1 addition & 0 deletions src/include/srpc/rpc_module.h
1 change: 1 addition & 0 deletions src/include/srpc/rpc_module_span.h
Loading

0 comments on commit 7771384

Please sign in to comment.