From 97c3460af8700de1675d39ea40019c36b3dc5a01 Mon Sep 17 00:00:00 2001 From: cryptozoidberg Date: Wed, 20 Mar 2024 14:45:29 +0100 Subject: [PATCH] autodoc inital code + cmake warningns + improvements over compilation performance --- CMakeLists.txt | 9 +++++++-- .../include/net/http_server_handlers_map2.h | 17 +++++++++++++++-- .../serialization/keyvalue_serialization.h | 12 ++++++++---- .../keyvalue_serialization_overloads.h | 4 ++-- .../epee/include/storages/portable_storage.h | 12 ++++++------ contrib/zlib/CMakeLists.txt | 1 - src/CMakeLists.txt | 4 ++-- src/daemon/daemon.cpp | 2 ++ src/rpc/core_rpc_server_commands_defs.h | 5 +++-- tests/gtest/CMakeLists.txt | 5 ++++- utils/Directory.Build.props.in | 7 +++++++ 11 files changed, 56 insertions(+), 22 deletions(-) create mode 100644 utils/Directory.Build.props.in diff --git a/CMakeLists.txt b/CMakeLists.txt index 9baf00a1..0666e592 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.5) +cmake_minimum_required(VERSION 3.16) PROJECT(Zano) @@ -18,6 +18,9 @@ endif() if(POLICY CMP0043) cmake_policy(SET CMP0074 NEW) endif() +if(POLICY CMP0144) + cmake_policy(SET CMP0144 NEW) +endif() set(CMAKE_CXX_STANDARD 17) @@ -122,6 +125,7 @@ if(MSVC) endforeach() endif() include_directories(SYSTEM src/platform/msc) + configure_file(utils/Directory.Build.props.in ${CMAKE_BINARY_DIR}/Directory.Build.props) else() set(ARCH default CACHE STRING "CPU to build for: -march value or default") if("${ARCH}" STREQUAL "default") @@ -258,8 +262,9 @@ elseif(NOT MSVC) endif() if(BUILD_GUI) - cmake_minimum_required(VERSION 3.1) find_package(Qt5Widgets REQUIRED) + find_package(Qt5WebEngineWidgets REQUIRED) + find_package(Qt5WebChannel REQUIRED) endif() set(COMMIT_ID_IN_VERSION ON CACHE BOOL "Include commit ID in version") diff --git a/contrib/epee/include/net/http_server_handlers_map2.h b/contrib/epee/include/net/http_server_handlers_map2.h index 3102cb2d..93fac55e 100644 --- a/contrib/epee/include/net/http_server_handlers_map2.h +++ b/contrib/epee/include/net/http_server_handlers_map2.h @@ -45,10 +45,23 @@ bool auto_doc_t(const std::string& prefix_name, std::string& generate_reference) if (!generate_reference.size()) return true; request_t req = get_documentation_json_struct(); response_t res = get_documentation_json_struct(); + + std::string req_str; + epee::serialization::portable_storage ps; + req.store(ps, nullptr, true); + ps.dump_as_json(req_str); + + + std::string res_str; + epee::serialization::portable_storage ps_res; + res.store(ps_res, nullptr, true); + ps_res.dump_as_json(res_str); + + std::stringstream ss; ss << prefix_name << ENDL - << "REQUEST: " << ENDL << epee::serialization::store_t_to_json(req) << ENDL << "--------------------------------" << ENDL - << "RESPONSE: " << ENDL << epee::serialization::store_t_to_json(res) << ENDL << "################################" << ENDL; + << "REQUEST: " << ENDL << req_str << ENDL << "--------------------------------" << ENDL + << "RESPONSE: " << ENDL << res_str << ENDL << "################################" << ENDL; generate_reference += ss.str(); return true; } diff --git a/contrib/epee/include/serialization/keyvalue_serialization.h b/contrib/epee/include/serialization/keyvalue_serialization.h index 31c90df7..033b12ca 100644 --- a/contrib/epee/include/serialization/keyvalue_serialization.h +++ b/contrib/epee/include/serialization/keyvalue_serialization.h @@ -32,16 +32,16 @@ #include "keyvalue_helpers.h" #include "keyvalue_serialization_overloads.h" namespace epee -{ +{ /************************************************************************/ /* Serialize map declarations */ /************************************************************************/ #define BEGIN_KV_SERIALIZE_MAP() \ public: \ template \ - bool store(t_storage& st, typename t_storage::hsection hparent_section = nullptr) const\ + bool store(t_storage& st, typename t_storage::hsection hparent_section = nullptr, bool auto_doc_mode = false) const\ {\ - return serialize_map(*this, st, hparent_section); \ + return serialize_map(*this, st, hparent_section, auto_doc_mode); \ }\ template \ bool _load(t_storage& stg, typename t_storage::hsection hparent_section = nullptr)\ @@ -62,12 +62,15 @@ public: \ }\ }\ template \ - static bool serialize_map(this_type& this_ref, t_storage& stg, typename t_storage::hsection hparent_section) \ + static bool serialize_map(this_type& this_ref, t_storage& stg, typename t_storage::hsection hparent_section, bool auto_doc_mode = false) \ { #define KV_SERIALIZE_N(varialble, val_name) \ epee::serialization::selector::serialize(this_ref.varialble, stg, hparent_section, val_name); +#define KV_SERIALIZE_N_DOC(varialble, val_name, substitute) \ + epee::serialization::selector::serialize(this_ref.varialble, stg, hparent_section, val_name, auto_doc_mode, substitute); + #define KV_SERIALIZE_CUSTOM_N(varialble, stored_type, from_v_to_stored, from_stored_to_v, val_name) \ epee::serialization::selector::template serialize_custom(this_ref.varialble, stg, hparent_section, val_name, from_v_to_stored, from_stored_to_v); @@ -95,6 +98,7 @@ public: \ #define END_KV_SERIALIZE_MAP() return true;} #define KV_SERIALIZE(varialble) KV_SERIALIZE_N(varialble, #varialble) +#define KV_SERIALIZE_DOC(varialble, substitute) KV_SERIALIZE_N_DOC( varialble, #varialble, substitute) #define KV_SERIALIZE_VAL_POD_AS_BLOB(varialble) KV_SERIALIZE_VAL_POD_AS_BLOB_N(varialble, #varialble) #define KV_SERIALIZE_VAL_POD_AS_BLOB_FORCE(varialble) KV_SERIALIZE_VAL_POD_AS_BLOB_FORCE_N(varialble, #varialble) //skip is_pod compile time check #define KV_SERIALIZE_CONTAINER_POD_AS_BLOB(varialble) KV_SERIALIZE_CONTAINER_POD_AS_BLOB_N(varialble, #varialble) diff --git a/contrib/epee/include/serialization/keyvalue_serialization_overloads.h b/contrib/epee/include/serialization/keyvalue_serialization_overloads.h index c0d46af3..c79c56b2 100644 --- a/contrib/epee/include/serialization/keyvalue_serialization_overloads.h +++ b/contrib/epee/include/serialization/keyvalue_serialization_overloads.h @@ -315,9 +315,9 @@ namespace epee struct selector { template - static bool serialize(const t_type& d, t_storage& stg, typename t_storage::hsection hparent_section, const char* pname) + static bool serialize(const t_type& d, t_storage& stg, typename t_storage::hsection hparent_section, const char* pname, bool doc_mode = false, const t_type& doc_substitute = t_type()) { - return kv_serialize(d, stg, hparent_section, pname); + return kv_serialize( (doc_mode ? doc_substitute:d), stg, hparent_section, pname); } template diff --git a/contrib/epee/include/storages/portable_storage.h b/contrib/epee/include/storages/portable_storage.h index a5d46e19..0a8b8127 100644 --- a/contrib/epee/include/storages/portable_storage.h +++ b/contrib/epee/include/storages/portable_storage.h @@ -63,18 +63,18 @@ namespace epee //serial access for arrays of values -------------------------------------- //values template - harray get_first_value(const std::string& value_name, t_value& target, hsection hparent_section); + harray get_first_value(const std::string& value_name, t_value& target, hsection hparent_section); template bool get_next_value(harray hval_array, t_value& target); template - harray insert_first_value(const std::string& value_name, const t_value& target, hsection hparent_section); + harray insert_first_value(const std::string& value_name, const t_value& target, hsection hparent_section); template bool insert_next_value(harray hval_array, const t_value& target); //sections - harray get_first_section(const std::string& pSectionName, hsection& h_child_section, hsection hparent_section); - bool get_next_section(harray hSecArray, hsection& h_child_section); - harray insert_first_section(const std::string& pSectionName, hsection& hinserted_childsection, hsection hparent_section); - bool insert_next_section(harray hSecArray, hsection& hinserted_childsection); + harray get_first_section(const std::string& pSectionName, hsection& h_child_section, hsection hparent_section); + bool get_next_section(harray hSecArray, hsection& h_child_section); + harray insert_first_section(const std::string& pSectionName, hsection& hinserted_childsection, hsection hparent_section); + bool insert_next_section(harray hSecArray, hsection& hinserted_childsection); //------------------------------------------------------------------------ //delete entry (section, value or array) bool delete_entry(const std::string& pentry_name, hsection hparent_section = nullptr); diff --git a/contrib/zlib/CMakeLists.txt b/contrib/zlib/CMakeLists.txt index 696b9f52..97fd8bf4 100644 --- a/contrib/zlib/CMakeLists.txt +++ b/contrib/zlib/CMakeLists.txt @@ -1,4 +1,3 @@ -cmake_minimum_required(VERSION 2.4.4) set(CMAKE_ALLOW_LOOSE_LOOP_CONSTRUCTS ON) project(zlib C) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 6b5ff732..200096f3 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -196,10 +196,10 @@ if(BUILD_GUI) ENABLE_SHARED_PCH(Zano QTDAEMON) ENABLE_SHARED_PCH_EXECUTABLE(Zano) - QT5_USE_MODULES(Zano WebEngineWidgets WebChannel) + #QT5_USE_MODULES(Zano WebEngineWidgets WebChannel) find_package(Qt5PrintSupport REQUIRED) - target_link_libraries(Zano wallet rpc currency_core crypto common zlibstatic ethash Qt5::WebEngineWidgets Qt5::PrintSupport ${CMAKE_THREAD_LIBS_INIT} ${Boost_LIBRARIES} OpenSSL::SSL OpenSSL::Crypto) + target_link_libraries(Zano wallet rpc currency_core crypto common zlibstatic ethash Qt5::WebChannel Qt5::WebEngineWidgets Qt5::PrintSupport ${CMAKE_THREAD_LIBS_INIT} ${Boost_LIBRARIES} OpenSSL::SSL OpenSSL::Crypto) if (UNIX AND NOT APPLE) target_link_libraries(Zano rt) endif() diff --git a/src/daemon/daemon.cpp b/src/daemon/daemon.cpp index cb09bdb2..004da0b8 100644 --- a/src/daemon/daemon.cpp +++ b/src/daemon/daemon.cpp @@ -287,6 +287,8 @@ int main(int argc, char* argv[]) rpc_server.handle_http_request_map(query_info, response_info, conn_context, call_found, json_rpc_reference); LOG_PRINT_L0(generate_reference << ENDL << "----------------------------------------" << ENDL << json_rpc_reference); + + return 0; } bool res = false; diff --git a/src/rpc/core_rpc_server_commands_defs.h b/src/rpc/core_rpc_server_commands_defs.h index ca55f2d4..056b3bfe 100644 --- a/src/rpc/core_rpc_server_commands_defs.h +++ b/src/rpc/core_rpc_server_commands_defs.h @@ -149,12 +149,13 @@ namespace currency std::string status; BEGIN_KV_SERIALIZE_MAP() - KV_SERIALIZE(height) - KV_SERIALIZE(status) + KV_SERIALIZE_DOC(height, uint64_t(11111)) + KV_SERIALIZE_DOC(status, std::string("OK")) END_KV_SERIALIZE_MAP() }; }; + template struct COMMAND_RPC_GET_BLOCKS_FAST_T { diff --git a/tests/gtest/CMakeLists.txt b/tests/gtest/CMakeLists.txt index ddd5443b..5b6e758e 100644 --- a/tests/gtest/CMakeLists.txt +++ b/tests/gtest/CMakeLists.txt @@ -9,6 +9,10 @@ # make it prominent in the GUI. option(BUILD_SHARED_LIBS "Build shared libraries (DLLs)." OFF) +if(POLICY CMP0148) + cmake_policy(SET CMP0148 OLD) +endif() + # When other libraries are using a shared version of runtime libraries, # Google Test also has to use one. option( @@ -40,7 +44,6 @@ endif() # ${gtest_BINARY_DIR}. # Language "C" is required for find_package(Threads). project(gtest CXX C) -cmake_minimum_required(VERSION 2.6.2) if (COMMAND set_up_hermetic_build) set_up_hermetic_build() diff --git a/utils/Directory.Build.props.in b/utils/Directory.Build.props.in new file mode 100644 index 00000000..168abb6a --- /dev/null +++ b/utils/Directory.Build.props.in @@ -0,0 +1,7 @@ + + + + true + true + +