Skip to content

Commit

Permalink
Merge pull request #55 from GeniusVentures/crdt
Browse files Browse the repository at this point in the history
Changes in formatting and optimization of some code.
  • Loading branch information
henriqueaklein committed Aug 30, 2024
2 parents e7c354e + 8e888ee commit 836f149
Show file tree
Hide file tree
Showing 331 changed files with 1,393 additions and 3,774 deletions.
7 changes: 6 additions & 1 deletion .clang-format
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
---
BasedOnStyle: Microsoft
AccessModifierOffset: -4
AllowAllArgumentsOnNextLine: false
AllowAllParametersOfDeclarationOnNextLine: false
AlwaysBreakTemplateDeclarations: true
AlignConsecutiveAssignments:
Enabled: true
Expand All @@ -12,19 +14,22 @@ AlignConsecutiveDeclarations:
AlignConsecutiveShortCaseStatements:
Enabled: true
BraceWrapping:
AfterCaseLabel: true
BeforeLambdaBody: true
BinPackArguments: false
BinPackParameters: false
BreakConstructorInitializers: AfterColon
BreakStringLiterals: false
ColumnLimit: 120
FixNamespaceComments: false
IndentCaseBlocks: true
IndentCaseBlocks: false
IndentCaseLabels: true
InsertBraces: true
InsertNewlineAtEOF: true
InsertTrailingCommas: Wrapped
KeepEmptyLinesAtTheStartOfBlocks: false
NamespaceIndentation: All
PackConstructorInitializers: NextLine
ReflowComments: false
RemoveParentheses: ReturnStatement
RemoveSemicolon: true
Expand Down
5 changes: 4 additions & 1 deletion .clang-tidy
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ Checks: >
-bugprone-reserved-identifier,
cert-*,
-cert-dcl37-c,
-cert-dcl51-cpp,
-cert-err58-cpp,
Expand Down Expand Up @@ -37,6 +38,7 @@ Checks: >
-misc-non-private-member-variables-in-classes,
modernize-*,
-modernize-use-default-member-init,
-modernize-use-trailing-return-type,
performance-*,
Expand All @@ -46,7 +48,8 @@ Checks: >
readability-*,
-readability-identifier-length,
-readability-magic-numbers,
-readability-named-parameter
-readability-named-parameter,
-readability-qualified-auto
FormatStyle: file

Expand Down
13 changes: 9 additions & 4 deletions .github/workflows/cmake.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ jobs:

- name: Thirdparty Compile
working-directory: ${{github.workspace}}/thirdparty/build/Windows/Release
run: cmake --build . --config Release
run: cmake --build . --config Release -j

- name: Create Build Directory
run: cmake -E make_directory ${{github.workspace}}/SuperGenius/build/Windows/Release
Expand All @@ -66,7 +66,7 @@ jobs:

- name: Compile
working-directory: ${{github.workspace}}/SuperGenius/build/Windows/Release
run: cmake --build . --config Release
run: cmake --build . --config Release -j

- name: Create install directory
working-directory: ${{github.workspace}}/SuperGenius/build/Windows/Release
Expand Down Expand Up @@ -528,6 +528,11 @@ jobs:
path: 'SuperGenius'
submodules: "recursive"

- name: Install Ninja
run: |
brew install ccache ninja
echo "CMAKE_GENERATOR=Ninja" >> $GITHUB_ENV
- name: Install bindgen
run: cargo install cbindgen

Expand Down Expand Up @@ -557,7 +562,7 @@ jobs:

- name: Thirdparty Compile
working-directory: ${{github.workspace}}/thirdparty/build/iOS/Release
run: make -j8
run: cmake --build . -j --config Release

- name: Create Build Directory
run: cmake -E make_directory ${{github.workspace}}/SuperGenius/build/iOS/Release
Expand All @@ -568,7 +573,7 @@ jobs:

- name: Compile
working-directory: ${{github.workspace}}/SuperGenius/build/iOS/Release
run: make -j8
run: cmake --build . -j --config Release

