Permalink
Browse files

Add bazel build files

  • Loading branch information...
teodor-pripoae committed Dec 28, 2016
1 parent b6992b8 commit ef6463fc47e562874a4b12ad07dce111063a7672
Showing with 410 additions and 0 deletions.
  1. +7 −0 .gitignore
  2. +77 −0 BUILD
  3. +36 −0 WORKSPACE
  4. +15 −0 bazel/gtest.BUILD
  5. +43 −0 bazel/snappy.BUILD
  6. +39 −0 bazel/zlib.BUILD
  7. +40 −0 sample/compress_sample/BUILD
  8. +50 −0 sample/echo/BUILD
  9. +26 −0 sample/mock_sample/BUILD
  10. +37 −0 sample/multi_server_sample/BUILD
  11. +40 −0 sample/timeout_sample/BUILD
View
@@ -23,3 +23,10 @@ depends.mk
src/sofa/pbrpc/*.pb.h
src/sofa/pbrpc/*.pb.cc
# bazel
bazel-app
bazel-bin
bazel-genfiles
bazel-out
bazel-sofa-pbrpc
bazel-testlogs
View
77 BUILD
@@ -0,0 +1,77 @@
load("@protobuf//:protobuf.bzl", "cc_proto_library")
RELATIVE_WELL_KNOWN_PROTOS = [
"sofa/pbrpc/builtin_service.proto",
"sofa/pbrpc/rpc_meta.proto",
"sofa/pbrpc/rpc_option.proto"
]
WELL_KNOWN_PROTOS = ["src/" + s for s in RELATIVE_WELL_KNOWN_PROTOS]
filegroup(
name = "well_known_protos",
srcs = WELL_KNOWN_PROTOS,
visibility = ["//visibility:public"],
)
cc_proto_library(
name = "cc_protos",
srcs = WELL_KNOWN_PROTOS,
include = "src/",
default_runtime = "@protobuf//:protobuf",
protoc = "@protobuf//:protoc",
deps = ["@protobuf//:cc_wkt_protos"],
visibility = ["//visibility:public"]
)
cc_library(
name = "rapidjson",
hdrs = glob(["src/rapidjson/*.h", "src/rapidjson/internal/*.h"]),
srcs = [],
visibility = ["//main:__pkg__"],
)
cc_library(
name = "sofa-pbrpc",
hdrs = glob([
"src/sofa/pbrpc/*.h",
"src/sofa/pbrpc/smart_ptr/*.hpp",
"src/sofa/pbrpc/smart_ptr/detail/*.hpp"
]),
srcs = glob(["src/sofa/pbrpc/*.cc"]),
deps = [
":cc_protos",
":rapidjson",
"@protobuf//:protobuf",
"@protobuf//:protoc_lib",
"@snappy//:snappy",
"@zlib//:zlib",
"@gtest//:gtest",
],
copts = [
"-Iexternal/googletest/include",
"-Iexternal/boost/boost"
],
visibility = ["//visibility:public"],
)
cc_library(
name = "sofa-pbrpc-client-lib",
hdrs = ["src/sofa/pbrpc/http-agent/http_agent.h"],
srcs = ["src/sofa/pbrpc/http-agent/http_agent.cc"],
deps = [
":sofa-pbrpc",
],
visibility = ["//main:__pkg__"],
)
cc_binary(
name = "sofa-pbrpc-client",
srcs = [
"src/sofa/pbrpc/http-agent/sofa_pbrpc_client.cc",
],
deps = [
":sofa-pbrpc-client-lib",
],
visibility = ["//main:__pkg__"],
)
View
@@ -0,0 +1,36 @@
git_repository(
name = "protobuf",
remote = "https://github.com/google/protobuf",
tag = "v3.1.0"
)
new_git_repository(
name = "snappy",
remote = "https://github.com/google/snappy",
commit = "32d6d7d8a2ef328a2ee1dd40f072e21f4983ebda", # latest master
build_file = "bazel/snappy.BUILD"
)
new_git_repository(
name = "gtest",
remote = "https://github.com/google/googletest.git",
tag = "release-1.8.0",
build_file = "bazel/gtest.BUILD",
)
new_http_archive(
name = "boost",
url = "https://sourceforge.net/projects/boost/files/boost/1.61.0/boost_1_61_0.tar.bz2/download",
type = "tar.bz2",
strip_prefix = "boost_1_61_0/",
sha256 = "a547bd06c2fd9a71ba1d169d9cf0339da7ebf4753849a8f7d6fdb8feee99b640",
)
new_http_archive(
name = "zlib",
url = "https://sourceforge.net/projects/libpng/files/zlib/1.2.8/zlib-1.2.8.tar.gz/download",
type = "tar.gz",
build_file = "bazel/zlib.BUILD",
strip_prefix = "zlib-1.2.8/",
sha256 = "36658cb768a54c1d4dec43c3116c27ed893e88b02ecfcb44f2166f9c0b7f2a0d",
)
View
@@ -0,0 +1,15 @@
cc_library(
name = "gtest",
hdrs = glob([
"googletest/include/**/*.h",
"googletest/src/*.h"
]),
srcs = glob(
["googletest/src/*.cc"],
exclude = ["googletest/src/gtest-all.cc"]
),
includes = ["googletest/include", "googletest"],
copts = ["-Iexternal/googletest/include"],
linkopts = ["-pthread"],
visibility = ["//visibility:public"],
)
View
@@ -0,0 +1,43 @@
genrule(
name = "snappy_stubs_public_h",
srcs = [
"snappy-stubs-public.h.in",
],
outs = [
"snappy-stubs-public.h",
],
cmd = "sed 's/@ac_cv_have_stdint_h@/1/g' $(<) | " +
"sed 's/@ac_cv_have_stddef_h@/1/g' | " +
"sed 's/@ac_cv_have_sys_uio_h@/1/g' | " +
"sed 's/@SNAPPY_MAJOR@/1/g' | " +
"sed 's/@SNAPPY_MINOR@/1/g' | " +
"sed 's/@SNAPPY_PATCHLEVEL@/3/g' >$(@)",
)
cc_library(
name = "snappy",
srcs = [
"snappy.cc",
"snappy-c.cc",
"snappy-sinksource.cc",
"snappy-stubs-internal.cc",
],
hdrs = [
":snappy_stubs_public_h",
"snappy.h",
"snappy-c.h",
"snappy-internal.h",
"snappy-sinksource.h",
"snappy-stubs-internal.h",
"snappy-stubs-public.h.in",
],
copts = [
"-Wno-non-virtual-dtor",
"-Wno-unused-variable",
"-Wno-implicit-fallthrough",
"-Wno-unused-function",
],
includes = ["."],
visibility = ["//visibility:public"],
)
View
@@ -0,0 +1,39 @@
cc_library(
name = "zlib",
srcs = [
"adler32.c",
"compress.c",
"crc32.c",
"deflate.c",
"gzclose.c",
"gzlib.c",
"gzread.c",
"gzwrite.c",
"infback.c",
"inffast.c",
"inflate.c",
"inftrees.c",
"trees.c",
"uncompr.c",
"zutil.c",
],
hdrs = [
"crc32.h",
"deflate.h",
"gzguts.h",
"inffast.h",
"inffixed.h",
"inflate.h",
"inftrees.h",
"trees.h",
"zconf.h",
"zlib.h",
"zutil.h",
],
copts = [
"-Wno-unused-variable",
"-Wno-implicit-function-declaration",
"-Wno-shift-negative-value",
],
visibility = ["//visibility:public"]
)
@@ -0,0 +1,40 @@
load("@protobuf//:protobuf.bzl", "cc_proto_library")
cc_proto_library(
name = "echo_proto",
srcs = [
"echo_service.proto",
],
include = ".",
default_runtime = "@protobuf//:protobuf",
protoc = "@protobuf//:protoc",
deps = [
"//:cc_protos",
],
)
cc_binary(
name = "server",
srcs = ["server.cc"],
deps = [
":echo_proto",
"//:sofa-pbrpc",
"@protobuf//:protobuf",
"@protobuf//:protoc_lib",
],
visibility = ["//main:__pkg__"],
)
cc_binary(
name = "client",
srcs = ["client.cc"],
deps = [
":echo_proto",
"//:sofa-pbrpc",
"@protobuf//:protobuf",
"@protobuf//:protoc_lib",
],
visibility = ["//main:__pkg__"],
)
View
@@ -0,0 +1,50 @@
load("@protobuf//:protobuf.bzl", "cc_proto_library")
cc_proto_library(
name = "echo_proto",
srcs = [
"echo_service.proto",
],
include = ".",
default_runtime = "@protobuf//:protobuf",
protoc = "@protobuf//:protoc",
)
cc_binary(
name = "server",
srcs = ["server.cc"],
deps = [
":echo_proto",
"//:sofa-pbrpc",
"@protobuf//:protobuf",
"@protobuf//:protoc_lib",
],
visibility = ["//main:__pkg__"],
)
cc_binary(
name = "client_async",
srcs = ["client_async.cc"],
deps = [
":echo_proto",
"//:sofa-pbrpc",
"@protobuf//:protobuf",
"@protobuf//:protoc_lib",
],
visibility = ["//main:__pkg__"],
)
cc_binary(
name = "client_sync",
srcs = ["client_sync.cc"],
deps = [
":echo_proto",
"//:sofa-pbrpc",
"@protobuf//:protobuf",
"@protobuf//:protoc_lib",
],
visibility = ["//main:__pkg__"],
)
View
@@ -0,0 +1,26 @@
load("@protobuf//:protobuf.bzl", "cc_proto_library")
cc_proto_library(
name = "echo_proto",
srcs = [
"echo_service.proto",
],
include = ".",
default_runtime = "@protobuf//:protobuf",
protoc = "@protobuf//:protoc",
deps = [
"//:cc_protos",
],
)
cc_binary(
name = "test",
srcs = ["mock_test_sample.cc"],
deps = [
":echo_proto",
"//:sofa-pbrpc",
"@gtest//:gtest",
],
visibility = ["//main:__pkg__"],
)
@@ -0,0 +1,37 @@
load("@protobuf//:protobuf.bzl", "cc_proto_library")
cc_proto_library(
name = "echo_proto",
srcs = [
"echo_service.proto",
],
include = ".",
default_runtime = "@protobuf//:protobuf",
protoc = "@protobuf//:protoc",
)
cc_binary(
name = "server",
srcs = ["server.cc"],
deps = [
":echo_proto",
"//:sofa-pbrpc",
"@protobuf//:protobuf",
"@protobuf//:protoc_lib",
],
visibility = ["//main:__pkg__"],
)
cc_binary(
name = "client",
srcs = ["client.cc"],
deps = [
":echo_proto",
"//:sofa-pbrpc",
"@protobuf//:protobuf",
"@protobuf//:protoc_lib",
],
visibility = ["//main:__pkg__"],
)
Oops, something went wrong.

0 comments on commit ef6463f

Please sign in to comment.