-
Notifications
You must be signed in to change notification settings - Fork 656
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #174 from teodor-pripoae/bazel-build
Bazel build
- Loading branch information
Showing
24 changed files
with
642 additions
and
3 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
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,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__"]) |
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,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", | ||
) |
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,12 @@ | ||
cc_library( | ||
name = "boost", | ||
srcs = [], | ||
hdrs = glob([ | ||
"boost/**/*.h", | ||
"boost/**/*.hpp", | ||
"boost/**/*.ipp", | ||
"boost/**/*.cc", | ||
]), | ||
includes = ["."], | ||
visibility = ["//visibility:public"] | ||
) |
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,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"], | ||
) |
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,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"], | ||
) |
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,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"] | ||
) |
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,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__"], | ||
) |
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,5 @@ | ||
syntax = "proto2"; | ||
|
||
import "sofa/pbrpc/rpc_option.proto"; | ||
|
||
package sofa.pbrpc.test; | ||
|
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,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__"], | ||
) |
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,5 @@ | ||
syntax = "proto2"; | ||
|
||
package sofa.pbrpc.test; | ||
|
||
option cc_generic_services = true; | ||
|
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,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__"], | ||
) |
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,5 @@ | ||
syntax = "proto2"; | ||
|
||
package sofa.pbrpc.test; | ||
|
||
option cc_generic_services = true; | ||
|
Oops, something went wrong.