Skip to content

Commit

Permalink
Merge branch 'develop' into remove-const-ref-in-shared-ptr
Browse files Browse the repository at this point in the history
  • Loading branch information
EduMenges authored Jun 27, 2024
2 parents a3711f5 + 7eeda19 commit 21393d0
Show file tree
Hide file tree
Showing 109 changed files with 3,568 additions and 3,153 deletions.
3 changes: 2 additions & 1 deletion .clang-format
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
---
BasedOnStyle: Microsoft
AccessModifierOffset: -4
AlwaysBreakTemplateDeclarations: true
AlignConsecutiveAssignments:
Enabled: true
AlignCompound: true
Expand Down Expand Up @@ -32,4 +33,4 @@ SortIncludes: Never
SpacesInParens: Custom
SpacesInParensOptions:
Other: true
Standard: c++17
Standard: c++17
3 changes: 2 additions & 1 deletion .git-blame-ignore-revs
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@
# Reformats
cd55bda30ece6f3af73bdbaea84e5cda93f8973a
968c9f34ae30975867ca18dea49d6c4671bdbb78
5f7734854e56dda50ee22270f11b8afb45ff16f9
5f7734854e56dda50ee22270f11b8afb45ff16f9
fb52575b5eda2436b9d0f7ec50672793f61a4514
192 changes: 94 additions & 98 deletions Readme.md
Original file line number Diff line number Diff line change
@@ -1,168 +1,168 @@
This is the block-lattice super fast cryptotoken system based on the original nanocurrency

## Download SuperGenius project

```bash
git clone [email protected]:GeniusVentures/SuperGenius.git --recursive
cd SuperGenius
git checkout develop
```

## Download thirdparty project

```bash
cd ..
git clone [email protected]:GeniusVentures/thirdparty.git --recursive
git clone [email protected]:GeniusVentures/thirdparty.git
cd thirdparty
git checkout develop
git submodule update --init --recursive
```
## [Build thirdparty project](../../../thirdparty/blob/master/README.md)

The folder structure must be as follows:
## Download SuperGenius project

```bash
.
├── thirdparty # geniustokens thirdparty
│ ├── grpc # grpc latest version (current v1.28.1)
│ ├── libp2p # libp2p cross-compile branch
│ └── ipfs-lite-cpp # current repo
│ ├── ipfs-lite # sub folder
│ ├── readme.md # readme
│ └── CMakeList.txt # CMake file
└── SuperGenius
├── readme.md # readme
└── CMakeList.txt # CMake file
git clone [email protected]:GeniusVentures/SuperGenius.git
cd SuperGenius
git checkout develop
git submodule update --init --recursive
```

## Building

### Windows
Ideally the folder structure should be as follows

I used visual studio 2019 to compile SuperGenius project.
1. Download OpenSSL and install
2. Build SuperGenius using following commands in Release configuration:

```bash
cd SuperGenius
md .build
cd .build
cmake ../build/Windows -G "Visual Studio 16 2019" -A x64 -DCMAKE_BUILD_TYPE=Release -DTHIRDPARTY_DIR=[ABSOLUTE_PATH_TO_THIRDPARTY_BUILD_RELEASE] -DTESTING=OFF
cmake --build . --config Release
.
├── thirdparty # SuperGenius project
│ └── build # build directory
│ ├── Android # Android build directory
│ ├── Linux # Linux build directory
│ ├── Windows # Windows build directory
│ ├── OSX # OSX build directory
| └── Release # Release build of OSX (Created when building for OSX Release)
| └── iOS # iOS build directory
└── SuperGenius
│ └── build # build directory
│ ├── Android # Android build directory
│ ├── Linux # Linux build directory
│ ├── Windows # Windows build directory
│ ├── OSX # OSX build directory
| └── Release # Release build of OSX (Created when building for OSX Release)
| └── iOS # iOS build directory
```

If you are going to build and test, then use following commands

```bash
cmake ../build/Windows -G "Visual Studio 16 2019" -A x64 -DTESTING=ON -DCMAKE_BUILD_TYPE=Release -DTHIRDPARTY_DIR=[ABSOLUTE_PATH_TO_THIRDPARTY_BUILD_RELEASE]
cmake --build . --config Release
cd SuperGenius/src/SuperGenius-build
ctest -C Release
```
## Building

To run sepecific test with detailed log, you can use following commands.
Chose the CMAKE_BUILD_TYPE according to the desired configuration (Debug or Release). Chose TESTING ON of OFF to enable unit tests.

