Skip to content
This repository has been archived by the owner on Jun 23, 2022. It is now read-only.

refactor: remove generated thrift srcs from repo #758

Merged
merged 6 commits into from
Feb 20, 2021
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions bin/dsn.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -342,4 +342,7 @@ function(dsn_common_setup)
dsn_setup_compiler_flags()
dsn_setup_include_path()
dsn_setup_thirdparty_libs()

include(bin/thrift_utils.cmake)

endfunction(dsn_common_setup)
77 changes: 77 additions & 0 deletions bin/thrift_utils.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
##############################################################################
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
##############################################################################

find_program(THRIFT_COMPILER
NAME
thrift
PATHS
${DSN_THIRDPARTY_ROOT}/bin
NO_DEFAULT_PATH
REQUIRED
neverchanje marked this conversation as resolved.
Show resolved Hide resolved
)

set(THRIFT_GENERATED_FILE_PATH ${CMAKE_BINARY_DIR}/thrift-gen CACHE INTERNAL "Where the thrift generated sources locate")
if(NOT EXISTS ${THRIFT_GENERATED_FILE_PATH})
file(MAKE_DIRECTORY ${THRIFT_GENERATED_FILE_PATH})
endif()
message(STATUS "THRIFT_GENERATED_FILE_PATH=${THRIFT_GENERATED_FILE_PATH}")
include_directories(${THRIFT_GENERATED_FILE_PATH})

# THRIFT_GENERATE_CPP is used to generate sources using the thrift compiler.
#
# Example:
#
# thrift_generate_cpp(
# REQUEST_META_THRIFT_SRCS
# REQUEST_META_THRIFT_HDRS
# ${CMAKE_CURRENT_SOURCE_DIR}/request_meta.thrift
# )
# add_library(
# dsn_rpc
# ${REQUEST_META_THRIFT_SRCS}
# ...
# )
function(THRIFT_GENERATE_CPP SRCS HDRS thrift_file)
if(NOT EXISTS ${thrift_file})
message(FATAL_ERROR "thrift file ${thrift_file} does not exist")
endif()

message(STATUS "THRIFT_GENERATE_CPP: ${thrift_file}")

exec_program(${THRIFT_COMPILER}
ARGS --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(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")
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)
endfunction()
36 changes: 0 additions & 36 deletions compile_thrift.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,46 +63,10 @@
},
},
},
{
"name": "nfs",
"path": "src/nfs",
"include_fix": {
"_types.h": {
"add": ["<dsn/service_api_cpp.h>"],
"remove": ["\"dsn_types.h\""]
}
}
},
{
"name": "simple_kv",
"path": "src/replica/storage/simple_kv"
},
{
"name": "command",
"path": "src/remote_cmd",
"file_move": {
"_types.h": "src/remote_cmd",
"_types.cpp": "src/remote_cmd"
}
},
{
"name": "security",
"path": "src/runtime/security",
"file_move": {
"_types.h": "src/runtime/security",
"_types.cpp": "src/runtime/security"
},
"include_fix": {
"_types.h": {
"add": ["<dsn/cpp/serialization_helper/dsn_types.h>"],
"remove": ["\"dsn_types.h\""]
},
"_types.cpp": {
"add": ["\"security_types.h\""],
"remove": ["\"security_types.h\""]
}
}
}
]


Expand Down
97 changes: 0 additions & 97 deletions include/dsn/cpp/serialization_helper/dsn.layer2_types.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 0 additions & 19 deletions src/dsn.layer2.thrift
Original file line number Diff line number Diff line change
Expand Up @@ -76,22 +76,3 @@ struct app_info
// Whether this app is executing bulk load
14:optional bool is_bulk_loading = false;
}

// Metadata field of the request in rDSN's thrift protocol (version 1).
// TODO(wutao1): add design doc of the thrift protocol.
struct thrift_request_meta_v1
{
// The replica's gpid.
1:optional i32 app_id;
2:optional i32 partition_index;

// The timeout of this request that's set on client side.
3:optional i32 client_timeout;

// The hash value calculated from the hash key.
4:optional i64 client_partition_hash;

// Whether it is a backup request. If true, this request (only if it's a read) can be handled by
// a secondary replica, which does not guarantee strong consistency.
5:optional bool is_backup_request;
}
10 changes: 7 additions & 3 deletions src/nfs/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
set(MY_PROJ_NAME dsn_nfs)

# Source files under CURRENT project directory will be automatically included.
# You can manually set MY_PROJ_SRC to include source files under other directories.
set(MY_PROJ_SRC "")
thrift_generate_cpp(
NFS_THRIFT_SRCS
NFS_THRIFT_HDRS
${CMAKE_CURRENT_SOURCE_DIR}/nfs.thrift
)

set(MY_PROJ_SRC ${NFS_THRIFT_SRCS})

# Search mode for source files under CURRENT project directory?
# "GLOB_RECURSE" for recursive search
Expand Down
6 changes: 0 additions & 6 deletions src/nfs/nfs.thrift
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,3 @@ struct get_file_size_response
2: list<string> file_list;
3: list<i64> size_list;
}

service nfs
{
copy_response copy(1: copy_request request);
get_file_size_response get_file_size(1: get_file_size_request request);
}
Loading