- name: Install
working-directory: ${{github.workspace}}/SuperGenius/build/iOS/Release
Expand Down
30 changes: 18 additions & 12 deletions build/CommonBuildParameters.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,16 @@ set(BOOST_VERSION "${BOOST_MAJOR_VERSION}.${BOOST_MINOR_VERSION}.${BOOST_PATCH_V
set(BOOST_VERSION_3U "${BOOST_MAJOR_VERSION}_${BOOST_MINOR_VERSION}_${BOOST_PATCH_VERSION}")
set(BOOST_VERSION_2U "${BOOST_MAJOR_VERSION}_${BOOST_MINOR_VERSION}")

# GTest
set(GTest_DIR "${_THIRDPARTY_BUILD_DIR}/GTest/lib/cmake/GTest")
set(GTest_INCLUDE_DIR "${_THIRDPARTY_BUILD_DIR}/GTest/include")
find_package(GTest CONFIG REQUIRED)
include_directories(${GTest_INCLUDE_DIR})
# --------------------------------------------------------
# Set config of GTest
set(BUILD_TESTING "ON" CACHE BOOL "Build tests")

if(BUILD_TESTING)
set(GTest_DIR "${_THIRDPARTY_BUILD_DIR}/GTest/lib/cmake/GTest")
set(GTest_INCLUDE_DIR "${_THIRDPARTY_BUILD_DIR}/GTest/include")
find_package(GTest CONFIG REQUIRED)
include_directories(${GTest_INCLUDE_DIR})
endif()

# absl
if(NOT DEFINED absl_DIR)
Expand Down Expand Up @@ -271,12 +276,13 @@ set(AsyncIOManager_DIR "${_THIRDPARTY_BUILD_DIR}/AsyncIOManager/lib/cmake/AsyncI
find_package(AsyncIOManager CONFIG REQUIRED)
include_directories(${AsyncIOManager_INCLUDE_DIR})

# crypto3
# set(crypto3_INCLUDE_DIR "${_THIRDPARTY_BUILD_DIR}/crypto3/include")
# set(crypto3_LIBRARY_DIR "${_THIRDPARTY_BUILD_DIR}/crypto3/lib")
# set(crypto3_DIR "${_THIRDPARTY_BUILD_DIR}/crypto3/lib/cmake/crypto3")
# find_package(crypto3 CONFIG REQUIRED)
# include_directories(${crypto3_INCLUDE_DIR})
# --------------------------------------------------------
# Set config of crypto3
#set(crypto3_INCLUDE_DIR "${_THIRDPARTY_BUILD_DIR}/crypto3/include")
#set(crypto3_LIBRARY_DIR "${_THIRDPARTY_BUILD_DIR}/crypto3/lib")
#set(crypto3_DIR "${_THIRDPARTY_BUILD_DIR}/crypto3/lib/cmake/crypto3")
#find_package(crypto3 CONFIG REQUIRED)
#include_directories(${crypto3_INCLUDE_DIR})
include_directories(
"${THIRDPARTY_DIR}/zkLLVM/libs/crypto3/libs/algebra/include"
"${THIRDPARTY_DIR}/zkLLVM/libs/crypto3/libs/block/include"
Expand Down Expand Up @@ -343,7 +349,7 @@ add_subdirectory(${PROJECT_ROOT}/src ${CMAKE_BINARY_DIR}/src)
add_subdirectory(${PROJECT_ROOT}/GeniusKDF ${CMAKE_BINARY_DIR}/GeniusKDF)

# add_subdirectory(${PROJECT_ROOT}/app ${CMAKE_BINARY_DIR}/app)
if(TESTING)
if(BUILD_TESTING)
enable_testing()
add_subdirectory(${PROJECT_ROOT}/test ${CMAKE_BINARY_DIR}/test)
endif()
Expand Down
41 changes: 15 additions & 26 deletions build/OSX/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,35 +1,24 @@
cmake_minimum_required(VERSION 3.12)

# if on OSX Darwin system, build the OSX executables
if(NOT ${CMAKE_HOST_SYSTEM_NAME} MATCHES "Darwin")
message(FATAL_ERROR "${CMAKE_HOST_SYSTEM_NAME} host system name does not match OSX Darwin - Please select the correct folder for configuring project")
cmake_minimum_required(VERSION 3.22)

if(NOT DEFINED CMAKE_TOOLCHAIN_FILE)
# set(_PLATFORM "MAC_UNIVERSAL" CACHE STRING "Setting the build for both x86_64 and arm64")
set(_PLATFORM "MAC" CACHE STRING "Setting the default build for x86_64")

set(NAMED_LANGUAGE_SUPPORT OFF CACHE BOOL "Toolchain named language support parameter")
set(ENABLE_BITCODE OFF CACHE BOOL "Toolchain bitcode enable parameter")
set(ENABLE_ARC OFF CACHE BOOL "Toolchain enable arc parameter")
set(ENABLE_VISIBILITY ON CACHE BOOL "Toolchain visibility parameter")
set(ENABLE_STRICT_TRY_COMPILE OFF CACHE BOOL "Toolchain try_compile enable parameter")
set(PLATFORM ${_PLATFORM} CACHE STRING "Toolchain platform parameter")
set(DEPLOYMENT_TARGET "12.1" CACHE STRING "Minimum OSX version")
set(CMAKE_TOOLCHAIN_FILE "${CMAKE_CURRENT_SOURCE_DIR}/../apple.toolchain.cmake" CACHE STRING "Toolchain file")
endif()

set(CMAKE_OSX_DEPLOYMENT_TARGET "12.1" CACHE STRING "Minimum OS X deployment version" FORCE)

# Project
project(SuperGenius C CXX)
project(SuperGenius LANGUAGES C CXX)

# include common compiler options
include(../CommonCompilerOptions.cmake)

# Set OSX specific runtime options
set(CMAKE_OSX_ARCHITECTURES "x86_64")
set(CMAKE_MACOSX_RPATH 1)
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM "BOTH")
set(CMAKE_XCODE_ATTRIBUTE_ONLY_ACTIVE_ARCH TRUE)
set(CMAKE_IOS_INSTALL_COMBINED TRUE)

# Assuming that xcode 12.0 is installed you most probably have ios sdk 14.0 or later installed (tested on Big Sur)
# if you don't set a deployment target it will be set the way you only get 64-bit builds
if(NOT DEFINED DEPLOYMENT_TARGET AND XCODE_VERSION_INT VERSION_GREATER 12.0)
# Temporarily fix the arm64 issues in CMake install-combined by excluding arm64 for simulator builds (needed for Apple Silicon...)
set(CMAKE_XCODE_ATTRIBUTE_EXCLUDED_ARCHS[sdk=iphonesimulator*] "arm64")
endif()

# Set toolchain file
set(CMAKE_TOOLCHAIN_FILE "${PROJECT_ROOT}/cmake/toolchain/cxx17.cmake")

# Set OS threading settings
set(CMAKE_THREAD_LIBS_INIT "-lpthread")
set(CMAKE_HAVE_THREADS_LIBRARY ON)
Expand Down
5 changes: 1 addition & 4 deletions build/iOS/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.15)
cmake_minimum_required(VERSION 3.22)

if(POLICY CMP0025)
# NEW: report OS X version of Clang as "AppleClang"
Expand Down Expand Up @@ -49,9 +49,6 @@ set(THREADS_PREFER_PTHREAD_FLAG ON)
set(FORCE_MULTILE ON)
set(MULTIPLE_OPTION "-Xlink=-force:multiple")

# Set extra compiler flags
set(EXTRA_CXX_FLAGS -std=c++17)

# Set custom subfolder for ABI
set(ABI_SUBFOLDER_NAME "/aarch64")

Expand Down
2 changes: 1 addition & 1 deletion example/AsyncFile/MNNExample.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
//#include "WSLoader.hpp"
#include "URLStringUtil.h"
#include <libp2p/injector/host_injector.hpp>
#include "libp2p/injector/kademlia_injector.hpp"
#include <libp2p/injector/kademlia_injector.hpp>

/**
* This program is example to loading MNN model file
Expand Down
4 changes: 2 additions & 2 deletions example/crdt_globaldb/globaldb_app.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
#include <boost/filesystem.hpp>
#include <boost/random.hpp>

#include <crdt/globaldb/globaldb.hpp>
#include <crdt/globaldb/keypair_file_storage.hpp>
#include "crdt/globaldb/globaldb.hpp"
#include "crdt/globaldb/keypair_file_storage.hpp"

#include <libp2p/log/configurator.hpp>
#include <libp2p/log/logger.hpp>
Expand Down
2 changes: 1 addition & 1 deletion example/ipfs_client/ipfs_dht.hpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#ifndef SUPERGENIUS_IPFS_DHT_HPP
#define SUPERGENIUS_IPFS_DHT_HPP

#include <base/logger.hpp>
#include "base/logger.hpp"

#include <libp2p/protocol/kademlia/kademlia.hpp>
#include <libp2p/multi/content_identifier.hpp>
Expand Down
3 changes: 1 addition & 2 deletions example/ipfs_client2/testipfs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,7 @@
#include <libp2p/log/configurator.hpp>
#include <libp2p/log/sublogger.hpp>
#include <libp2p/multi/content_identifier_codec.hpp>
#include <base/logger.hpp>

#include "base/logger.hpp"

#include <ipfs_lite/ipld/impl/ipld_node_impl.hpp>
#include <libp2p/protocol/kademlia/kademlia.hpp>
Expand Down
4 changes: 2 additions & 2 deletions example/ipfs_pubsub/ipfs_pubsub.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
#include <libp2p/log/logger.hpp>
#include <libp2p/injector/host_injector.hpp>
#include <libp2p/multi/multibase_codec/multibase_codec_impl.hpp>
#include <crdt/globaldb/globaldb.hpp>
#include <crdt/globaldb/keypair_file_storage.hpp>
#include "crdt/globaldb/globaldb.hpp"
#include "crdt/globaldb/keypair_file_storage.hpp"
#include <libp2p/host/basic_host.hpp>

using GossipPubSub = sgns::ipfs_pubsub::GossipPubSub;
Expand Down
4 changes: 2 additions & 2 deletions example/processing_dapp/processing_dapp.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#include "processing/impl/processing_task_queue_impl.hpp"

#include <crdt/globaldb/globaldb.hpp>
#include <crdt/globaldb/keypair_file_storage.hpp>
#include "crdt/globaldb/globaldb.hpp"
#include "crdt/globaldb/keypair_file_storage.hpp"

#include <libp2p/multi/multibase_codec/multibase_codec_impl.hpp>
#include <libp2p/log/configurator.hpp>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
#ifndef GRPC_FOR_SUPERGENIUS_PROCESSING_SUBTASK_RESULT_STORAGE_IMPL_HPP
#define GRPC_FOR_SUPERGENIUS_PROCESSING_SUBTASK_RESULT_STORAGE_IMPL_HPP

#include <processing/processing_subtask_result_storage.hpp>
#include <crdt/globaldb/globaldb.hpp>
#include "processing/processing_subtask_result_storage.hpp"
#include "crdt/globaldb/globaldb.hpp"

namespace sgns::processing
{
Expand Down
10 changes: 9 additions & 1 deletion example/processing_mnn/processing_mnn.cpp
Original file line number Diff line number Diff line change
@@ -1,9 +1,17 @@
//#define STB_IMAGE_IMPLEMENTATION
//#define STB_IMAGE_WRITE_IMPLEMENTATION
#include "processing_mnn.hpp"

#include <ipfs_pubsub/gossip_pubsub.hpp>
#include <rapidjson/document.h>

#include "FileManager.hpp"
#include "URLStringUtil.h"
#include "base/logger.hpp"
#include "crdt/globaldb/globaldb.hpp"
#include "crdt/globaldb/keypair_file_storage.hpp"
#include "processing/impl/processing_task_queue_impl.hpp"
#include "processing/processing_imagesplit.hpp"

using GossipPubSub = sgns::ipfs_pubsub::GossipPubSub;
const std::string logger_config(R"(
# ----------------
Expand Down
20 changes: 6 additions & 14 deletions example/processing_mnn/processing_mnn.hpp
Original file line number Diff line number Diff line change
@@ -1,17 +1,8 @@
#pragma once
#include <math.h>
#include <fstream>
#include <memory>

#include <cmath>
#include <iostream>
#include "processing/impl/processing_task_queue_impl.hpp"
#include "processing/impl/processing_subtask_result_storage_impl.hpp"
#include <processing/processing_service.hpp>
#include <processing/processing_subtask_enqueuer_impl.hpp>
#include <processing/processors/processing_processor_mnn_posenet.hpp>
#include <processing/impl/processing_core_impl.hpp>
#include <crdt/globaldb/globaldb.hpp>
#include <crdt/globaldb/keypair_file_storage.hpp>
#include <crdt/globaldb/proto/broadcast.pb.h>

#include <spdlog/sinks/basic_file_sink.h>
#include <libp2p/log/configurator.hpp>
#include <libp2p/log/logger.hpp>
Expand All @@ -20,9 +11,10 @@
#include <openssl/sha.h>
#include <boost/program_options.hpp>
#include <boost/format.hpp>
#include <ipfs_lite/ipfs/graphsync/graphsync.hpp>
#include "ipfs_pubsub/gossip_pubsub.hpp"

#include <ipfs_lite/ipfs/graphsync/graphsync.hpp>
#include "processing/processing_subtask_state_storage.hpp"
#include "processing/processing_imagesplit.hpp"

namespace
{
Expand Down
12 changes: 12 additions & 0 deletions example/processing_mnn/processing_mnn_p.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
#include <ipfs_pubsub/gossip_pubsub.hpp>
#include <ipfs_pubsub/gossip_pubsub_topic.hpp>

#include "base/logger.hpp"
#include "crdt/globaldb/globaldb.hpp"
#include "crdt/globaldb/keypair_file_storage.hpp"
#include "processing/impl/processing_core_impl.hpp"
#include "processing/impl/processing_subtask_result_storage_impl.hpp"
#include "processing/impl/processing_task_queue_impl.hpp"
#include "processing/processing_service.hpp"
#include "processing/processing_subtask_enqueuer_impl.hpp"
#include "processing/processors/processing_processor_mnn_posenet.hpp"
#include "processing_mnn.hpp"

using GossipPubSub = sgns::ipfs_pubsub::GossipPubSub;
Expand Down
4 changes: 2 additions & 2 deletions example/processing_room/processing_app.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include <processing/processing_service.hpp>
#include <processing/processing_subtask_enqueuer_impl.hpp>
#include "processing/processing_service.hpp"
#include "processing/processing_subtask_enqueuer_impl.hpp"

#include <iostream>
#include <thread>
Expand Down
Loading

0 comments on commit 836f149

Please sign in to comment.