Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master' into opensource
Browse files Browse the repository at this point in the history
  • Loading branch information
zd-double committed Jan 18, 2017
2 parents 42c7182 + 636920b commit b390dad
Show file tree
Hide file tree
Showing 24 changed files with 642 additions and 3 deletions.
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -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
79 changes: 79 additions & 0 deletions BUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
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",
"@boost//:boost"
],
copts = [
"-Iexternal/googletest/include",
],
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__"],
)

exports_files(["src/sofa/pbrpc/buffer.cc"], ["//unit-test:__pkg__"])
37 changes: 37 additions & 0 deletions WORKSPACE
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
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/",
build_file = "bazel/boost.BUILD",
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",
)
12 changes: 12 additions & 0 deletions bazel/boost.BUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
cc_library(
name = "boost",
srcs = [],
hdrs = glob([
"boost/**/*.h",
"boost/**/*.hpp",
"boost/**/*.ipp",
"boost/**/*.cc",
]),
includes = ["."],
visibility = ["//visibility:public"]
)
15 changes: 15 additions & 0 deletions bazel/gtest.BUILD
Original file line number Diff line number Diff line change
@@ -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"],
)
43 changes: 43 additions & 0 deletions bazel/snappy.BUILD
Original file line number Diff line number Diff line change
@@ -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"],
)
39 changes: 39 additions & 0 deletions bazel/zlib.BUILD
Original file line number Diff line number Diff line change
@@ -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"]
)
56 changes: 56 additions & 0 deletions sample/compress_sample/BUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
load("@protobuf//:protobuf.bzl", "cc_proto_library")

config_setting(
name = "darwin",
values = {
"cpu": "darwin",
},
visibility = ["//visibility:public"],
)

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",
],
linkopts = select({
":darwin": [],
"//conditions:default": ["-static"]
}),
visibility = ["//main:__pkg__"],
)

cc_binary(
name = "client",
srcs = ["client.cc"],

deps = [
":echo_proto",
"//:sofa-pbrpc",
"@protobuf//:protobuf",
"@protobuf//:protoc_lib",
],
linkopts = select({
":darwin": [],
"//conditions:default": ["-static"]
}),
visibility = ["//main:__pkg__"],
)
2 changes: 2 additions & 0 deletions sample/compress_sample/echo_service.proto
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
syntax = "proto2";

import "sofa/pbrpc/rpc_option.proto";

package sofa.pbrpc.test;
Expand Down
50 changes: 50 additions & 0 deletions sample/echo/BUILD
Original file line number Diff line number Diff line change
@@ -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__"],
)
2 changes: 2 additions & 0 deletions sample/echo/echo_service.proto
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
syntax = "proto2";

package sofa.pbrpc.test;

option cc_generic_services = true;
Expand Down
26 changes: 26 additions & 0 deletions sample/mock_sample/BUILD
Original file line number Diff line number Diff line change
@@ -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__"],
)
2 changes: 2 additions & 0 deletions sample/mock_sample/echo_service.proto
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
syntax = "proto2";

package sofa.pbrpc.test;

option cc_generic_services = true;
Expand Down
Loading

0 comments on commit b390dad

Please sign in to comment.