Skip to content

Commit

Permalink
add example support
Browse files Browse the repository at this point in the history
  • Loading branch information
zhujiashun committed Dec 5, 2017
1 parent b92c498 commit 27643b6
Show file tree
Hide file tree
Showing 25 changed files with 246 additions and 20 deletions.
7 changes: 6 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,11 @@ include_directories(
${PROTOBUF_HEADER}
${LEVELDB_HEADER}
)

# for *.so
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
# for *.a
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)

ADD_SUBDIRECTORY(src)
#ADD_SUBDIRECTORY(example)
ADD_SUBDIRECTORY(example)
36 changes: 23 additions & 13 deletions example/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,13 +1,23 @@
set(EchoClient_SOURCES
${CMAKE_SOURCE_DIR}/example/echo/echo.pb.cc
${CMAKE_SOURCE_DIR}/example/echo/client.cpp
)
add_executable(EchoClient ${EchoClient_SOURCES})
target_link_libraries(EchoClient brpc)

set(EchoServer_SOURCES
${CMAKE_SOURCE_DIR}/example/echo/echo.pb.cc
${CMAKE_SOURCE_DIR}/example/echo/server.cpp
)
add_executable(EchoServer ${EchoServer_SOURCES})
target_link_libraries(EchoServer brpc)
add_subdirectory(http_c++)
add_subdirectory(asynchronous_echo_c++)
add_subdirectory(backup_request_c++)
add_subdirectory(cancel_c++)
add_subdirectory(cascade_echo_c++)
add_subdirectory(dynamic_partition_echo_c++)
add_subdirectory(echo_c++)
add_subdirectory(echo_c++_hulu_pbrpc)
add_subdirectory(echo_c++_sofa_pbrpc)
add_subdirectory(echo_c++_ubrpc_compack)
add_subdirectory(memcache_c++)
add_subdirectory(multi_threaded_echo_c++)
add_subdirectory(multi_threaded_echo_fns_c++)
add_subdirectory(multi_threaded_mcpack_c++)
add_subdirectory(nshead_extension_c++)
add_subdirectory(nshead_pb_extension_c++)
add_subdirectory(parallel_echo_c++)
add_subdirectory(partition_echo_c++)
# need readline library
#add_subdirectory(redis_c++)
add_subdirectory(selective_echo_c++)
add_subdirectory(session_data_and_thread_local)
add_subdirectory(streaming_echo_c++)
10 changes: 10 additions & 0 deletions example/asynchronous_echo_c++/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
include(FindProtobuf)
find_package(Protobuf REQUIRED)
include_directories(${PROTOBUF_INCLUDE_DIR})
protobuf_generate_cpp(PROTO_SRC PROTO_HEADER echo.proto)

add_executable(asynchronous_echo_client client.cpp ${PROTO_SRC} ${PROTO_HEADER})
target_link_libraries(asynchronous_echo_client brpc)

add_executable(asynchronous_echo_server server.cpp ${PROTO_SRC} ${PROTO_HEADER})
target_link_libraries(asynchronous_echo_server brpc)
10 changes: 10 additions & 0 deletions example/backup_request_c++/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
include(FindProtobuf)
find_package(Protobuf REQUIRED)
include_directories(${PROTOBUF_INCLUDE_DIR})
protobuf_generate_cpp(PROTO_SRC PROTO_HEADER echo.proto)

add_executable(backup_request_client client.cpp ${PROTO_SRC} ${PROTO_HEADER})
target_link_libraries(backup_request_client brpc)

add_executable(backup_request_server server.cpp ${PROTO_SRC} ${PROTO_HEADER})
target_link_libraries(backup_request_server brpc)
10 changes: 10 additions & 0 deletions example/cancel_c++/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
include(FindProtobuf)
find_package(Protobuf REQUIRED)
include_directories(${PROTOBUF_INCLUDE_DIR})
protobuf_generate_cpp(PROTO_SRC PROTO_HEADER echo.proto)

add_executable(cancel_client client.cpp ${PROTO_SRC} ${PROTO_HEADER})
target_link_libraries(cancel_client brpc)

add_executable(cancel_server server.cpp ${PROTO_SRC} ${PROTO_HEADER})
target_link_libraries(cancel_server brpc)
10 changes: 10 additions & 0 deletions example/cascade_echo_c++/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
include(FindProtobuf)
find_package(Protobuf REQUIRED)
include_directories(${PROTOBUF_INCLUDE_DIR})
protobuf_generate_cpp(PROTO_SRC PROTO_HEADER echo.proto)

