-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Fetch protobuf definitions from hedera services repository (#810)
Signed-off-by: gsstoykov <[email protected]>
- Loading branch information
Showing
271 changed files
with
801 additions
and
538 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,107 +1,64 @@ | ||
set(HAPI_LIBRARY_HASH "cf995030036c92624f9054570f1bf4e9607610a67ccf277d17b3b80ba67e4838" CACHE STRING "Use the configured hash to verify the Hedera API protobuf library release") | ||
set(HAPI_LIBRARY_URL "https://github.com/hashgraph/hedera-protobufs-cpp/releases/download/v0.55.0/hapi-library-32c2a4a2.tar.gz" CACHE STRING "Use the configured URL to download the Hedera API protobuf library package") | ||
set(HAPI_VERSION_TAG "v0.55.0" CACHE STRING "Use the configured version tag for the Hedera API protobufs") | ||
|
||
set(HAPI_LOCAL_LIBRARY_PATH "" CACHE STRING "Overrides the configured HAPI_LIBRARY_URL setting and instead uses the local path to retrieve the artifacts") | ||
|
||
if (HAPI_LOCAL_LIBRARY_PATH STREQUAL "") | ||
# Fetch the HAPI Library | ||
FetchContent_Declare( | ||
hapi | ||
URL ${HAPI_LIBRARY_URL} | ||
URL_HASH SHA256=${HAPI_LIBRARY_HASH} | ||
) | ||
set(FETCHCONTENT_QUIET OFF) | ||
FetchContent_MakeAvailable(hapi) | ||
else () | ||
set(hapi_SOURCE_DIR ${HAPI_LOCAL_LIBRARY_PATH}) | ||
if (HAPI_VERSION_TAG STREQUAL "") | ||
set(HAPI_VERSION_TAG "v0.55.0") | ||
endif () | ||
|
||
set(HAPI_ROOT_DIR ${hapi_SOURCE_DIR}/${CMAKE_HOST_SYSTEM_NAME}/${CMAKE_HOST_SYSTEM_PROCESSOR}) | ||
# Fetch the protobuf definitions | ||
FetchContent_Declare( | ||
HProto | ||
GIT_REPOSITORY https://github.com/hashgraph/hedera-services.git | ||
GIT_TAG ${HAPI_VERSION_TAG} | ||
) | ||
set(FETCHCONTENT_QUIET OFF) | ||
FetchContent_MakeAvailable(HProto) | ||
|
||
# Clean and update the protobuf definitions | ||
set(PROTO_SRC ${PROJECT_SOURCE_DIR}/proto) | ||
|
||
# Get all .proto files in the specified directory | ||
file(GLOB_RECURSE PROTO_FILES ${PROTO_SRC}/*.proto) | ||
|
||
# List of files to exclude from removal | ||
set(EXCLUDE_FILES | ||
"consensus_service.proto" | ||
"mirror_network_service.proto" | ||
"transaction_list.proto" | ||
) | ||
|
||
# Create a list to hold files to be removed | ||
set(FILES_TO_REMOVE "") | ||
|
||
# Iterate over all found .proto files | ||
foreach(PROTO_FILE ${PROTO_FILES}) | ||
# Get the file name without the path | ||
get_filename_component(FILENAME ${PROTO_FILE} NAME) | ||
|
||
# Check if the file is in the exclusion list | ||
list(FIND EXCLUDE_FILES ${FILENAME} INDEX) | ||
|
||
# If the file is not in the exclusion list, add it to the removal list | ||
if (INDEX EQUAL -1) | ||
list(APPEND FILES_TO_REMOVE ${PROTO_FILE}) | ||
endif() | ||
endforeach() | ||
|
||
# Remove the files that are not in the exclusion list | ||
if (FILES_TO_REMOVE) | ||
file(REMOVE ${FILES_TO_REMOVE}) | ||
endif() | ||
|
||
file(INSTALL ${PROJECT_SOURCE_DIR}/proto/service-external-proto/mirror/ DESTINATION ${PROTO_SRC}/mirror) | ||
file(INSTALL ${hproto_SOURCE_DIR}/hapi/hedera-protobufs/services/ DESTINATION ${PROTO_SRC}) | ||
file(INSTALL ${PROJECT_SOURCE_DIR}/proto/service-external-proto/sdk/ DESTINATION ${PROTO_SRC}) | ||
|
||
add_subdirectory(proto) | ||
|
||
set(HAPI_ROOT_DIR ${CMAKE_CURRENT_BINARY_DIR}/proto) | ||
|
||
if (NOT EXISTS ${HAPI_ROOT_DIR}) | ||
set(HAPI_ROOT_DIR ${hapi_SOURCE_DIR}/${CMAKE_BUILD_TYPE}/${CMAKE_HOST_SYSTEM_NAME}/${CMAKE_HOST_SYSTEM_PROCESSOR}) | ||
|
||
if (NOT EXISTS ${HAPI_ROOT_DIR}) | ||
message(FATAL_ERROR "Failed to the HAPI_ROOT_DIR at `${HAPI_ROOT_DIR}`") | ||
endif () | ||
message(FATAL_ERROR "Failed to the HAPI_ROOT_DIR at `${HAPI_ROOT_DIR}`") | ||
endif () | ||
|
||
set(HAPI_INCLUDE_DIR ${HAPI_ROOT_DIR}/include) | ||
set(HAPI_LIB_DIR ${HAPI_ROOT_DIR}/lib) | ||
|
||
function(create_req_link_target prefix name nixlib winlib) | ||
string(TOUPPER "${prefix}" prefixUpper) | ||
string(TOUPPER "${name}" nameUpper) | ||
if (prefix STREQUAL "") | ||
set(variableName "${nameUpper}_LINK_TARGET") | ||
else () | ||
set(variableName "${prefixUpper}_${nameUpper}_LINK_TARGET") | ||
endif () | ||
|
||
set(linkTarget "${HAPI_LIB_DIR}/${nixlib}") | ||
if (NOT EXISTS ${linkTarget}) | ||
set(linkTarget "${HAPI_LIB_DIR}/${winlib}") | ||
|
||
if (NOT EXISTS ${linkTarget}) | ||
message(FATAL_ERROR "Failed to locate the ${variableName} at `${HAPI_LIB_DIR}/(${nixlib}|${winlib})`") | ||
endif () | ||
endif () | ||
|
||
set(${variableName} ${linkTarget} PARENT_SCOPE) | ||
endfunction() | ||
|
||
function(create_opt_link_target prefix name nixlib winlib) | ||
string(TOUPPER "${prefix}" prefixUpper) | ||
string(TOUPPER "${name}" nameUpper) | ||
if (prefix STREQUAL "") | ||
set(variableName "${nameUpper}_LINK_TARGET") | ||
else () | ||
set(variableName "${prefixUpper}_${nameUpper}_LINK_TARGET") | ||
endif () | ||
|
||
set(linkTarget "${HAPI_LIB_DIR}/${nixlib}") | ||
if (NOT EXISTS ${linkTarget}) | ||
set(linkTarget "${HAPI_LIB_DIR}/${winlib}") | ||
|
||
if (NOT EXISTS ${linkTarget}) | ||
set(linkTarget "") | ||
message(WARNING "Failed to locate the ${variableName} at `${HAPI_LIB_DIR}/(${nixlib}|${winlib})`") | ||
endif () | ||
endif () | ||
|
||
set(${variableName} ${linkTarget} PARENT_SCOPE) | ||
endfunction() | ||
|
||
function(create_external_package prefix) | ||
math(EXPR lastIndex "${ARGC}-1") | ||
string(TOUPPER "${prefix}" prefixUpper) | ||
|
||
# Create all the imported library targets first | ||
foreach (index RANGE 1 ${lastIndex}) | ||
string(TOUPPER "${ARGV${index}}" nameUpper) | ||
if (prefix STREQUAL "") | ||
set(LIBNAME${index} "${ARGV${index}}") | ||
set(LINKTARGET${index} "${nameUpper}_LINK_TARGET") | ||
else () | ||
set(LIBNAME${index} "${prefix}::${ARGV${index}}") | ||
set(LINKTARGET${index} "${prefixUpper}_${nameUpper}_LINK_TARGET") | ||
endif () | ||
|
||
# message("LIBNAME${index}=${LIBNAME${index}}") | ||
# message("LINKTARGET${index}=${LINKTARGET${index}}") | ||
if (NOT ${${LINKTARGET${index}}} STREQUAL "") | ||
add_library(${LIBNAME${index}} STATIC IMPORTED) | ||
endif () | ||
endforeach () | ||
|
||
# Now import the link targets | ||
foreach (index RANGE 1 ${lastIndex}) | ||
if (NOT ${${LINKTARGET${index}}} STREQUAL "") | ||
set_target_properties(${LIBNAME${index}} PROPERTIES IMPORTED_LOCATION ${${LINKTARGET${index}}}) | ||
endif () | ||
endforeach () | ||
endfunction() | ||
|
||
|
||
create_req_link_target(hapi proto libhapi.a hapi.lib) | ||
create_external_package(hapi proto) | ||
set(HAPI_INCLUDE_DIR ${HAPI_ROOT_DIR}) | ||
set(HAPI_LIB_DIR ${HAPI_ROOT_DIR}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,127 @@ | ||
# Begin Protobuf Definitions | ||
set(PROTO_FILES | ||
address_book_service.proto | ||
basic_types.proto | ||
consensus_create_topic.proto | ||
consensus_delete_topic.proto | ||
consensus_get_topic_info.proto | ||
consensus_service.proto | ||
consensus_submit_message.proto | ||
consensus_topic_info.proto | ||
consensus_update_topic.proto | ||
contract_call.proto | ||
contract_call_local.proto | ||
contract_create.proto | ||
contract_delete.proto | ||
contract_get_bytecode.proto | ||
contract_get_info.proto | ||
contract_get_records.proto | ||
contract_update.proto | ||
contract_types.proto | ||
crypto_add_live_hash.proto | ||
crypto_approve_allowance.proto | ||
crypto_create.proto | ||
crypto_delete.proto | ||
crypto_delete_allowance.proto | ||
crypto_delete_live_hash.proto | ||
crypto_get_account_balance.proto | ||
crypto_get_account_records.proto | ||
crypto_get_info.proto | ||
crypto_get_live_hash.proto | ||
crypto_get_stakers.proto | ||
crypto_service.proto | ||
crypto_transfer.proto | ||
crypto_update.proto | ||
custom_fees.proto | ||
duration.proto | ||
ethereum_transaction.proto | ||
exchange_rate.proto | ||
file_append.proto | ||
file_create.proto | ||
file_delete.proto | ||
file_get_contents.proto | ||
file_get_info.proto | ||
file_service.proto | ||
file_update.proto | ||
freeze.proto | ||
freeze_service.proto | ||
freeze_type.proto | ||
get_account_details.proto | ||
get_by_key.proto | ||
get_by_solidity_id.proto | ||
network_get_execution_time.proto | ||
network_get_version_info.proto | ||
network_service.proto | ||
node_create.proto | ||
node_delete.proto | ||
node_stake_update.proto | ||
node_update.proto | ||
query.proto | ||
query_header.proto | ||
response.proto | ||
response_code.proto | ||
response_header.proto | ||
schedulable_transaction_body.proto | ||
schedule_create.proto | ||
schedule_delete.proto | ||
schedule_get_info.proto | ||
schedule_service.proto | ||
schedule_sign.proto | ||
smart_contract_service.proto | ||
system_delete.proto | ||
system_undelete.proto | ||
throttle_definitions.proto | ||
timestamp.proto | ||
token_airdrop.proto | ||
token_associate.proto | ||
token_burn.proto | ||
token_cancel_airdrop.proto | ||
token_claim_airdrop.proto | ||
token_create.proto | ||
token_delete.proto | ||
token_dissociate.proto | ||
token_fee_schedule_update.proto | ||
token_freeze_account.proto | ||
token_get_account_nft_infos.proto | ||
token_get_info.proto | ||
token_get_nft_info.proto | ||
token_get_nft_infos.proto | ||
token_grant_kyc.proto | ||
token_mint.proto | ||
token_pause.proto | ||
token_reject.proto | ||
token_revoke_kyc.proto | ||
token_service.proto | ||
token_unfreeze_account.proto | ||
token_unpause.proto | ||
token_update.proto | ||
token_update_nfts.proto | ||
token_wipe_account.proto | ||
transaction.proto | ||
transaction_body.proto | ||
transaction_contents.proto | ||
transaction_get_fast_record.proto | ||
transaction_get_receipt.proto | ||
transaction_get_record.proto | ||
transaction_list.proto | ||
transaction_receipt.proto | ||
transaction_record.proto | ||
transaction_response.proto | ||
unchecked_submit.proto | ||
util_prng.proto | ||
util_service.proto | ||
|
||
mirror/consensus_service.proto | ||
mirror/mirror_network_service.proto) | ||
# End Protobuf Definitions | ||
|
||
add_library(hapi STATIC ${PROTO_FILES}) | ||
target_link_libraries(hapi PRIVATE protobuf::libprotobuf gRPC::grpc gRPC::grpc++ OpenSSL::SSL OpenSSL::Crypto) | ||
target_include_directories(hapi PRIVATE ${CMAKE_CURRENT_BINARY_DIR}) | ||
|
||
# | ||
# Compile protobuf and grpc files in the hapi target to cpp | ||
# | ||
get_target_property(grpc_cpp_plugin_location gRPC::grpc_cpp_plugin LOCATION) | ||
protobuf_generate(TARGET hapi LANGUAGE cpp IMPORT_DIRS ${PROTO_SRC}) | ||
protobuf_generate(TARGET hapi LANGUAGE grpc GENERATE_EXTENSIONS .grpc.pb.h .grpc.pb.cc PLUGIN "protoc-gen-grpc=${grpc_cpp_plugin_location}" IMPORT_DIRS ${PROTO_SRC}) |
Oops, something went wrong.