From 6a1339a31fd31ca96dc236310ae3512b45eea41b Mon Sep 17 00:00:00 2001 From: mtyszczak <mateusz.tyszczak@gmail.com> Date: Thu, 12 Dec 2024 15:07:22 +0100 Subject: [PATCH] Use generate_get_config generating protocol config typing from hive repo --- hive | 2 +- ts/wasm/src/CMakeLists.txt | 2 +- .../get_config.d/generate_get_config.cmake | 73 ------------------- 3 files changed, 2 insertions(+), 75 deletions(-) delete mode 100644 ts/wasm/src/get_config.d/generate_get_config.cmake diff --git a/hive b/hive index e86d9f42..909b0ddd 160000 --- a/hive +++ b/hive @@ -1 +1 @@ -Subproject commit e86d9f42aebc2ac81264b2dae5c5b04aeac9d3c8 +Subproject commit 909b0ddde6b1b6210cc6874b59a6dda2907660dc diff --git a/ts/wasm/src/CMakeLists.txt b/ts/wasm/src/CMakeLists.txt index d9d51e11..d18f68a8 100644 --- a/ts/wasm/src/CMakeLists.txt +++ b/ts/wasm/src/CMakeLists.txt @@ -53,7 +53,7 @@ set( INCLUDES "${WAX_ROOT_PATH}" "${HIVE_ROOT_PATH}/libraries/chain/include" ) -include("${CMAKE_CURRENT_SOURCE_DIR}/get_config.d/generate_get_config.cmake") +include("${CMAKE_CURRENT_SOURCE_DIR}/../../../hive/libraries/protocol/get_config.d/generate_get_config.cmake") generate_get_config( "${CMAKE_CURRENT_SOURCE_DIR}/../../../hive/libraries/protocol/include/hive/protocol/config.hpp" # path to config.hpp "${CMAKE_CURRENT_SOURCE_DIR}/get_config.d/config.ts.in" # path to get_config template file diff --git a/ts/wasm/src/get_config.d/generate_get_config.cmake b/ts/wasm/src/get_config.d/generate_get_config.cmake deleted file mode 100644 index 7d829c79..00000000 --- a/ts/wasm/src/get_config.d/generate_get_config.cmake +++ /dev/null @@ -1,73 +0,0 @@ -macro(generate_get_config path_to_config_hpp get_config_cpp_in get_config_cpp_out) - - file(COPY ${path_to_config_hpp} DESTINATION ${CMAKE_CURRENT_BINARY_DIR}) - set(path_to_new_config_hpp "${CMAKE_CURRENT_BINARY_DIR}/config.hpp") - - # removing includes and pragmas - file(STRINGS ${path_to_new_config_hpp} file_content ) - list(FILTER file_content EXCLUDE REGEX "#(include|pragma)" ) - set(prepared_get_content) - foreach(x ${file_content}) - list( APPEND prepared_get_content "${x}\n" ) - endforeach() - - set(_OUT_FILE "${path_to_new_config_hpp}.pregen.preprocessed.hpp" ) - set(OUT_FILE "${path_to_new_config_hpp}.preprocessed" ) - - # rewriting gile - file(WRITE ${_OUT_FILE} ${prepared_get_content} ) - - # setup compiler flags for dry run - set(local_compiler_flags "-E") - - IF( "${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" ) - list(APPEND local_compiler_flags "-fdirectives-only" "${_OUT_FILE}" "-o" "${OUT_FILE}") - ELSE() - list(APPEND local_compiler_flags "-dD" "${_OUT_FILE}" "-o" "${OUT_FILE}") - ENDIF() - - if( BUILD_HIVE_TESTNET ) - list(APPEND local_compiler_flags "-DIS_TEST_NET") - endif() - if( ENABLE_SMT_SUPPORT ) - list(APPEND local_compiler_flags "-DHIVE_ENABLE_SMT") - endif() - - # using of compiler dry run to preprocess config.hpp - message("running c++ compiler wit flags: ${local_compiler_flags}") - execute_process(COMMAND ${CMAKE_CXX_COMPILER} ${local_compiler_flags}) - - # trim additional output from comiler till the comment from header file - file(STRINGS ${OUT_FILE} config_hpp_content ) - set(preambula_on 1) - set(list_of_new_lines) - foreach(line in ${config_hpp_content}) - if( ${preambula_on} EQUAL 1 ) - string(FIND "${line}" "__HIVE_START_PROTOCOL_DEFINITIONS__" preambula_found ) - if( ${preambula_found} GREATER_EQUAL 0 ) - set(preambula_on 0) - endif() - continue() - endif() - - # parse defines - if(${line} MATCHES "^([ ]*#define)") - string(REGEX REPLACE "#define ([A-Z0-9_]+) .*" "\\1" UNSAFE_VALUE "${line}") - string(STRIP ${UNSAFE_VALUE} VALUE) - if( NOT ${VALUE} STREQUAL "HIVE_CHAIN_ID" ) - list( APPEND list_of_new_lines " \"${VALUE}\": string\;\n" ) - endif() - endif() - endforeach() - - # convert list to single varriable - set(CONFIG_HPP) - foreach(x ${list_of_new_lines}) - set(CONFIG_HPP "${CONFIG_HPP}${x}") - endforeach() - - configure_file(${get_config_cpp_in} ${get_config_cpp_out} ) - message("get_config.cpp has been generated in `${get_config_cpp_out}`") - set(GET_CONFIG_CPP ${get_config_cpp_out}) - -endmacro() \ No newline at end of file -- GitLab