add_executable(cascade_echo_client client.cpp ${PROTO_SRC} ${PROTO_HEADER})
target_link_libraries(cascade_echo_client brpc)

add_executable(cascade_echo_server server.cpp ${PROTO_SRC} ${PROTO_HEADER})
target_link_libraries(cascade_echo_server brpc)
10 changes: 10 additions & 0 deletions example/dynamic_partition_echo_c++/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
include(FindProtobuf)
find_package(Protobuf REQUIRED)
include_directories(${PROTOBUF_INCLUDE_DIR})
protobuf_generate_cpp(PROTO_SRC PROTO_HEADER echo.proto)

add_executable(dynamic_partition_echo_client client.cpp ${PROTO_SRC} ${PROTO_HEADER})
target_link_libraries(dynamic_partition_echo_client brpc)

add_executable(dynamic_partition_echo_server server.cpp ${PROTO_SRC} ${PROTO_HEADER})
target_link_libraries(dynamic_partition_echo_server brpc)
10 changes: 10 additions & 0 deletions example/echo_c++/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
include(FindProtobuf)
find_package(Protobuf REQUIRED)
include_directories(${PROTOBUF_INCLUDE_DIR})
protobuf_generate_cpp(PROTO_SRC PROTO_HEADER echo.proto)

add_executable(echo_client client.cpp ${PROTO_SRC} ${PROTO_HEADER})
target_link_libraries(echo_client brpc)

add_executable(echo_server server.cpp ${PROTO_SRC} ${PROTO_HEADER})
target_link_libraries(echo_server brpc)
10 changes: 10 additions & 0 deletions example/echo_c++_hulu_pbrpc/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
include(FindProtobuf)
find_package(Protobuf REQUIRED)
include_directories(${PROTOBUF_INCLUDE_DIR})
protobuf_generate_cpp(PROTO_SRC PROTO_HEADER echo.proto)

add_executable(echo_hulu_pbrpc_client client.cpp ${PROTO_SRC} ${PROTO_HEADER})
target_link_libraries(echo_hulu_pbrpc_client brpc)

add_executable(echo_hulu_pbrpc_server server.cpp ${PROTO_SRC} ${PROTO_HEADER})
target_link_libraries(echo_hulu_pbrpc_server brpc)
10 changes: 10 additions & 0 deletions example/echo_c++_sofa_pbrpc/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
include(FindProtobuf)
find_package(Protobuf REQUIRED)
include_directories(${PROTOBUF_INCLUDE_DIR})
protobuf_generate_cpp(PROTO_SRC PROTO_HEADER echo.proto)

add_executable(echo_sofa_pbrpc_client client.cpp ${PROTO_SRC} ${PROTO_HEADER})
target_link_libraries(echo_sofa_pbrpc_client brpc)

add_executable(echo_sofa_pbrpc_server server.cpp ${PROTO_SRC} ${PROTO_HEADER})
target_link_libraries(echo_sofa_pbrpc_server brpc)
15 changes: 15 additions & 0 deletions example/echo_c++_ubrpc_compack/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
include(FindProtobuf)
find_package(Protobuf REQUIRED)
include_directories(${PROTOBUF_INCLUDE_DIR})
include_directories(${CMAKE_CURRENT_BINARY_DIR})
execute_process(
COMMAND ${PROTOBUF_PROTOC_EXECUTABLE} ${PROTO_FLAGS} --cpp_out=${CMAKE_CURRENT_BINARY_DIR} --proto_path=${PROTOBUF_INCLUDE_DIR} --proto_path=${CMAKE_CURRENT_BINARY_DIR}/../../src/ --proto_path=${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_BINARY_DIR}/echo.proto
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
)

add_executable(echo_ubrpc_compack_client client.cpp echo.pb.cc)
target_link_libraries(echo_ubrpc_compack_client brpc)

add_executable(echo_ubrpc_compack_server server.cpp echo.pb.cc)
target_link_libraries(echo_ubrpc_compack_server brpc)

13 changes: 13 additions & 0 deletions example/http_c++/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
include(FindProtobuf)
find_package(Protobuf REQUIRED)
include_directories(${PROTOBUF_INCLUDE_DIR})
protobuf_generate_cpp(PROTO_SRC PROTO_HEADER http.proto)

add_executable(http_client http_client.cpp)
target_link_libraries(http_client brpc)

