Skip to content

Commit

Permalink
refactor: separate files from replication.thrift (#760)
Browse files Browse the repository at this point in the history
  • Loading branch information
Wu Tao authored Feb 23, 2021
1 parent 660bf06 commit c057d35
Show file tree
Hide file tree
Showing 22 changed files with 1,655 additions and 28,705 deletions.
6 changes: 6 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,12 @@ message (STATUS "dsn Installation directory: CMAKE_INSTALL_PREFIX = " ${CMAKE_IN
# install rdsn/include to ${CMAKE_INCLUDE_PREFIX}/include
install(DIRECTORY include/ DESTINATION include)

# NOTE: dsn_types.h is not actually a thrift-generated file. As pegasus may reference it,
# we should copy also this file to the path the same as other thrift-generated files.
install(FILES include/dsn/cpp/serialization_helper/dsn_types.h DESTINATION include)
# TODO(wutao1): remove this line after dsn.layer2_types.h is removed from repo.
install(FILES include/dsn/cpp/serialization_helper/dsn.layer2_types.h DESTINATION include)

include_directories(${DSN_PROJECT_DIR}/include)
include_directories(${DSN_PROJECT_DIR}/include/dsn/cpp/serialization_helper)
include_directories(${DSN_PROJECT_DIR}/src)
Expand Down
2 changes: 1 addition & 1 deletion bin/dsn.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -343,6 +343,6 @@ function(dsn_common_setup)
dsn_setup_include_path()
dsn_setup_thirdparty_libs()

include(bin/thrift_utils.cmake)
include(${DSN_PROJECT_DIR}/bin/thrift_utils.cmake)

endfunction(dsn_common_setup)
11 changes: 7 additions & 4 deletions bin/thrift_utils.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -54,23 +54,26 @@ function(THRIFT_GENERATE_CPP SRCS HDRS thrift_file)
message(STATUS "THRIFT_GENERATE_CPP: ${thrift_file}")

exec_program(${THRIFT_COMPILER}
ARGS --out ${THRIFT_GENERATED_FILE_PATH} --gen cpp ${thrift_file}
ARGS -gen cpp:moveable_types --out ${THRIFT_GENERATED_FILE_PATH} --gen cpp ${thrift_file}
OUTPUT_VARIABLE __thrift_OUT
RETURN_VALUE THRIFT_RETURN)
if(NOT ${THRIFT_RETURN} EQUAL "0")
message(STATUS "COMMAND: ${THRIFT_COMPILER} --out ${THRIFT_GENERATED_FILE_PATH} --gen cpp ${thrift_file}")
message(STATUS "COMMAND: ${THRIFT_COMPILER} -gen cpp:moveable_types --out ${THRIFT_GENERATED_FILE_PATH} --gen cpp ${thrift_file}")
message(FATAL_ERROR "thrift-compiler exits with " ${THRIFT_RETURN} ": " ${__thrift_OUT})
endif()

get_filename_component(__thrift_name ${thrift_file} NAME_WE)

set(${SRCS})
set(${HDRS})
file(GLOB_RECURSE __result_src "${THRIFT_GENERATED_FILE_PATH}/${__thrift_name}*.cpp")
file(GLOB_RECURSE __result_hdr "${THRIFT_GENERATED_FILE_PATH}/${__thrift_name}*.h")
file(GLOB __result_src "${THRIFT_GENERATED_FILE_PATH}/${__thrift_name}_types.cpp")
file(GLOB __result_hdr "${THRIFT_GENERATED_FILE_PATH}/${__thrift_name}_types.h")
list(APPEND ${SRCS} ${__result_src})
list(APPEND ${HDRS} ${__result_hdr})
# Sets the variables in global scope.
set(${SRCS} ${${SRCS}} PARENT_SCOPE)
set(${HDRS} ${${HDRS}} PARENT_SCOPE)

# install the thrift generated headers to include/
install(FILES ${__result_hdr} DESTINATION include)
endfunction()
18 changes: 0 additions & 18 deletions compile_thrift.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,24 +28,6 @@
"_types.cpp": "src/runtime"
}
},
{
"name": "replication",
"path": "src/",
"file_move": {
"_types.h": "include/dsn/dist/replication",
"_types.cpp": "src/common"
},
"include_fix": {
"_types.h": {
"add": ["<dsn/cpp/serialization_helper/dsn.layer2_types.h>"],
"remove": ["\"dsn_types.h\"", "\"dsn.layer2_types.h\""]
},
"_types.cpp": {
"add": ["<dsn/dist/replication/replication_types.h>"],
"remove": ["\"replication_types.h\""]
},
},
},
]


Expand Down
2 changes: 0 additions & 2 deletions include/dsn/dist/replication/duplication_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,6 @@ typedef rpc_holder<duplication_modify_request, duplication_modify_response> dupl
typedef rpc_holder<duplication_add_request, duplication_add_response> duplication_add_rpc;
typedef rpc_holder<duplication_query_request, duplication_query_response> duplication_query_rpc;
typedef rpc_holder<duplication_sync_request, duplication_sync_response> duplication_sync_rpc;
typedef rpc_holder<configuration_update_app_env_request, configuration_update_app_env_response>
update_app_env_rpc;

typedef int32_t dupid_t;

Expand Down
Loading

0 comments on commit c057d35

Please sign in to comment.