diff --git a/CMakeLists.txt b/CMakeLists.txt index 66428a43..8a06e636 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -233,44 +233,7 @@ add_library (blake2 blake2/blake2.h ${BLAKE2_IMPLEMENTATION}) -if (${CMAKE_SYSTEM_NAME} MATCHES "Darwin") - set (PLATFORM_SECURE_SOURCE rai/plat/osx/working.mm) -elseif (${CMAKE_SYSTEM_NAME} MATCHES "Windows") - set (PLATFORM_SECURE_SOURCE rai/plat/windows/working.cpp) -elseif (${CMAKE_SYSTEM_NAME} MATCHES "Linux") - set (PLATFORM_SECURE_SOURCE rai/plat/posix/working.cpp) -elseif (${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD") - set (PLATFORM_SECURE_SOURCE rai/plat/posix/working.cpp) -else () - error ("Unknown platform: ${CMAKE_SYSTEM_NAME}") -endif () - -# Embed bootstrap representative weights in executable -file (READ rep_weights.bin filedata HEX) -string (REGEX REPLACE "(..)" "0x\\1," filedata ${filedata}) -file (WRITE ${CMAKE_BINARY_DIR}/bootstrap_weights.cpp "#include \n" - "namespace rai {\n" - " unsigned char rai_bootstrap_weights[] = {${filedata} 0x00};\n" - " size_t rai_bootstrap_weights_size = sizeof(rai_bootstrap_weights) - 1;\n" - "}\n") - -add_library (secure - ${PLATFORM_SECURE_SOURCE} - ${CMAKE_BINARY_DIR}/bootstrap_weights.cpp - rai/config.hpp - rai/common.cpp - rai/common.hpp - rai/blockstore.cpp - rai/blockstore.hpp - rai/ledger.cpp - rai/ledger.hpp - rai/node/utility.cpp - rai/node/utility.hpp - rai/versioning.hpp - rai/versioning.cpp) - -target_link_libraries(secure Boost::boost) - +add_subdirectory(rai/secure) add_subdirectory(rai/lib) add_subdirectory(rai/node) @@ -414,9 +377,9 @@ add_subdirectory(rai/rai_node) set_target_properties (argon2 PROPERTIES COMPILE_FLAGS "${PLATFORM_C_FLAGS} ${PLATFORM_COMPILE_FLAGS}") set_target_properties (blake2 PROPERTIES COMPILE_FLAGS "${PLATFORM_C_FLAGS} ${PLATFORM_COMPILE_FLAGS} -D__SSE2__") set_target_properties (ed25519 PROPERTIES COMPILE_FLAGS "${PLATFORM_C_FLAGS} ${PLATFORM_COMPILE_FLAGS} -DED25519_CUSTOMHASH -DED25519_CUSTOMRNG") -set_target_properties (secure node rai_lib rai_lib_static PROPERTIES COMPILE_FLAGS "${PLATFORM_CXX_FLAGS} ${PLATFORM_COMPILE_FLAGS} -DQT_NO_KEYWORDS -DACTIVE_NETWORK=${ACTIVE_NETWORK} -DRAIBLOCKS_VERSION_MAJOR=${CPACK_PACKAGE_VERSION_MAJOR} -DRAIBLOCKS_VERSION_MINOR=${CPACK_PACKAGE_VERSION_MINOR} -DBOOST_ASIO_HAS_STD_ARRAY=1") +set_target_properties (node rai_lib rai_lib_static PROPERTIES COMPILE_FLAGS "${PLATFORM_CXX_FLAGS} ${PLATFORM_COMPILE_FLAGS} -DQT_NO_KEYWORDS -DACTIVE_NETWORK=${ACTIVE_NETWORK} -DRAIBLOCKS_VERSION_MAJOR=${CPACK_PACKAGE_VERSION_MAJOR} -DRAIBLOCKS_VERSION_MINOR=${CPACK_PACKAGE_VERSION_MINOR} -DBOOST_ASIO_HAS_STD_ARRAY=1") # TODO: Do globally -set_target_properties (secure node PROPERTIES LINK_FLAGS "${PLATFORM_LINK_FLAGS}") +set_target_properties (node PROPERTIES LINK_FLAGS "${PLATFORM_LINK_FLAGS}") if (WIN32) set (PLATFORM_LIBS Ws2_32 mswsock iphlpapi ntdll) diff --git a/rai/lib/CMakeLists.txt b/rai/lib/CMakeLists.txt index eb2db575..5e08c514 100644 --- a/rai/lib/CMakeLists.txt +++ b/rai/lib/CMakeLists.txt @@ -31,6 +31,7 @@ add_library (rai_lib SHARED ${sources}) add_library (rai_lib_static STATIC ${sources}) target_link_libraries (rai_lib + secure ed25519 xxhash blake2 @@ -38,6 +39,7 @@ target_link_libraries (rai_lib Boost::boost) target_link_libraries (rai_lib_static + secure ed25519 xxhash blake2 diff --git a/rai/lib/work.hpp b/rai/lib/work.hpp index 2102bdf7..a74683b2 100644 --- a/rai/lib/work.hpp +++ b/rai/lib/work.hpp @@ -1,7 +1,7 @@ #pragma once #include -#include +#include #include #include diff --git a/rai/node/bootstrap.hpp b/rai/node/bootstrap.hpp index b3e3fbea..43b0d2c1 100644 --- a/rai/node/bootstrap.hpp +++ b/rai/node/bootstrap.hpp @@ -1,7 +1,7 @@ #pragma once -#include -#include +#include +#include #include #include diff --git a/rai/node/common.hpp b/rai/node/common.hpp index 6239b6aa..1feae4f8 100644 --- a/rai/node/common.hpp +++ b/rai/node/common.hpp @@ -1,6 +1,6 @@ #pragma once -#include +#include #include #include diff --git a/rai/node/node.hpp b/rai/node/node.hpp index 10737705..5a973ae1 100644 --- a/rai/node/node.hpp +++ b/rai/node/node.hpp @@ -1,6 +1,6 @@ #pragma once -#include +#include #include #include #include diff --git a/rai/node/rpc.hpp b/rai/node/rpc.hpp index b77769dc..d4bee17c 100644 --- a/rai/node/rpc.hpp +++ b/rai/node/rpc.hpp @@ -5,7 +5,7 @@ #include #include #include -#include +#include #include namespace rai diff --git a/rai/node/wallet.hpp b/rai/node/wallet.hpp index 03bafe15..3029b75c 100644 --- a/rai/node/wallet.hpp +++ b/rai/node/wallet.hpp @@ -1,7 +1,7 @@ #pragma once -#include -#include +#include +#include #include #include diff --git a/rai/node/working.hpp b/rai/node/working.hpp index 6caac5c7..e756ef04 100644 --- a/rai/node/working.hpp +++ b/rai/node/working.hpp @@ -1,6 +1,6 @@ #pragma once -#include +#include namespace rai { diff --git a/rai/secure/CMakeLists.txt b/rai/secure/CMakeLists.txt new file mode 100644 index 00000000..7c61aa9c --- /dev/null +++ b/rai/secure/CMakeLists.txt @@ -0,0 +1,44 @@ +if (${CMAKE_SYSTEM_NAME} MATCHES "Darwin") + set (PLATFORM_SECURE_SOURCE plat/osx/working.mm) +elseif (${CMAKE_SYSTEM_NAME} MATCHES "Windows") + set (PLATFORM_SECURE_SOURCE plat/windows/working.cpp) +elseif (${CMAKE_SYSTEM_NAME} MATCHES "Linux") + set (PLATFORM_SECURE_SOURCE plat/posix/working.cpp) +elseif (${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD") + set (PLATFORM_SECURE_SOURCE plat/posix/working.cpp) +else () + error ("Unknown platform: ${CMAKE_SYSTEM_NAME}") +endif () + +# Embed bootstrap representative weights in executable +file (READ ${CMAKE_SOURCE_DIR}/rep_weights.bin filedata HEX) +string (REGEX REPLACE "(..)" "0x\\1," filedata ${filedata}) +file (WRITE ${CMAKE_BINARY_DIR}/bootstrap_weights.cpp "#include \n" + "namespace rai {\n" + " unsigned char rai_bootstrap_weights[] = {${filedata} 0x00};\n" + " size_t rai_bootstrap_weights_size = sizeof(rai_bootstrap_weights) - 1;\n" + "}\n") + +add_library (secure + ${PLATFORM_SECURE_SOURCE} + ${CMAKE_BINARY_DIR}/bootstrap_weights.cpp + config.hpp + common.cpp + common.hpp + blockstore.cpp + blockstore.hpp + ledger.cpp + ledger.hpp + utility.cpp + utility.hpp + versioning.hpp + versioning.cpp) + +target_link_libraries(secure Boost::boost) + +# TODO: Do globally +set_target_properties (secure + PROPERTIES + COMPILE_FLAGS "${PLATFORM_CXX_FLAGS} ${PLATFORM_COMPILE_FLAGS} -DQT_NO_KEYWORDS -DACTIVE_NETWORK=${ACTIVE_NETWORK} -DRAIBLOCKS_VERSION_MAJOR=${CPACK_PACKAGE_VERSION_MAJOR} -DRAIBLOCKS_VERSION_MINOR=${CPACK_PACKAGE_VERSION_MINOR} -DBOOST_ASIO_HAS_STD_ARRAY=1") +# TODO: Do globally +set_target_properties (secure PROPERTIES LINK_FLAGS "${PLATFORM_LINK_FLAGS}") diff --git a/rai/blockstore.cpp b/rai/secure/blockstore.cpp similarity index 99% rename from rai/blockstore.cpp rename to rai/secure/blockstore.cpp index 320a559e..6aacc694 100644 --- a/rai/blockstore.cpp +++ b/rai/secure/blockstore.cpp @@ -1,6 +1,6 @@ #include -#include -#include +#include +#include namespace { diff --git a/rai/blockstore.hpp b/rai/secure/blockstore.hpp similarity index 99% rename from rai/blockstore.hpp rename to rai/secure/blockstore.hpp index ab1025eb..eca9ed44 100644 --- a/rai/blockstore.hpp +++ b/rai/secure/blockstore.hpp @@ -1,6 +1,6 @@ #pragma once -#include +#include namespace rai { diff --git a/rai/common.cpp b/rai/secure/common.cpp similarity index 99% rename from rai/common.cpp rename to rai/secure/common.cpp index 891634d4..9c8f9d46 100644 --- a/rai/common.cpp +++ b/rai/secure/common.cpp @@ -1,9 +1,9 @@ -#include +#include -#include +#include #include #include -#include +#include #include diff --git a/rai/common.hpp b/rai/secure/common.hpp similarity index 99% rename from rai/common.hpp rename to rai/secure/common.hpp index 95f80311..081a3bbb 100644 --- a/rai/common.hpp +++ b/rai/secure/common.hpp @@ -1,7 +1,7 @@ #pragma once #include -#include +#include #include diff --git a/rai/config.hpp b/rai/secure/config.hpp similarity index 100% rename from rai/config.hpp rename to rai/secure/config.hpp diff --git a/rai/icon.hpp b/rai/secure/icon.hpp similarity index 100% rename from rai/icon.hpp rename to rai/secure/icon.hpp diff --git a/rai/ledger.cpp b/rai/secure/ledger.cpp similarity index 99% rename from rai/ledger.cpp rename to rai/secure/ledger.cpp index c657923d..0b4b81a7 100644 --- a/rai/ledger.cpp +++ b/rai/secure/ledger.cpp @@ -1,5 +1,5 @@ -#include -#include +#include +#include #include #include diff --git a/rai/ledger.hpp b/rai/secure/ledger.hpp similarity index 98% rename from rai/ledger.hpp rename to rai/secure/ledger.hpp index c549d100..fe691f42 100644 --- a/rai/ledger.hpp +++ b/rai/secure/ledger.hpp @@ -1,6 +1,6 @@ #pragma once -#include +#include namespace rai { diff --git a/rai/plat/osx/working.mm b/rai/secure/plat/osx/working.mm similarity index 100% rename from rai/plat/osx/working.mm rename to rai/secure/plat/osx/working.mm diff --git a/rai/plat/posix/working.cpp b/rai/secure/plat/posix/working.cpp similarity index 100% rename from rai/plat/posix/working.cpp rename to rai/secure/plat/posix/working.cpp diff --git a/rai/plat/windows/working.cpp b/rai/secure/plat/windows/working.cpp similarity index 100% rename from rai/plat/windows/working.cpp rename to rai/secure/plat/windows/working.cpp diff --git a/rai/node/utility.cpp b/rai/secure/utility.cpp similarity index 99% rename from rai/node/utility.cpp rename to rai/secure/utility.cpp index cedd8785..7084ef99 100644 --- a/rai/node/utility.cpp +++ b/rai/secure/utility.cpp @@ -1,5 +1,6 @@ +#include + #include -#include #include #include diff --git a/rai/node/utility.hpp b/rai/secure/utility.hpp similarity index 99% rename from rai/node/utility.hpp rename to rai/secure/utility.hpp index a17aa632..76373ab4 100644 --- a/rai/node/utility.hpp +++ b/rai/secure/utility.hpp @@ -14,7 +14,7 @@ #include -#include +#include #include #include diff --git a/rai/versioning.cpp b/rai/secure/versioning.cpp similarity index 99% rename from rai/versioning.cpp rename to rai/secure/versioning.cpp index 2917ec2d..e7c4823f 100644 --- a/rai/versioning.cpp +++ b/rai/secure/versioning.cpp @@ -1,4 +1,4 @@ -#include +#include rai::account_info_v1::account_info_v1 () : head (0), diff --git a/rai/versioning.hpp b/rai/secure/versioning.hpp similarity index 97% rename from rai/versioning.hpp rename to rai/secure/versioning.hpp index 07b246a9..ab909307 100644 --- a/rai/versioning.hpp +++ b/rai/secure/versioning.hpp @@ -1,7 +1,7 @@ #pragma once #include -#include +#include namespace rai {