From 7f50c0b2cd78b50346ebf53140d650858032b76e Mon Sep 17 00:00:00 2001 From: Alexander Diemand Date: Sat, 21 Oct 2023 23:44:45 +0200 Subject: [PATCH 1/4] upgrade gitalk for code extraction Signed-off-by: Alexander Diemand --- build/CMakeLists.txt | 73 +++++++++---- build/mk_cpp.sh | 30 ------ build/src/CMakeLists.txt | 186 ++++++++++++++++++++++++++++++++- build/test/CMakeLists.txt | 83 +++++++++++++-- ext/gitalk | 2 +- src/cpp/key128.hpp.md | 2 + src/cpp/key128_ctor.cpp.md | 7 ++ src/cpp/key256.hpp.md | 2 + src/cpp/key256_ctor.cpp.md | 7 ++ test/cpp/elykseer-crypto-ut.md | 29 ----- 10 files changed, 325 insertions(+), 96 deletions(-) delete mode 100755 build/mk_cpp.sh delete mode 100644 test/cpp/elykseer-crypto-ut.md diff --git a/build/CMakeLists.txt b/build/CMakeLists.txt index c733d35..37fe27e 100644 --- a/build/CMakeLists.txt +++ b/build/CMakeLists.txt @@ -2,21 +2,28 @@ cmake_minimum_required(VERSION 3.5) IF(DEFINED CMAKE_BUILD_TYPE) - SET(CMAKE_BUILD_TYPE ${CMAKE_BUILD_TYPE} CACHE STRING "Choose the type of build, options are: None(CMAKE_CXX_FLAGS or CMAKE_C_FLAGS used) Debug Release DebugProfile RelWithDebInfo MinSizeRel.") + SET(CMAKE_BUILD_TYPE ${CMAKE_BUILD_TYPE} CACHE STRING + "Choose the type of build, options are: + None(CMAKE_CXX_FLAGS or CMAKE_C_FLAGS used) + Debug Release RelWithDebInfo MinSizeRel." ) ELSE() - SET(CMAKE_BUILD_TYPE Debug CACHE STRING "Choose the type of build, options are: None(CMAKE_CXX_FLAGS or CMAKE_C_FLAGS used) Debug Release DebugProfile RelWithDebInfo MinSizeRel.") + SET(CMAKE_BUILD_TYPE Debug CACHE STRING + "Choose the type of build, options are: + None(CMAKE_CXX_FLAGS or CMAKE_C_FLAGS used) + Debug Release RelWithDebInfo MinSizeRel." ) ENDIF() -project(elykseer-crypto CXX) +find_program(CCACHE_PROGRAM ccache) +if(CCACHE_PROGRAM) + set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE "${CCACHE_PROGRAM}") +endif() -message("CMAKE_SYSTEM_NAME: ${CMAKE_SYSTEM_NAME}") -message("CMAKE_HOST_SYSTEM_PROCESSOR: ${CMAKE_HOST_SYSTEM_PROCESSOR}") -message("CMAKE_SYSTEM: ${CMAKE_SYSTEM}") +project(elykseer-crypto CXX) # The version number. set (${PROJECT_NAME}_VERSION_MAJOR 1) set (${PROJECT_NAME}_VERSION_MINOR 0) -set (${PROJECT_NAME}_VERSION_PATCH 8) +set (${PROJECT_NAME}_VERSION_PATCH 9) set (${PROJECT_NAME}_VERSION_STRING ${elykseer-crypto_VERSION_MAJOR}.${elykseer-crypto_VERSION_MINOR}.${elykseer-crypto_VERSION_PATCH}) # choose either one @@ -25,12 +32,25 @@ set(USE_CRYPTOPP YES) option(RUN_ADDRESS_SANITIZER "using Clang you can turn on address sanitizer in Debug") -set(CMAKE_CXX_STANDARD 17) +# set to '-DDEBUG' to turn on debugging output +# set to '-UDEBUG' to disable debugging output +add_definitions( -UDEBUG ) + +set(CMAKE_CXX_STANDARD 20) set(CMAKE_CXX_STANDARD_REQUIRED ON) -set(CMAKE_LINKER_LANGUAGE "CXX") set(CMAKE_POSITION_INDEPENDENT_CODE ON) +# boost +add_definitions( -DBOOST_ALL_DYN_LINK ) +set(Boost_DEBUG OFF) +set(Boost_USE_STATIC_LIBS OFF) +set(Boost_USE_STATIC_RUNTIME OFF) +set(Boost_USE_MULTITHREADED ON) +find_package( Boost 1.74.0 REQUIRED COMPONENTS system date_time contract ) +link_directories ( ${Boost_LIBRARY_DIRS} ) +include_directories (${Boost_INCLUDE_DIRS}) + find_package(PkgConfig) find_program(CPPCHECK NAMES cppcheck) @@ -39,10 +59,10 @@ IF(CPPCHECK) message(STATUS "Found: cppcheck") add_custom_target(cppcheck ${CPPCHECK} - -Uassert --std=c++17 --enable=all - ${CMAKE_SOURCE_DIR}/build/src/lxr/*.hpp - ${CMAKE_SOURCE_DIR}/build/src/*.cpp - ${CMAKE_SOURCE_DIR}/build/test/*.cpp + -Uassert --std=c++20 --enable=all + ${CMAKE_SOURCE_DIR}/src/lxr/*.hpp + ${CMAKE_SOURCE_DIR}/src/*.cpp + ${CMAKE_SOURCE_DIR}/test/*.cpp -I ${CMAKE_SOURCE_DIR}/../ext -I /opt/homebrew/include ) @@ -58,20 +78,21 @@ set(LIB_PREFIX "") # OS dependent IF(${CMAKE_SYSTEM_NAME} MATCHES "Darwin") - set(CMAKE_OSX_DEPLOYMENT_TARGET "13.0") - include_directories(/usr/local/opt/zlib/include) - link_directories(/usr/local/opt/zlib/lib) - link_directories(/usr/local/lib) - include_directories(/opt/homebrew/opt/zlib/include) - link_directories(/opt/homebrew/opt/zlib/lib) - link_directories(/opt/homebrew/lib) - set(SELECTED_AR "/opt/homebrew/opt/binutils/bin/ar") + set(CMAKE_OSX_DEPLOYMENT_TARGET "13.6") + #include_directories(/usr/local/opt/zlib/include) + #link_directories(/usr/local/opt/zlib/lib) + #link_directories(/usr/local/lib) + #include_directories(/opt/homebrew/opt/zlib/include) + #link_directories(/opt/homebrew/opt/zlib/lib) + #link_directories(/opt/homebrew/lib) + find_program (SELECTED_AR NAMES ar PATHS /opt/homebrew/opt/binutils/bin /opt/homebrew/ NO_DEFAULT_PATH REQUIRED) + #set(SELECTED_AR "/opt/homebrew/opt/binutils/bin/ar") set(LIB_PREFIX "lib") - set(libs "dl" "z" "intl") + set(libs "dl" "z") ENDIF(${CMAKE_SYSTEM_NAME} MATCHES "Darwin") IF(${CMAKE_SYSTEM_NAME} MATCHES "Windows") - set(EXT_PATH ${CMAKE_SYSTEM_NAME}_${CMAKE_HOST_SYSTEM_PROCESSOR}) + #set(EXT_PATH ${CMAKE_SYSTEM_NAME}_${CMAKE_HOST_SYSTEM_PROCESSOR}) set(PLATFORM "win64") IF(${CMAKE_HOST_SYSTEM_PROCESSOR} MATCHES "AMD64") set(PROCESSOR_TYPE "x86_64") @@ -98,6 +119,12 @@ include_directories(../ext/) include_directories(../ext/${EXT_PATH}/include) link_directories("../ext/${EXT_PATH}/lib") +find_program (HTML2TEXT NAMES html2text html2text.exe PATHS ../ext/${EXT_PATH}/bin NO_DEFAULT_PATH REQUIRED) +IF(HTML2TEXT) + message(STATUS "Found: html2text in " ${HTML2TEXT}) + set(ENV{HTML2TEXT} ${HTML2TEXT}) +ENDIF() + # cryptography IF(USE_CRYPTOPP) add_definitions( -DCRYPTOPP ) diff --git a/build/mk_cpp.sh b/build/mk_cpp.sh deleted file mode 100755 index 03790d1..0000000 --- a/build/mk_cpp.sh +++ /dev/null @@ -1,30 +0,0 @@ -#!/usr/bin/env bash - -UNAME_S=$(uname -s) -UNAME_M=$(uname -m) - -GITALK=$(pwd)/../ext/gitalk - -if [ -e ${GITALK}/../${UNAME_S}_${UNAME_M}/bin/html2text ]; then - export PATH=${GITALK}/../${UNAME_S}_${UNAME_M}/bin/:$PATH -fi - -cd src -cd lxr -for HPP in `bash $GITALK/utils/find_hpp.sh ../../../src/cpp/elykseer-crypto.md`; do - bash $GITALK/utils/make_hpp.sh ${HPP} -done - -cd .. -for HPP in `bash $GITALK/utils/find_hpp.sh ../../src/cpp/elykseer-crypto.md`; do - echo ${HPP} - bash $GITALK/utils/make_cpp.sh ${HPP} -done - -cd .. -cd test - -$GITALK/utils/make_test.sh ../../test/cpp/elykseer-crypto-ut.md - -cd .. - diff --git a/build/src/CMakeLists.txt b/build/src/CMakeLists.txt index 3083aac..f372203 100644 --- a/build/src/CMakeLists.txt +++ b/build/src/CMakeLists.txt @@ -4,13 +4,181 @@ cmake_minimum_required(VERSION 3.5) include_directories(".") # list of source files to be compiled -file(GLOB SRCS *.cpp) +set(GENERATED_SRCS + aes.cpp + gpg.cpp + key.cpp + key128.cpp + key256.cpp + md5.cpp + randlist.cpp + random.cpp + sha256.cpp) +set_source_files_properties(${GENERATED_SRCS} GENERATED) +set(GENERATED_HDRS + lxr/aes.hpp + lxr/gpg.hpp + lxr/key.hpp + lxr/key128.hpp + lxr/key256.hpp + lxr/lxr-cbindings.hpp + lxr/lxr-crypto.hpp + lxr/md5.hpp + lxr/randlist.hpp + lxr/random.hpp + lxr/sha256.hpp) +set_source_files_properties(${GENERATED_HDRS} GENERATED) + +# generate sources from literate c++ files +set(MAKE_CPP_CMD ${CMAKE_CURRENT_SOURCE_DIR}/../../ext/gitalk/utils/make_cpp.sh) +set(MAKE_HPP_CMD ${CMAKE_COMMAND} -E env HTML2TEXT=${HTML2TEXT} ${CMAKE_CURRENT_SOURCE_DIR}/../../ext/gitalk/utils/make_hpp.sh) + +set(LITERATE_SRC_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../../src/cpp") + +add_custom_command( + WORKING_DIRECTORY "lxr" + COMMAND rm -f lxr-crypto.hpp + COMMAND ${MAKE_HPP_CMD} "${LITERATE_SRC_PATH}/lxr-crypto.hpp.md" + OUTPUT lxr/lxr-crypto.hpp) +add_custom_command( + WORKING_DIRECTORY "lxr" + COMMAND rm -f lxr-cbindings.hpp + COMMAND ${MAKE_HPP_CMD} "${LITERATE_SRC_PATH}/lxr-cbindings.hpp.md" + OUTPUT lxr/lxr-cbindings.hpp) + +add_custom_command( + COMMAND rm -f aes.cpp + COMMAND ${MAKE_CPP_CMD} "${LITERATE_SRC_PATH}/aes.hpp.md" + MAIN_DEPENDENCY "${LITERATE_SRC_PATH}/aes.hpp.md" + DEPENDS "${LITERATE_SRC_PATH}/aes*.md" + OUTPUT aes.cpp) +add_custom_command( + WORKING_DIRECTORY "lxr" + COMMAND rm -f aes.hpp + COMMAND ${MAKE_HPP_CMD} "${LITERATE_SRC_PATH}/aes.hpp.md" + MAIN_DEPENDENCY "${LITERATE_SRC_PATH}/aes.hpp.md" + DEPENDS "${LITERATE_SRC_PATH}/aes*.md" + OUTPUT lxr/aes.hpp) + +add_custom_command( + COMMAND rm -f gpg.cpp + COMMAND ${MAKE_CPP_CMD} "${LITERATE_SRC_PATH}/gpg.hpp.md" + MAIN_DEPENDENCY "${LITERATE_SRC_PATH}/gpg.hpp.md" + DEPENDS "${LITERATE_SRC_PATH}/gpg*.md" + OUTPUT gpg.cpp) +add_custom_command( + WORKING_DIRECTORY "lxr" + COMMAND rm -f gpg.hpp + COMMAND ${MAKE_HPP_CMD} "${LITERATE_SRC_PATH}/gpg.hpp.md" + MAIN_DEPENDENCY "${LITERATE_SRC_PATH}/gpg.hpp.md" + DEPENDS "${LITERATE_SRC_PATH}/gpg*.md" + OUTPUT lxr/gpg.hpp) + +add_custom_command( + COMMAND rm -f key.cpp + COMMAND ${MAKE_CPP_CMD} "${LITERATE_SRC_PATH}/key.hpp.md" + MAIN_DEPENDENCY "${LITERATE_SRC_PATH}/key.hpp.md" + DEPENDS "${LITERATE_SRC_PATH}/key*.md" + OUTPUT key.cpp) +add_custom_command( + WORKING_DIRECTORY "lxr" + COMMAND rm -f key.hpp + COMMAND ${MAKE_HPP_CMD} "${LITERATE_SRC_PATH}/key.hpp.md" + MAIN_DEPENDENCY "${LITERATE_SRC_PATH}/key.hpp.md" + DEPENDS "${LITERATE_SRC_PATH}/key*.md" + OUTPUT lxr/key.hpp) + +add_custom_command( + COMMAND rm -f key128.cpp + COMMAND ${MAKE_CPP_CMD} "${LITERATE_SRC_PATH}/key128.hpp.md" + MAIN_DEPENDENCY "${LITERATE_SRC_PATH}/key128.hpp.md" + DEPENDS "${LITERATE_SRC_PATH}/key128*.md" + OUTPUT key128.cpp) +add_custom_command( + WORKING_DIRECTORY "lxr" + COMMAND rm -f key128.hpp + COMMAND ${MAKE_HPP_CMD} "${LITERATE_SRC_PATH}/key128.hpp.md" + MAIN_DEPENDENCY "${LITERATE_SRC_PATH}/key128.hpp.md" + DEPENDS "${LITERATE_SRC_PATH}/key128*.md" + OUTPUT lxr/key128.hpp) + +add_custom_command( + COMMAND rm -f key256.cpp + COMMAND ${MAKE_CPP_CMD} "${LITERATE_SRC_PATH}/key256.hpp.md" + MAIN_DEPENDENCY "${LITERATE_SRC_PATH}/key256.hpp.md" + DEPENDS "${LITERATE_SRC_PATH}/key256*.md" + OUTPUT key256.cpp) +add_custom_command( + WORKING_DIRECTORY "lxr" + COMMAND rm -f key256.hpp + COMMAND ${MAKE_HPP_CMD} "${LITERATE_SRC_PATH}/key256.hpp.md" + MAIN_DEPENDENCY "${LITERATE_SRC_PATH}/key256.hpp.md" + DEPENDS "${LITERATE_SRC_PATH}/key256*.md" + OUTPUT lxr/key256.hpp) + +add_custom_command( + COMMAND rm -f md5.cpp + COMMAND ${MAKE_CPP_CMD} "${LITERATE_SRC_PATH}/md5.hpp.md" + MAIN_DEPENDENCY "${LITERATE_SRC_PATH}/md5.hpp.md" + DEPENDS "${LITERATE_SRC_PATH}/md5*.md" + OUTPUT md5.cpp) +add_custom_command( + WORKING_DIRECTORY "lxr" + COMMAND rm -f md5.hpp + COMMAND ${MAKE_HPP_CMD} "${LITERATE_SRC_PATH}/md5.hpp.md" + MAIN_DEPENDENCY "${LITERATE_SRC_PATH}/md5.hpp.md" + DEPENDS "${LITERATE_SRC_PATH}/md5*.md" + OUTPUT lxr/md5.hpp) + +add_custom_command( + COMMAND rm -f randlist.cpp + COMMAND ${MAKE_CPP_CMD} "${LITERATE_SRC_PATH}/randlist.hpp.md" + MAIN_DEPENDENCY "${LITERATE_SRC_PATH}/randlist.hpp.md" + DEPENDS "${LITERATE_SRC_PATH}/randlist*.md" + OUTPUT randlist.cpp) +add_custom_command( + WORKING_DIRECTORY "lxr" + COMMAND rm -f randlist.hpp + COMMAND ${MAKE_HPP_CMD} "${LITERATE_SRC_PATH}/randlist.hpp.md" + MAIN_DEPENDENCY "${LITERATE_SRC_PATH}/randlist.hpp.md" + DEPENDS "${LITERATE_SRC_PATH}/randlist*.md" + OUTPUT lxr/randlist.hpp) + +add_custom_command( + COMMAND rm -f random.cpp + COMMAND ${MAKE_CPP_CMD} "${LITERATE_SRC_PATH}/random.hpp.md" + MAIN_DEPENDENCY "${LITERATE_SRC_PATH}/random.hpp.md" + DEPENDS "${LITERATE_SRC_PATH}/random*.md" + OUTPUT random.cpp) +add_custom_command( + WORKING_DIRECTORY "lxr" + COMMAND rm -f random.hpp + COMMAND ${MAKE_HPP_CMD} "${LITERATE_SRC_PATH}/random.hpp.md" + MAIN_DEPENDENCY "${LITERATE_SRC_PATH}/random.hpp.md" + DEPENDS "${LITERATE_SRC_PATH}/random*.md" + OUTPUT lxr/random.hpp) + +add_custom_command( + COMMAND rm -f sha256.cpp + COMMAND ${MAKE_CPP_CMD} "${LITERATE_SRC_PATH}/sha256.hpp.md" + MAIN_DEPENDENCY "${LITERATE_SRC_PATH}/sha256.hpp.md" + DEPENDS "${LITERATE_SRC_PATH}/sha256*.md" + OUTPUT sha256.cpp) +add_custom_command( + WORKING_DIRECTORY "lxr" + COMMAND rm -f sha256.hpp + COMMAND ${MAKE_HPP_CMD} "${LITERATE_SRC_PATH}/sha256.hpp.md" + MAIN_DEPENDENCY "${LITERATE_SRC_PATH}/sha256.hpp.md" + DEPENDS "${LITERATE_SRC_PATH}/sha256*.md" + OUTPUT lxr/sha256.hpp) + IF(${CMAKE_SYSTEM_NAME} MATCHES "Windows") message("not building dynamic library on ${CMAKE_SYSTEM_NAME}") ELSE() add_library (${PROJECT_NAME}_${CMAKE_BUILD_TYPE} SHARED - ${SRCS}) + ${GENERATED_SRCS} + ${GENERATED_HDRS}) set_target_properties(${PROJECT_NAME}_${CMAKE_BUILD_TYPE} PROPERTIES VERSION ${elykseer-crypto_VERSION_STRING} SOVERSION ${elykseer-crypto_VERSION_MAJOR}) @@ -26,7 +194,8 @@ ENDIF(${CMAKE_SYSTEM_NAME} MATCHES "Windows") # targets add_library (${PROJECT_NAME}_${CMAKE_BUILD_TYPE}_s STATIC - ${SRCS} + ${GENERATED_SRCS} + ${GENERATED_HDRS} ) # combine all static libs into one @@ -67,7 +236,7 @@ add_custom_target(static_lib ALL # profiling if (CMAKE_BUILD_TYPE STREQUAL "DebugProfile") add_library (${PROJECT_NAME}_p${CMAKE_BUILD_TYPE} STATIC - ${SRCS} + ${GENERATED_SRCS} ) set_target_properties(${PROJECT_NAME}_p${CMAKE_BUILD_TYPE} PROPERTIES COMPILE_FLAGS "-fprofile-arcs -ftest-coverage") #set(libs, "${libs} gcov") @@ -79,4 +248,13 @@ if (CMAKE_BUILD_TYPE STREQUAL "DebugProfile") ) endif() +set(CPACK_PACKAGE_VERSION ${${PROJECT_NAME}_VERSION_STRING}) +set(CPACK_PACKAGE_VERSION_MAJOR ${${PROJECT_NAME}_VERSION_MAJOR}) +set(CPACK_PACKAGE_VERSION_MINOR ${${PROJECT_NAME}_VERSION_MINOR}) +set(CPACK_PACKAGE_VERSION_PATCH ${${PROJECT_NAME}_VERSION_PATCH}) +install(FILES ${LIBRARY_NAME} DESTINATION lib) +install(FILES ${GENERATED_HDRS} DESTINATION include/lxr) +include(CPack) +set(CPACK_BINARY_STGZ "OFF") +set(CPACK_BINARY_TGZ "ON") diff --git a/build/test/CMakeLists.txt b/build/test/CMakeLists.txt index 696cd12..ba8836d 100644 --- a/build/test/CMakeLists.txt +++ b/build/test/CMakeLists.txt @@ -1,29 +1,44 @@ cmake_minimum_required(VERSION 3.5) +IF(DEFINED CMAKE_BUILD_TYPE) + SET(CMAKE_BUILD_TYPE ${CMAKE_BUILD_TYPE} CACHE STRING "Choose the type of build, options are: None(CMAKE_CXX_FLAGS or CMAKE_C_FLAGS used) Debug Release DebugProfile RelWithDebInfo MinSizeRel.") +ELSE() + SET(CMAKE_BUILD_TYPE Debug CACHE STRING "Choose the type of build, options are: None(CMAKE_CXX_FLAGS or CMAKE_C_FLAGS used) Debug Release DebugProfile RelWithDebInfo MinSizeRel.") +ENDIF() + # boost set(Boost_DEBUG OFF) set(Boost_USE_STATIC_LIBS OFF) set(Boost_USE_STATIC_RUNTIME OFF) set(Boost_USE_MULTITHREADED ON) -find_package( Boost 1.70.0 REQUIRED COMPONENTS system unit_test_framework contract) -include_directories(${Boost_INCLUDE_DIRS}) +find_package( Boost 1.74.0 REQUIRED COMPONENTS system date_time unit_test_framework contract) +#include_directories(${Boost_INCLUDE_DIRS}) # mine include_directories(../src) -file(GLOB SRCS ut*.cpp) +set(GENERATED_SRCS + utAes.cpp + utGpg.cpp + utKey128.cpp + utKey256.cpp + utMain.cpp + utMd5.cpp + utRandList.cpp + utRandom.cpp + utSha256.cpp) +set_source_files_properties(${GENERATED_SRCS} GENERATED) if (CMAKE_BUILD_TYPE STREQUAL "Debug") + add_executable ( ut${PROJECT_NAME} + ${GENERATED_SRCS} + ) add_library(libelykseer-crypto_s STATIC IMPORTED) set_target_properties(libelykseer-crypto_s PROPERTIES IMPORTED_LOCATION "${CMAKE_HOME_DIRECTORY}/src/libelykseer-crypto_d.a") - add_executable ( ut${PROJECT_NAME} - ${SRCS} - ) - target_link_libraries ( ut${PROJECT_NAME} - libelykseer-crypto_s + elykseer-crypto_${CMAKE_BUILD_TYPE} ${libs} ${Boost_LIBRARIES} ${CRYPTO_LIBS} @@ -32,7 +47,7 @@ endif() if (CMAKE_BUILD_TYPE STREQUAL "DebugProfile") add_executable ( utp${PROJECT_NAME} - ${SRCS} + ${GENERATED_SRCS} ) set_target_properties(utp${PROJECT_NAME} PROPERTIES LINK_FLAGS "-fprofile-arcs -ftest-coverage ") target_link_libraries ( utp${PROJECT_NAME} @@ -45,3 +60,53 @@ if (CMAKE_BUILD_TYPE STREQUAL "DebugProfile") endif() +# generate sources from literate c++ files +set(EXTRACT_CPP_CMD "${CMAKE_CURRENT_SOURCE_DIR}/../../ext/gitalk/utils/extract_cpp.sh") + +set(LITERATE_SRC_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../../test/cpp") + +add_custom_command( + COMMAND rm -f utAes.cpp + COMMAND ${EXTRACT_CPP_CMD} "${LITERATE_SRC_PATH}/utAes.cpp.md" utAes.cpp + DEPENDS "${LITERATE_SRC_PATH}/utAes.cpp.md" + OUTPUT utAes.cpp) +add_custom_command( + COMMAND rm -f utGpg.cpp + COMMAND ${EXTRACT_CPP_CMD} "${LITERATE_SRC_PATH}/utGpg.cpp.md" utGpg.cpp + DEPENDS "${LITERATE_SRC_PATH}/utGpg.cpp.md" + OUTPUT utGpg.cpp) +add_custom_command( + COMMAND rm -f utKey128.cpp + COMMAND ${EXTRACT_CPP_CMD} "${LITERATE_SRC_PATH}/utKey128.cpp.md" utKey128.cpp + DEPENDS "${LITERATE_SRC_PATH}/utKey128.cpp.md" + OUTPUT utKey128.cpp) +add_custom_command( + COMMAND rm -f utKey256.cpp + COMMAND ${EXTRACT_CPP_CMD} "${LITERATE_SRC_PATH}/utKey256.cpp.md" utKey256.cpp + DEPENDS "${LITERATE_SRC_PATH}/utKey256.cpp.md" + OUTPUT utKey256.cpp) +add_custom_command( + COMMAND rm -f utMain.cpp + COMMAND ${EXTRACT_CPP_CMD} "${LITERATE_SRC_PATH}/utMain.cpp.md" utMain.cpp + DEPENDS "${LITERATE_SRC_PATH}/utMain.cpp.md" + OUTPUT utMain.cpp) +add_custom_command( + COMMAND rm -f utMd5.cpp + COMMAND ${EXTRACT_CPP_CMD} "${LITERATE_SRC_PATH}/utMd5.cpp.md" utMd5.cpp + DEPENDS "${LITERATE_SRC_PATH}/utMd5.cpp.md" + OUTPUT utMd5.cpp) +add_custom_command( + COMMAND rm -f utRandList.cpp + COMMAND ${EXTRACT_CPP_CMD} "${LITERATE_SRC_PATH}/utRandList.cpp.md" utRandList.cpp + DEPENDS "${LITERATE_SRC_PATH}/utRandList.cpp.md" + OUTPUT utRandList.cpp) +add_custom_command( + COMMAND rm -f utRandom.cpp + COMMAND ${EXTRACT_CPP_CMD} "${LITERATE_SRC_PATH}/utRandom.cpp.md" utRandom.cpp + DEPENDS "${LITERATE_SRC_PATH}/utRandom.cpp.md" + OUTPUT utRandom.cpp) +add_custom_command( + COMMAND rm -f utSha256.cpp + COMMAND ${EXTRACT_CPP_CMD} "${LITERATE_SRC_PATH}/utSha256.cpp.md" utSha256.cpp + DEPENDS "${LITERATE_SRC_PATH}/utSha256.cpp.md" + OUTPUT utSha256.cpp) diff --git a/ext/gitalk b/ext/gitalk index 9d2e664..9bd114e 160000 --- a/ext/gitalk +++ b/ext/gitalk @@ -1 +1 @@ -Subproject commit 9d2e664bd051182fbe8bf1202c54568b7f92921c +Subproject commit 9bd114e136296c6757028b65accb81fd72a73b80 diff --git a/src/cpp/key128.hpp.md b/src/cpp/key128.hpp.md index b58adb2..8c33fda 100644 --- a/src/cpp/key128.hpp.md +++ b/src/cpp/key128.hpp.md @@ -52,6 +52,8 @@ module Key128 = >Key128 & [operator=](key128_ctor.cpp.md)(Key128 const &); +>static Key128 [key128FromHex](key128_ctor.cpp.md)(std::string const &); + >virtual unsigned char const* [bytes](key128_functions.cpp.md)() const override; >virtual int [length](key128_functions.cpp.md)() const override { return 128; }; diff --git a/src/cpp/key128_ctor.cpp.md b/src/cpp/key128_ctor.cpp.md index 61cb340..e77f3fc 100644 --- a/src/cpp/key128_ctor.cpp.md +++ b/src/cpp/key128_ctor.cpp.md @@ -31,4 +31,11 @@ Key128 & Key128::operator=(Key128 const & o) return *this; } +Key128 Key128::key128FromHex(std::string const &s) +{ + Key128 key{true}; + key.fromHex(s); + return key; +} + ``` \ No newline at end of file diff --git a/src/cpp/key256.hpp.md b/src/cpp/key256.hpp.md index 69675c0..7a4c249 100644 --- a/src/cpp/key256.hpp.md +++ b/src/cpp/key256.hpp.md @@ -52,6 +52,8 @@ module Key256 = >Key256 & [operator=](key256_ctor.cpp.md)(Key256 const &); +>static Key256 [key256FromHex](key256_functions.cpp.md)(std::string const &); + >virtual unsigned char const* [bytes](key256_functions.cpp.md)() const override; >virtual int [length](key256_functions.cpp.md)() const override { return 256; }; diff --git a/src/cpp/key256_ctor.cpp.md b/src/cpp/key256_ctor.cpp.md index 9ffce00..9c47e93 100644 --- a/src/cpp/key256_ctor.cpp.md +++ b/src/cpp/key256_ctor.cpp.md @@ -31,4 +31,11 @@ Key256 & Key256::operator=(Key256 const & o) return *this; } +Key256 Key256::key256FromHex(std::string const &s) +{ + Key256 key{true}; + key.fromHex(s); + return key; +} + ``` \ No newline at end of file diff --git a/test/cpp/elykseer-crypto-ut.md b/test/cpp/elykseer-crypto-ut.md deleted file mode 100644 index f3b2248..0000000 --- a/test/cpp/elykseer-crypto-ut.md +++ /dev/null @@ -1,29 +0,0 @@ -# Unit tests for eLyKseeR-crypto - -all entries here are parsed and used in source code generation -and subsequentially be compiled and linked against the -elykseer-crypto library. - - -## unit tests - -[utMd5](utMd5.cpp.md) for class [Md5](../md5.hpp.md) - -[utSha256](utSha256.cpp.md) for class [Sha256](../sha256.hpp.md) - -[utRandom](utRandom.cpp.md) for class [Random](../random.hpp.md) - -[utKey128](utKey128.cpp.md) for class [Key128](../key128.hpp.md) - -[utKey256](utKey256.cpp.md) for class [Key256](../key256.hpp.md) - -[utRandList](utRandList.cpp.md) for class [RandList](../randlist.hpp.md) - -[utAes](utAes.cpp.md) for class [Aes](../aes.hpp.md) - -[utGpg](utGpg.cpp.md) for class [Gpg](../gpg.hpp.md) - - -## main entry point - -[utMain](utMain.cpp.md) provides main entry point. From 12d191a7150aa216bfbb50c1378189fedf33f252 Mon Sep 17 00:00:00 2001 From: Alexander Diemand Date: Sun, 22 Oct 2023 00:02:38 +0200 Subject: [PATCH 2/4] adapt CI Signed-off-by: Alexander Diemand --- .github/workflows/CI.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 2f59e43..61abe66 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -37,11 +37,6 @@ jobs: working-directory: ${{github.workspace}}/ext run: make - - name: Prepare code - shell: bash - working-directory: ${{github.workspace}}/build - run: PATH=${{github.workspace}}/ext/Linux_*/bin:$PATH ./mk_cpp.sh - - name: Configure CMake # Use a bash shell so we can use the same syntax for environment variable # access regardless of the host operating system @@ -65,3 +60,8 @@ jobs: # See https://cmake.org/cmake/help/latest/manual/ctest.1.html for more detail #run: ctest -C $BUILD_TYPE run: ./ut.sh + + - name: Packaging + shell: bash + working-directory: ${{github.workspace}}/build + run: cpack From 69250b093359cdda6cda1a6a3b290a84fc7d33af Mon Sep 17 00:00:00 2001 From: Alexander Diemand Date: Thu, 26 Oct 2023 18:59:22 +0200 Subject: [PATCH 3/4] +ctest +cpack +update deps --- build/CMakeLists.txt | 2 ++ build/src/CMakeLists.txt | 1 - build/test/CMakeLists.txt | 9 +++++---- ext/cryptopp | 2 +- ext/gpgme | 2 +- ext/libassuan | 2 +- 6 files changed, 10 insertions(+), 8 deletions(-) diff --git a/build/CMakeLists.txt b/build/CMakeLists.txt index 37fe27e..659524b 100644 --- a/build/CMakeLists.txt +++ b/build/CMakeLists.txt @@ -168,5 +168,7 @@ IF(RUN_ADDRESS_SANITIZER) ENDIF(${CMAKE_BUILD_TYPE} MATCHES "Debug") ENDIF(RUN_ADDRESS_SANITIZER) +enable_testing() + add_subdirectory( src ) add_subdirectory( test ) diff --git a/build/src/CMakeLists.txt b/build/src/CMakeLists.txt index f372203..26adf36 100644 --- a/build/src/CMakeLists.txt +++ b/build/src/CMakeLists.txt @@ -254,7 +254,6 @@ set(CPACK_PACKAGE_VERSION_MINOR ${${PROJECT_NAME}_VERSION_MINOR}) set(CPACK_PACKAGE_VERSION_PATCH ${${PROJECT_NAME}_VERSION_PATCH}) install(FILES ${LIBRARY_NAME} DESTINATION lib) install(FILES ${GENERATED_HDRS} DESTINATION include/lxr) -include(CPack) set(CPACK_BINARY_STGZ "OFF") set(CPACK_BINARY_TGZ "ON") diff --git a/build/test/CMakeLists.txt b/build/test/CMakeLists.txt index ba8836d..7624da8 100644 --- a/build/test/CMakeLists.txt +++ b/build/test/CMakeLists.txt @@ -33,12 +33,13 @@ if (CMAKE_BUILD_TYPE STREQUAL "Debug") add_executable ( ut${PROJECT_NAME} ${GENERATED_SRCS} ) + add_test(NAME ut${PROJECT_NAME} COMMAND ut${PROJECT_NAME} --show_progress) - add_library(libelykseer-crypto_s STATIC IMPORTED) - set_target_properties(libelykseer-crypto_s PROPERTIES IMPORTED_LOCATION "${CMAKE_HOME_DIRECTORY}/src/libelykseer-crypto_d.a") + add_library(lib${PROJECT_NAME}_s STATIC IMPORTED) + set_target_properties(lib${PROJECT_NAME}_s PROPERTIES IMPORTED_LOCATION "${CMAKE_HOME_DIRECTORY}/src/libelykseer-crypto_d.a") target_link_libraries ( ut${PROJECT_NAME} - elykseer-crypto_${CMAKE_BUILD_TYPE} + ${PROJECT_NAME}_${CMAKE_BUILD_TYPE} ${libs} ${Boost_LIBRARIES} ${CRYPTO_LIBS} @@ -51,7 +52,7 @@ if (CMAKE_BUILD_TYPE STREQUAL "DebugProfile") ) set_target_properties(utp${PROJECT_NAME} PROPERTIES LINK_FLAGS "-fprofile-arcs -ftest-coverage ") target_link_libraries ( utp${PROJECT_NAME} - elykseer-crypto_p${CMAKE_BUILD_TYPE} + ${PROJECT_NAME}_p${CMAKE_BUILD_TYPE} #gcov ${libs} ${Boost_LIBRARIES} diff --git a/ext/cryptopp b/ext/cryptopp index 511806c..843d74c 160000 --- a/ext/cryptopp +++ b/ext/cryptopp @@ -1 +1 @@ -Subproject commit 511806c0eba8ba5b5cedd4b4a814e96df92864a6 +Subproject commit 843d74c7c97f9e19a615b8ff3c0ca06599ca501b diff --git a/ext/gpgme b/ext/gpgme index 72bb46b..451ed47 160000 --- a/ext/gpgme +++ b/ext/gpgme @@ -1 +1 @@ -Subproject commit 72bb46b34f5191f672a5356e2f152e6ad9440554 +Subproject commit 451ed47434c5ffd2916adae25e5a128606b5ef98 diff --git a/ext/libassuan b/ext/libassuan index f8cfb56..6b50ee6 160000 --- a/ext/libassuan +++ b/ext/libassuan @@ -1 +1 @@ -Subproject commit f8cfb565ee461946901ae3bc573abc0023d821b5 +Subproject commit 6b50ee6bcdd6aa81bd7cc3fb2379864c3ed479b8 From 2ea8b32fd6271e4fa95d200e69cf87bfc68dedea Mon Sep 17 00:00:00 2001 From: Alexander Diemand Date: Thu, 26 Oct 2023 19:05:29 +0200 Subject: [PATCH 4/4] cleanups; preparing version 1.0.9 --- .gitignore | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/.gitignore b/.gitignore index 1d7e380..4bfa9d1 100644 --- a/.gitignore +++ b/.gitignore @@ -55,6 +55,15 @@ GTAGS .vscode .vs +*.swp + +CPackConfig.cmake +CPackSourceConfig.cmake +CTestTestfile.cmake +Testing/ +_CPack_Packages/ +install_manifest.txt + ext/Darwin_arm64 ext/Darwin_amd64 ext/Linux_aarch64