```bash
ctest -C Release -R <test_name> --verbose
```
### Windows

To run all tests and display log for failed tests, you can use following commands.
Use Visual Studio 17 2022 to compile SuperGenius project.

```bash
ctest -C Release --output-on-failure
cd build
cd Windows
md [Debug or Release]
cd [Debug or Release]
cmake .. -G "Visual Studio 17 2022" -A x64 -DCMAKE_BUILD_TYPE=[Debug or Release] -DTHIRDPARTY_DIR=[ABSOLUTE_PATH_TO_THIRDPARTY_PROJECT] -DTESTING=[ON or OFF]
cmake --build . --config [Debug or Release]
```

You can use Debug configuration to debug in Visual Studio.

example build commands

```bash
cmake ../build/Windows -G "Visual Studio 16 2019" -A x64 -DTESTING=ON -DCMAKE_BUILD_TYPE=Debug -DTHIRDPARTY_DIR=[ABSOLUTE_PATH_TO_THIRDPARTY_BUILD_DEBUG]

cmake --build . --config Debug
cd SuperGenius/src/SuperGenius-build
ctest -C Debug
```

### Linux

```bash
cd SuperGenius
mkdir .build
cd .build
cmake ../build/Linux -DCMAKE_BUILD_TYPE=Release -DTHIRDPARTY_DIR=[ABSOLUTE_PATH_TO_THIRDPARTY_BUILD_RELEASE]
cmake --build . --config Release
cd build/Linux
mkdir [Debug or Release]
cd [Debug or Release]
cmake .. -DCMAKE_BUILD_TYPE=[Debug or Release] -DTHIRDPARTY_DIR=[ABSOLUTE_PATH_TO_THIRDPARTY_PROJECT] -DTESTING=[ON or OFF]
cmake --build . --config [Debug or Release]
```

### Linux for Android cross compile
### Android Cross-Compile on Linux/OSX Hosts