add_executable(http_server http_server.cpp ${PROTO_SRC} ${PROTO_HEADER})
target_link_libraries(http_server brpc)

add_executable(benchmark_http benchmark_http.cpp)
target_link_libraries(benchmark_http brpc)
2 changes: 2 additions & 0 deletions example/memcache_c++/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
add_executable(memcache_client client.cpp)
target_link_libraries(memcache_client brpc)
10 changes: 10 additions & 0 deletions example/multi_threaded_echo_c++/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
include(FindProtobuf)
find_package(Protobuf REQUIRED)
include_directories(${PROTOBUF_INCLUDE_DIR})
protobuf_generate_cpp(PROTO_SRC PROTO_HEADER echo.proto)

add_executable(multi_threaded_echo_client client.cpp ${PROTO_SRC} ${PROTO_HEADER})
target_link_libraries(multi_threaded_echo_client brpc)

add_executable(multi_threaded_echo_server server.cpp ${PROTO_SRC} ${PROTO_HEADER})
target_link_libraries(multi_threaded_echo_server brpc)
10 changes: 10 additions & 0 deletions example/multi_threaded_echo_fns_c++/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
include(FindProtobuf)
find_package(Protobuf REQUIRED)
include_directories(${PROTOBUF_INCLUDE_DIR})
protobuf_generate_cpp(PROTO_SRC PROTO_HEADER echo.proto)

add_executable(multi_threaded_echo_fns_client client.cpp ${PROTO_SRC} ${PROTO_HEADER})
target_link_libraries(multi_threaded_echo_fns_client brpc)

add_executable(multi_threaded_echo_fns_server server.cpp ${PROTO_SRC} ${PROTO_HEADER})
target_link_libraries(multi_threaded_echo_fns_server brpc)
14 changes: 14 additions & 0 deletions example/multi_threaded_mcpack_c++/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
include(FindProtobuf)
find_package(Protobuf REQUIRED)
include_directories(${PROTOBUF_INCLUDE_DIR})
include_directories(${CMAKE_CURRENT_BINARY_DIR})
execute_process(
COMMAND ${PROTOBUF_PROTOC_EXECUTABLE} ${PROTO_FLAGS} --cpp_out=${CMAKE_CURRENT_BINARY_DIR} --proto_path=${PROTOBUF_INCLUDE_DIR} --proto_path=${CMAKE_CURRENT_BINARY_DIR}/../../src/ --proto_path=${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_BINARY_DIR}/echo.proto
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
)

add_executable(multi_threaded_mcpack_client client.cpp echo.pb.cc)
target_link_libraries(multi_threaded_mcpack_client brpc)

add_executable(multi_threaded_mcpack_server server.cpp echo.pb.cc)
target_link_libraries(multi_threaded_mcpack_server brpc)
5 changes: 5 additions & 0 deletions example/nshead_extension_c++/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
add_executable(nshead_extension_client client.cpp)
target_link_libraries(nshead_extension_client brpc)

add_executable(nshead_extension_server server.cpp)
target_link_libraries(nshead_extension_server brpc)
10 changes: 10 additions & 0 deletions example/nshead_pb_extension_c++/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
include(FindProtobuf)
find_package(Protobuf REQUIRED)
include_directories(${PROTOBUF_INCLUDE_DIR})
protobuf_generate_cpp(PROTO_SRC PROTO_HEADER echo.proto)

add_executable(nshead_pb_extension_client client.cpp ${PROTO_SRC} ${PROTO_HEADER})
target_link_libraries(nshead_pb_extension_client brpc)

add_executable(nshead_pb_extension_server server.cpp ${PROTO_SRC} ${PROTO_HEADER})
target_link_libraries(nshead_pb_extension_server brpc)
10 changes: 10 additions & 0 deletions example/parallel_echo_c++/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
include(FindProtobuf)
find_package(Protobuf REQUIRED)
include_directories(${PROTOBUF_INCLUDE_DIR})
protobuf_generate_cpp(PROTO_SRC PROTO_HEADER echo.proto)

add_executable(parallel_echo_client client.cpp ${PROTO_SRC} ${PROTO_HEADER})
target_link_libraries(parallel_echo_client brpc)

add_executable(parallel_echo_server server.cpp ${PROTO_SRC} ${PROTO_HEADER})
target_link_libraries(parallel_echo_server brpc)
10 changes: 10 additions & 0 deletions example/partition_echo_c++/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
include(FindProtobuf)
find_package(Protobuf REQUIRED)
include_directories(${PROTOBUF_INCLUDE_DIR})
protobuf_generate_cpp(PROTO_SRC PROTO_HEADER echo.proto)

