File tree Expand file tree Collapse file tree 8 files changed +72
-6
lines changed
doc/getstarted/build_and_install Expand file tree Collapse file tree 8 files changed +72
-6
lines changed Original file line number Diff line number Diff line change 1+ # External dependency to grpc-enabled Google-styleprotobuf bulding
2+ # rules. This method comes from
3+ # https://github.com/pubref/rules_protobuf#usage.
14git_repository (
25 name = "org_pubref_rules_protobuf" ,
36 remote = "https://github.com/pubref/rules_protobuf" ,
47 tag = "v0.7.1" ,
58)
69
10+ # External dependency to gtest 1.7.0. This method comes from
11+ # https://www.bazel.io/versions/master/docs/tutorial/cpp.html.
12+ new_http_archive (
13+ name = "gtest" ,
14+ url = "https://github.com/google/googletest/archive/release-1.7.0.zip" ,
15+ sha256 = "b58cb7547a28b2c718d1e38aee18a3659c9e3ff52440297e965f5edffe34b6d0" ,
16+ build_file = "third_party/gtest.BUILD" ,
17+ strip_prefix = "googletest-release-1.7.0" ,
18+ )
19+
20+
721load ("@org_pubref_rules_protobuf//cpp:rules.bzl" , "cpp_proto_repositories" )
822cpp_proto_repositories ()
Original file line number Diff line number Diff line change @@ -161,12 +161,13 @@ The general development workflow with Docker and Bazel is as follows:
161161 cd /paddle # where paddle source code has been mounted into the container
162162 mkdir -p build
163163 cd build
164- cmake ..
164+ cmake -DWITH_TESTING=ON ..
165165 make -j ` nproc`
166+ CTEST_OUTPUT_ON_FAILURE=1 ctest
166167
167168 or Bazel in the container:
168169
169170 .. code-block :: bash
170171
171172 cd /paddle
172- bazel build ...
173+ bazel test ...
Original file line number Diff line number Diff line change 1+ cc_library(
2+ name = "main",
3+ srcs = glob(
4+ ["src/*.cc"],
5+ exclude = ["src/gtest-all.cc"]
6+ ),
7+ hdrs = glob([
8+ "include/**/*.h",
9+ "src/*.h"
10+ ]),
11+ copts = ["-Iexternal/gtest/include"],
12+ linkopts = ["-pthread"],
13+ visibility = ["//visibility:public"],
14+ )
Original file line number Diff line number Diff line change @@ -7,6 +7,7 @@ cpp_proto_library(
77 protos = [
88 "example.proto"
99 ],
10+ with_grpc = True ,
1011)
1112
1213cc_library (
@@ -15,3 +16,13 @@ cc_library(
1516 hdrs = ["example_lib.h" ],
1617 deps = [":example_proto" ],
1718)
19+
20+ cc_test (
21+ name = "example_lib_test" ,
22+ srcs = ["example_lib_test.cc" ],
23+ copts = ["-Iexternal/gtest/include" ],
24+ deps = [
25+ "@gtest//:main" ,
26+ ":example_lib" ,
27+ ],
28+ )
Original file line number Diff line number Diff line change 11syntax = "proto3" ;
22
3- package protos ;
3+ package third_party.protobuf_test ;
44
55message Greeting {
66 string name = 1 ;
Original file line number Diff line number Diff line change 11#include " third_party/protobuf_test/example_lib.h"
2- #include < string>
32
4- std::string get_greet (const ::protos::Greeting& who) {
3+ namespace third_party {
4+ namespace protobuf_test {
5+
6+ std::string get_greet (const Greeting& who) {
57 return " Hello " + who.name ();
68}
9+
10+ } // namespace protobuf_test
11+ } // namespace thrid_party
Original file line number Diff line number Diff line change 44
55#include < string>
66
7- std::string get_greet (const ::protos::Greeting &who);
7+ namespace third_party {
8+ namespace protobuf_test {
9+
10+ std::string get_greet (const Greeting &who);
11+
12+ } // namespace protobuf_test
13+ } // namespace third_party
Original file line number Diff line number Diff line change 1+ #include " third_party/protobuf_test/example_lib.h"
2+
3+ #include " gtest/gtest.h"
4+
5+ namespace third_party {
6+ namespace protobuf_test {
7+
8+ TEST (ProtobufTest, GetGreet) {
9+ Greeting g;
10+ g.set_name (" Paddle" );
11+ EXPECT_EQ (" Hello Paddle" , get_greet (g));
12+ }
13+
14+ } // namespace protobuf_test
15+ } // namespace third_party
You can’t perform that action at this time.
0 commit comments