#### Preinstall
- CMake
- Android NDK Latest LTS Version (r21e) [(link)](https://developer.android.com/ndk/downloads#lts-downloads)
- ([Build thirdparty project](../thirdparty/README.md))
- Android NDK Latest LTS Version (r25b) [(link)](https://github.com/android/ndk/wiki/Unsupported-Downloads)

#### Building
```bash
export ANDROID_NDK=/path/to/android-ndk-r21e
export ANDROID_NDK=/path/to/android-ndk-r25b
export ANDROID_TOOLCHAIN="$ANDROID_NDK/toolchains/llvm/prebuilt/linux-x86_64/bin"
export PATH="$ANDROID_TOOLCHAIN":"$PATH"
```

* armeabi-v7a

```bash
mkdir .build/Android.armeabi-v7a
cd ./.build/Android.armeabi-v7a
cmake ../../build/Android/ -DANDROID_ABI="armeabi-v7a" -DCMAKE_ANDROID_NDK=$ANDROID_NDK -DANDROID_TOOLCHAIN=clang -DTHIRDPARTY_DIR=[ABSOLUTE_PATH_TO_THIRDPARTY_BUILD_Android.armeabi-v7a]
make -j4
cd build/Android
mkdir -p [Debug or Release]/armeabi-v7a
cd [Debug or Release]/armeabi-v7a
cmake ../../ -DANDROID_ABI="armeabi-v7a" -DCMAKE_ANDROID_NDK=$ANDROID_NDK -DANDROID_TOOLCHAIN=clang -DTHIRDPARTY_DIR=[ABSOLUTE_PATH_TO_THIRDPARTY_PROJECT]
cmake --build . --config [Debug or Release]
```

* arm64-v8a

```bash
mkdir .build/Android.arm64-v8a
cd ./.build/Android.arm64-v8a
cmake ../../build/Android/ -DANDROID_ABI="arm64-v8a" -DCMAKE_ANDROID_NDK=$ANDROID_NDK -DANDROID_TOOLCHAIN=clang -DTHIRDPARTY_DIR=[ABSOLUTE_PATH_TO_THIRDPARTY_BUILD_Android.arm64-v8a]
make -j4
cd build/Android
mkdir -p [Debug or Release]/arm64-v8a
cd [Debug or Release]/arm64-v8a
cmake ../../ -DANDROID_ABI="arm64-v8a" -DCMAKE_ANDROID_NDK=$ANDROID_NDK -DANDROID_TOOLCHAIN=clang -DTHIRDPARTY_DIR=[ABSOLUTE_PATH_TO_THIRDPARTY_PROJECT] -DSUPERGENIUS_SRC_DIR=[ABSOLUTE_PATH_TO_SUPERGENIUS_PROJECT]
cmake --build . --config [Debug or Release]
```

* x86

```bash
mkdir .build/Android.x86
cd ./.build/Android.x86
cmake ../../build/Android/ -DANDROID_ABI="x86" -DCMAKE_ANDROID_NDK=$ANDROID_NDK -DANDROID_TOOLCHAIN=clang -DTHIRDPARTY_DIR=[ABSOLUTE_PATH_TO_THIRDPARTY_BUILD_Android.x86]
make -j4
cd build/Android
mkdir -p [Debug or Release]/x86
cd [Debug or Release]/x86
cmake ../../ -DANDROID_ABI="x86" -DCMAKE_ANDROID_NDK=$ANDROID_NDK -DANDROID_TOOLCHAIN=clang -DTHIRDPARTY_DIR=[ABSOLUTE_PATH_TO_THIRDPARTY_PROJECT] -DSUPERGENIUS_SRC_DIR=[ABSOLUTE_PATH_TO_SUPERGENIUS_PROJECT]
cmake --build . --config [Debug or Release]
```

* x86_64
```bash
mkdir .build/Android.x86_64
cd ./.build/Android.x86_64
cmake ../../build/Android/ -DANDROID_ABI="x86_64" -DCMAKE_ANDROID_NDK=$ANDROID_NDK -DANDROID_TOOLCHAIN=clang -DTHIRDPARTY_DIR=[ABSOLUTE_PATH_TO_THIRDPARTY_BUILD_Android.x86_64]
make -j4
cd build/Android
mkdir -p [Debug or Release]/x86_64
cd [Debug or Release]/x86_64
cmake ../../ -DANDROID_ABI="x86_64" -DCMAKE_ANDROID_NDK=$ANDROID_NDK -DANDROID_TOOLCHAIN=clang -DTHIRDPARTY_DIR=[ABSOLUTE_PATH_TO_THIRDPARTY_PROJECT] -DSUPERGENIUS_SRC_DIR=[ABSOLUTE_PATH_TO_SUPERGENIUS_PROJECT]
cmake --build . --config [Debug or Release]
```

### OSX
### OSX (x86_64 & Arm64)

```bash
cd SuperGenius
mkdir .build/OSX
cd .build/OSX
cmake ../../build/OSX -DCMAKE_BUILD_TYPE=Release -DTHIRDPARTY_DIR=[ABSOLUTE_PATH_TO_THIRDPARTY_BUILD_RELEASE]
make -j4
cd build/OSX
mkdir [Debug or Release]
cd [Debug or Release]
cmake .. -DCMAKE_BUILD_TYPE=[Debug or Release] -DTHIRDPARTY_DIR=[ABSOLUTE_PATH_TO_THIRDPARTY_PROJECT]
cmake --build . --config [Debug or Release]
```

#### For iOS cross compile
### iOS cross compile

```bash
cd SuperGenius
mkdir .build/iOS
cd .build/iOS
cmake ../../build/iOS -DCMAKE_BUILD_TYPE=Release -DTHIRDPARTY_DIR=[ABSOLUTE_PATH_TO_THIRDPARTY_BUILD_RELEASE] -DCMAKE_TOOLCHAIN_FILE=[/ABSOLUTE/PATH/TO/GeniusTokens/SuperGenius/build/iOS/iOS.cmake] -DiOS_ABI=arm64-v8a -DIOS_ARCH="arm64" -DENABLE_ARC=0 -DENABLE_BITCODE=0 -DENABLE_VISIBILITY=1 -DCMAKE_OSX_ARCHITECTURES=arm64 -DCMAKE_SYSTEM_PROCESSOR=arm64
make -j4
cd build/iOS
mkdir [Debug or Release]
cd [Debug or Release]
cmake .. -DCMAKE_BUILD_TYPE=[Debug or Release] -DTHIRDPARTY_DIR=[ABSOLUTE_PATH_TO_THIRDPARTY_PROJECT] -DCMAKE_TOOLCHAIN_FILE=../iOS.cmake -DiOS_ABI=arm64-v8a -DIOS_ARCH="arm64" -DENABLE_ARC=0 -DENABLE_BITCODE=0 -DENABLE_VISIBILITY=1 -DCMAKE_OSX_ARCHITECTURES=arm64 -DCMAKE_SYSTEM_PROCESSOR=arm64
cmake --build . --config [Debug or Release]
```
## Unit tests
If you configured and built with -DTESTING=ON, you can execute the unit tests on the root of the build directory.

### Setting up VS Code intellisense
```bash
ctest -C [Debug or Release]
```

To run sepecific test with detailed log, you can use following commands.

```bash
ctest -C [Debug or Release] -R <test_name> --verbose
```

To run all tests and display log for failed tests, you can use following commands.

```bash
ctest -C [Debug or Release] --output-on-failure
```

## Setting up VS Code intellisense

This requires installing the (C/C++ Extension Pack)[https://marketplace.visualstudio.com/items?itemName=ms-vscode.cpptools-extension-pack]. Configure CMake Tools to appear under the toolbar, with this setting:

Expand All @@ -185,8 +185,4 @@ By pressing `CTRL + P` and picking `CMake: Configure`, choose the `CMakeLists.tx

This will also configure the `thirdparty` directory. Now, it should be working.

## Running tests

### Linux

Enter the `.build` directory and run `ctest -C Release`.
16 changes: 9 additions & 7 deletions build/Android/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.12)

# --------------------------------------------------------
# if on Linux system, build the Android executables
if (NOT ${CMAKE_HOST_SYSTEM_NAME} MATCHES "Linux")
if(NOT ${CMAKE_HOST_SYSTEM_NAME} MATCHES "Linux")
message(FATAL_ERROR "${CMAKE_HOST_SYSTEM_NAME} host system name does not match Linux for Android cross compiling - Please select the correct folder for configuring project")
endif()

Expand All @@ -15,7 +15,7 @@ set(ANDROID_NATIVE_API_LEVEL 28)
# --------------------------------------------------------
# Check Android NDK version
if(NOT CMAKE_ANDROID_NDK)
message(FATAL_ERROR "Cannot find Android NDK, make sure you pass -DCMAKE_ANDROID_NDK=[path_to_NDK]")
message(FATAL_ERROR "Cannot find Android NDK, make sure you pass -DCMAKE_ANDROID_NDK=[path_to_NDK]")
endif()

file(READ "${CMAKE_ANDROID_NDK}/source.properties" SOURCE_PROPERTIES_CONTENT)
Expand All @@ -25,19 +25,20 @@ set(CMAKE_ANDROID_NDK_VERSION_MINOR ${CMAKE_MATCH_2})

message("--Android NDK version: ${CMAKE_ANDROID_NDK_VERSION}.${CMAKE_ANDROID_NDK_VERSION_MINOR}")

if (NOT CMAKE_ANDROID_NDK_VERSION EQUAL 25)
message(FATAL_ERROR "Android NDK LTS Version (r25b) stable long term support version required")
if(NOT CMAKE_ANDROID_NDK_VERSION EQUAL 25)
message(FATAL_ERROR "Android NDK LTS Version (r25b) stable long term support version required")
endif()

# --------------------------------------------------------
# Check required input args
if(NOT ANDROID_ABI)
message(FATAL_ERROR "Cannot find ANDROID_ABI, make sure you pass -DANDROID_ABI=[armeabi-v7a | arm64-v8a | x86 | x86_64]")
message(FATAL_ERROR "Cannot find ANDROID_ABI, make sure you pass -DANDROID_ABI=[armeabi-v7a | arm64-v8a | x86 | x86_64]")
endif()

set(CMAKE_ANDROID_ARCH_ABI ${ANDROID_ABI})

if(NOT ANDROID_TOOLCHAIN)
message(FATAL_ERROR "Cannot find ANDROID_TOOLCHAIN, make sure you pass -DANDROID_TOOLCHAIN=[e.g clang]")
message(FATAL_ERROR "Cannot find ANDROID_TOOLCHAIN, make sure you pass -DANDROID_TOOLCHAIN=[e.g clang]")
endif()

# --------------------------------------------------------
Expand All @@ -47,8 +48,9 @@ set(CMAKE_ANDROID_STL_TYPE c++_static)
# --------------------------------------------------------
# Set toolchain file
set(CMAKE_TOOLCHAIN_FILE "${CMAKE_ANDROID_NDK}/build/cmake/android.toolchain.cmake")

if(NOT EXISTS ${CMAKE_TOOLCHAIN_FILE})
message(FATAL_ERROR "Android NDK toolchain file ${CMAKE_TOOLCHAIN_FILE} not found")
message(FATAL_ERROR "Android NDK toolchain file ${CMAKE_TOOLCHAIN_FILE} not found")
endif()

# --------------------------------------------------------
Expand Down
Loading

0 comments on commit 21393d0

Please sign in to comment.