提交 0ddb8447 编写于 作者: W wangguibao

Separating targets between serving side and client side

Change-Id: Ia1a31a321b02e7bb2a58b15e12dd48c610f4676a
上级 2ab4cc8a
...@@ -91,6 +91,7 @@ if(WITH_MKLDNN) ...@@ -91,6 +91,7 @@ if(WITH_MKLDNN)
endif() endif()
add_subdirectory(configure) add_subdirectory(configure)
add_subdirectory(pdcodegen)
add_subdirectory(predictor) add_subdirectory(predictor)
add_subdirectory(inferencer-fluid-cpu) add_subdirectory(inferencer-fluid-cpu)
add_subdirectory(serving) add_subdirectory(serving)
......
...@@ -793,7 +793,7 @@ function(brpc_library TARGET_NAME) ...@@ -793,7 +793,7 @@ function(brpc_library TARGET_NAME)
cc_library("${TARGET_NAME}" SRCS "${brpc_library_SRCS}" DEPS "${TARGET_NAME}_proto" "${brpc_library_DEPS}") cc_library("${TARGET_NAME}" SRCS "${brpc_library_SRCS}" DEPS "${TARGET_NAME}_proto" "${brpc_library_DEPS}")
endfunction() endfunction()
function(PROTOBUF_GENERATE_SERVING_CPP SRCS HDRS) function(PROTOBUF_GENERATE_SERVING_CPP FOR_SERVING_SIDE SRCS HDRS )
if(NOT ARGN) if(NOT ARGN)
message(SEND_ERROR "Error: PROTOBUF_GENERATE_SERVING_CPP() called without any proto files") message(SEND_ERROR "Error: PROTOBUF_GENERATE_SERVING_CPP() called without any proto files")
return() return()
...@@ -832,18 +832,33 @@ function(PROTOBUF_GENERATE_SERVING_CPP SRCS HDRS) ...@@ -832,18 +832,33 @@ function(PROTOBUF_GENERATE_SERVING_CPP SRCS HDRS)
list(APPEND ${SRCS} "${CMAKE_CURRENT_BINARY_DIR}/${FIL_WE}.pb.cc") list(APPEND ${SRCS} "${CMAKE_CURRENT_BINARY_DIR}/${FIL_WE}.pb.cc")
list(APPEND ${HDRS} "${CMAKE_CURRENT_BINARY_DIR}/${FIL_WE}.pb.h") list(APPEND ${HDRS} "${CMAKE_CURRENT_BINARY_DIR}/${FIL_WE}.pb.h")
add_custom_command( message("For serving side " ${FOR_SERVING_SIDE})
OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/${FIL_WE}.pb.cc" if (${FOR_SERVING_SIDE})
"${CMAKE_CURRENT_BINARY_DIR}/${FIL_WE}.pb.h" add_custom_command(
COMMAND ${Protobuf_PROTOC_EXECUTABLE} OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/${FIL_WE}.pb.cc"
ARGS --cpp_out=${CMAKE_CURRENT_BINARY_DIR} "${CMAKE_CURRENT_BINARY_DIR}/${FIL_WE}.pb.h"
--pdcodegen_out=${CMAKE_CURRENT_BINARY_DIR} COMMAND ${Protobuf_PROTOC_EXECUTABLE}
--plugin=protoc-gen-pdcodegen=${CMAKE_BINARY_DIR}/predictor/pdcodegen ARGS --cpp_out=${CMAKE_CURRENT_BINARY_DIR}
--proto_path=${CMAKE_SOURCE_DIR}/predictor/proto --pdcodegen_out=${CMAKE_CURRENT_BINARY_DIR}
${_protobuf_include_path} ${ABS_FIL} --plugin=protoc-gen-pdcodegen=${CMAKE_BINARY_DIR}/pdcodegen/pdcodegen
DEPENDS ${ABS_FIL} ${Protobuf_PROTOC_EXECUTABLE} --proto_path=${CMAKE_SOURCE_DIR}/predictor/proto
COMMENT "Running Paddle-serving C++ protocol buffer compiler on ${FIL}" ${_protobuf_include_path} ${ABS_FIL}
VERBATIM) DEPENDS ${ABS_FIL} ${Protobuf_PROTOC_EXECUTABLE}
COMMENT "Running Paddle-serving C++ protocol buffer compiler on ${FIL}"
VERBATIM)
else()
add_custom_command(
OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/${FIL_WE}.pb.cc"
"${CMAKE_CURRENT_BINARY_DIR}/${FIL_WE}.pb.h"
COMMAND ${Protobuf_PROTOC_EXECUTABLE}
ARGS --cpp_out=${CMAKE_CURRENT_BINARY_DIR}
--pdcodegen_out=${CMAKE_CURRENT_BINARY_DIR}
--plugin=protoc-gen-pdcodegen=${CMAKE_BINARY_DIR}/pdcodegen/pdcodegen
${_protobuf_include_path} ${ABS_FIL}
DEPENDS ${ABS_FIL} ${Protobuf_PROTOC_EXECUTABLE}
COMMENT "Running Paddle-serving C++ protocol buffer compiler on ${FIL}"
VERBATIM)
endif()
endforeach() endforeach()
set_source_files_properties(${${SRCS}} ${${HDRS}} PROPERTIES GENERATED TRUE) set_source_files_properties(${${SRCS}} ${${HDRS}} PROPERTIES GENERATED TRUE)
......
include(plugin/CMakeLists.txt)
include(src/CMakeLists.txt)
PROTOBUF_GENERATE_CPP(pdcodegen_proto_srcs pdcodegen_proto_hdrs
${CMAKE_SOURCE_DIR}/predictor/proto/pds_option.proto)
LIST(APPEND pdcodegen_srcs ${pdcodegen_proto_srcs})
add_executable(pdcodegen ${pdcodegen_srcs})
target_link_libraries(pdcodegen protobuf ${PROTOBUF_PROTOC_LIBRARY})
# install
install(TARGETS pdcodegen
RUNTIME DESTINATION ${PADDLE_SERVING_INSTALL_DIR}/bin
ARCHIVE DESTINATION ${PADDLE_SERVING_INSTALL_DIR}/lib
LIBRARY DESTINATION ${PADDLE_SERVING_INSTALL_DIR}/so
)
...@@ -45,9 +45,9 @@ ...@@ -45,9 +45,9 @@
// Author: kenton@google.com (Kenton Varda) // Author: kenton@google.com (Kenton Varda)
// #include <google/protobuf/stubs/strutil.h> // #include <google/protobuf/stubs/strutil.h>
#include "predictor/plugin/substitute.h" #include "pdcodegen/plugin/substitute.h"
#include "predictor/plugin/stl_util-inl.h" #include "pdcodegen/plugin/stl_util-inl.h"
#include "predictor/plugin/strutil.h" #include "pdcodegen/plugin/strutil.h"
namespace google { namespace google {
namespace protobuf { namespace protobuf {
......
...@@ -49,7 +49,7 @@ ...@@ -49,7 +49,7 @@
#include <string> #include <string>
// hmmm... // hmmm...
// #include <google/protobuf/stubs/strutil.h> // #include <google/protobuf/stubs/strutil.h>
#include "predictor/plugin/strutil.h" #include "pdcodegen/plugin/strutil.h"
#pragma once #pragma once
namespace google { namespace google {
......
LIST(APPEND pdcodegen_srcs ${CMAKE_CURRENT_LIST_DIR}/pdcodegen.cpp)
...@@ -20,9 +20,9 @@ ...@@ -20,9 +20,9 @@
#include "google/protobuf/descriptor.h" #include "google/protobuf/descriptor.h"
#include "google/protobuf/io/printer.h" #include "google/protobuf/io/printer.h"
#include "google/protobuf/io/zero_copy_stream.h" #include "google/protobuf/io/zero_copy_stream.h"
#include "predictor/pds_option.pb.h" #include "pdcodegen/pds_option.pb.h"
#include "predictor/plugin/strutil.h" #include "pdcodegen/plugin/strutil.h"
#include "predictor/plugin/substitute.h" #include "pdcodegen/plugin/substitute.h"
using std::string; using std::string;
using google::protobuf::Descriptor; using google::protobuf::Descriptor;
using google::protobuf::FileDescriptor; using google::protobuf::FileDescriptor;
......
...@@ -3,12 +3,9 @@ include(common/CMakeLists.txt) ...@@ -3,12 +3,9 @@ include(common/CMakeLists.txt)
include(op/CMakeLists.txt) include(op/CMakeLists.txt)
include(mempool/CMakeLists.txt) include(mempool/CMakeLists.txt)
include(framework/CMakeLists.txt) include(framework/CMakeLists.txt)
include(plugin/CMakeLists.txt) #include(plugin/CMakeLists.txt)
include(src/CMakeLists.txt) include(src/CMakeLists.txt)
add_executable(pdcodegen ${pdcodegen_srcs})
target_link_libraries(pdcodegen protobuf ${PROTOBUF_PROTOC_LIBRARY})
add_library(pdserving ${pdserving_srcs}) add_library(pdserving ${pdserving_srcs})
set_source_files_properties( set_source_files_properties(
${pdserving_srcs} ${pdserving_srcs}
...@@ -20,7 +17,7 @@ target_link_libraries(pdserving ...@@ -20,7 +17,7 @@ target_link_libraries(pdserving
brpc protobuf boost leveldb configure -lpthread -lcrypto -lm -lrt -lssl -ldl -lz) brpc protobuf boost leveldb configure -lpthread -lcrypto -lm -lrt -lssl -ldl -lz)
# install # install
install(TARGETS pdserving pdcodegen install(TARGETS pdserving
RUNTIME DESTINATION ${PADDLE_SERVING_INSTALL_DIR}/bin RUNTIME DESTINATION ${PADDLE_SERVING_INSTALL_DIR}/bin
ARCHIVE DESTINATION ${PADDLE_SERVING_INSTALL_DIR}/lib ARCHIVE DESTINATION ${PADDLE_SERVING_INSTALL_DIR}/lib
LIBRARY DESTINATION ${PADDLE_SERVING_INSTALL_DIR}/so LIBRARY DESTINATION ${PADDLE_SERVING_INSTALL_DIR}/so
......
PROTOBUF_GENERATE_CPP(pdcodegen_proto_srcs pdcodegen_proto_hdrs PROTOBUF_GENERATE_CPP(pdcodegen_proto_srcs pdcodegen_proto_hdrs
${CMAKE_CURRENT_LIST_DIR}/pds_option.proto) ${CMAKE_CURRENT_LIST_DIR}/pds_option.proto)
LIST(APPEND pdcodegen_srcs ${pdcodegen_proto_srcs}) LIST(APPEND pdserving_srcs ${pdcodegen_proto_srcs})
LIST(APPEND protofiles LIST(APPEND protofiles
${CMAKE_CURRENT_LIST_DIR}/./builtin_format.proto ${CMAKE_CURRENT_LIST_DIR}/./builtin_format.proto
...@@ -9,5 +9,5 @@ LIST(APPEND protofiles ...@@ -9,5 +9,5 @@ LIST(APPEND protofiles
${CMAKE_CURRENT_LIST_DIR}/./xrecord_format.proto ${CMAKE_CURRENT_LIST_DIR}/./xrecord_format.proto
) )
PROTOBUF_GENERATE_SERVING_CPP(PROTO_SRCS PROTO_HDRS ${protofiles}) PROTOBUF_GENERATE_SERVING_CPP(TRUE PROTO_SRCS PROTO_HDRS ${protofiles})
LIST(APPEND pdserving_srcs ${PROTO_SRCS} ${pdcodegen_proto_srcs}) LIST(APPEND pdserving_srcs ${PROTO_SRCS} ${pdcodegen_proto_srcs})
...@@ -13,7 +13,6 @@ ...@@ -13,7 +13,6 @@
// limitations under the License. // limitations under the License.
syntax = "proto2"; syntax = "proto2";
import "pds_option.proto";
package baidu.paddle_serving.predictor.format; package baidu.paddle_serving.predictor.format;
// dense format // dense format
......
LIST(APPEND pdcodegen_srcs ${CMAKE_CURRENT_LIST_DIR}/pdcodegen.cpp)
LIST(APPEND pdserving_srcs ${CMAKE_CURRENT_LIST_DIR}/pdserving.cpp) LIST(APPEND pdserving_srcs ${CMAKE_CURRENT_LIST_DIR}/pdserving.cpp)
...@@ -18,7 +18,7 @@ include(src/CMakeLists.txt) ...@@ -18,7 +18,7 @@ include(src/CMakeLists.txt)
include(proto/CMakeLists.txt) include(proto/CMakeLists.txt)
add_library(sdk-cpp ${sdk_cpp_srcs}) add_library(sdk-cpp ${sdk_cpp_srcs})
add_dependencies(sdk-cpp pdcodegen configure) add_dependencies(sdk-cpp pdcodegen configure)
target_link_libraries(sdk-cpp pdserving brpc configure protobuf leveldb) target_link_libraries(sdk-cpp brpc configure protobuf leveldb)
target_include_directories(sdk-cpp PUBLIC target_include_directories(sdk-cpp PUBLIC
${CMAKE_BINARY_DIR}/predictor/) ${CMAKE_BINARY_DIR}/predictor/)
...@@ -97,3 +97,6 @@ install(DIRECTORY ${CMAKE_CURRENT_LIST_DIR}/conf DESTINATION ...@@ -97,3 +97,6 @@ install(DIRECTORY ${CMAKE_CURRENT_LIST_DIR}/conf DESTINATION
${PADDLE_SERVING_INSTALL_DIR}/demo/client/text_classification/) ${PADDLE_SERVING_INSTALL_DIR}/demo/client/text_classification/)
install(DIRECTORY ${CMAKE_CURRENT_LIST_DIR}/data/text_classification DESTINATION install(DIRECTORY ${CMAKE_CURRENT_LIST_DIR}/data/text_classification DESTINATION
${PADDLE_SERVING_INSTALL_DIR}/demo/client/text_classification/data) ${PADDLE_SERVING_INSTALL_DIR}/demo/client/text_classification/data)
install(DIRECTORY ${CMAKE_CURRENT_LIST_DIR}/include
DESTINATION ${PADDLE_SERVING_INSTALL_DIR}/)
FILE(GLOB protos ${CMAKE_CURRENT_LIST_DIR}/*.proto) FILE(GLOB protos ${CMAKE_CURRENT_LIST_DIR}/*.proto)
PROTOBUF_GENERATE_SERVING_CPP(PROTO_SRCS PROTO_HDRS ${protos}) list(APPEND protos ${CMAKE_SOURCE_DIR}/predictor/proto/pds_option.proto
${CMAKE_SOURCE_DIR}/predictor/proto/builtin_format.proto)
PROTOBUF_GENERATE_SERVING_CPP(FALSE PROTO_SRCS PROTO_HDRS ${protos})
LIST(APPEND sdk_cpp_srcs ${PROTO_SRCS}) LIST(APPEND sdk_cpp_srcs ${PROTO_SRCS})
...@@ -7,5 +7,5 @@ LIST(APPEND protofiles ...@@ -7,5 +7,5 @@ LIST(APPEND protofiles
${CMAKE_CURRENT_LIST_DIR}/text_classification.proto ${CMAKE_CURRENT_LIST_DIR}/text_classification.proto
) )
PROTOBUF_GENERATE_SERVING_CPP(PROTO_SRCS PROTO_HDRS ${protofiles}) PROTOBUF_GENERATE_SERVING_CPP(TRUE PROTO_SRCS PROTO_HDRS ${protofiles})
LIST(APPEND serving_srcs ${PROTO_SRCS}) LIST(APPEND serving_srcs ${PROTO_SRCS})
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册