add_executable(client client.cpp ${PROTO_SRC} ${PROTO_HEADER})
target_link_libraries(client brpc)

add_executable(server server.cpp ${PROTO_SRC} ${PROTO_HEADER})
target_link_libraries(server brpc)
6 changes: 6 additions & 0 deletions example/redis_c++/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
add_executable(redis_cli redis_cli.cpp)
target_link_libraries(redis_cli brpc)

add_executable(redis_press redis_press.cpp)
target_link_libraries(redis_press brpc)

10 changes: 10 additions & 0 deletions example/selective_echo_c++/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
include(FindProtobuf)
find_package(Protobuf REQUIRED)
include_directories(${PROTOBUF_INCLUDE_DIR})
protobuf_generate_cpp(PROTO_SRC PROTO_HEADER echo.proto)

add_executable(selective_echo_client client.cpp ${PROTO_SRC} ${PROTO_HEADER})
target_link_libraries(selective_echo_client brpc)

add_executable(selective_echo_server server.cpp ${PROTO_SRC} ${PROTO_HEADER})
target_link_libraries(selective_echo_server brpc)
10 changes: 10 additions & 0 deletions example/session_data_and_thread_local/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
include(FindProtobuf)
find_package(Protobuf REQUIRED)
include_directories(${PROTOBUF_INCLUDE_DIR})
protobuf_generate_cpp(PROTO_SRC PROTO_HEADER echo.proto)

add_executable(session_data_and_thread_local_client client.cpp ${PROTO_SRC} ${PROTO_HEADER})
target_link_libraries(session_data_and_thread_local_client brpc)

add_executable(session_data_and_thread_local_server server.cpp ${PROTO_SRC} ${PROTO_HEADER})
target_link_libraries(session_data_and_thread_local_server brpc)
10 changes: 10 additions & 0 deletions example/streaming_echo_c++/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
include(FindProtobuf)
find_package(Protobuf REQUIRED)
include_directories(${PROTOBUF_INCLUDE_DIR})
protobuf_generate_cpp(PROTO_SRC PROTO_HEADER echo.proto)

add_executable(streaming_echo_client client.cpp ${PROTO_SRC} ${PROTO_HEADER})
target_link_libraries(streaming_echo_client brpc)

add_executable(streaming_echo_server server.cpp ${PROTO_SRC} ${PROTO_HEADER})
target_link_libraries(streaming_echo_server brpc)
8 changes: 2 additions & 6 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,13 @@ find_package(Protobuf REQUIRED)
include_directories(${PROTOBUF_INCLUDE_DIR})
include_directories(${CMAKE_CURRENT_BINARY_DIR})
file(GLOB PROTOS "*.proto" "brpc/*.proto" "brpc/policy/*.proto")
message("PROTOBUF_INCLUDE_DIR=${PROTOBUF_INCLUDE_DIR}")
message("PROTOBUF_PROTOC_EXECUTABLE=${PROTOBUF_PROTOC_EXECUTABLE}")
message("proto=${PROTOS}")
message("CMAKE_CURRENT_BINARY_DIR=${CMAKE_CURRENT_BINARY_DIR}")
list(APPEND PROTO_FLAGS -I${CMAKE_CURRENT_BINARY_DIR})

foreach(PROTO ${PROTOS})
get_filename_component(PROTO_WE ${PROTO} NAME_WE)

list(APPEND PROTO_SRCS "${CMAKE_CURRENT_BINARY_DIR}/${PROTO_WE}.pb.cc")
list(APPEND PROTO_HDRS "${CMAKE_CURRENT_BINARY_DIR}/${PROTO_WE}.pb.h")
#list(APPEND PROTO_SRCS "${CMAKE_CURRENT_BINARY_DIR}/${PROTO_WE}.pb.cc")
#list(APPEND PROTO_HDRS "${CMAKE_CURRENT_BINARY_DIR}/${PROTO_WE}.pb.h")

execute_process(
COMMAND ${PROTOBUF_PROTOC_EXECUTABLE} ${PROTO_FLAGS} --cpp_out=${CMAKE_CURRENT_BINARY_DIR} --proto_path=${PROTOBUF_INCLUDE_DIR} ${PROTO}
Expand Down

0 comments on commit 27643b6

Please sign in to comment.