Skip to content

Commit

Permalink
Updated README
Browse files Browse the repository at this point in the history
  • Loading branch information
EduMenges committed Nov 18, 2024
1 parent 8a107fa commit 7ff036e
Showing 1 changed file with 59 additions and 198 deletions.
257 changes: 59 additions & 198 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,234 +1,95 @@
This is the repository for third party of SuperGenius
===================================

# CI/CD Status
| | | |
|:----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|:---|:---|
| [![WIndows Master](https://github.com/GeniusVentures/thirdparty/actions/workflows/Windows-cmake.yml/badge.svg?branch=master)](https://github.com/GeniusVentures/thirdparty/actions/workflows/Windows-cmake.yml) | [![OSX Master](https://github.com/GeniusVentures/thirdparty/actions/workflows/OSX-cmake.yml/badge.svg?branch=master)](https://github.com/GeniusVentures/thirdparty/actions/workflows/OSX-cmake.yml) | [![Linux Master](https://github.com/GeniusVentures/thirdparty/actions/workflows/Linux-cmake.yml/badge.svg?branch=master)](https://github.com/GeniusVentures/thirdparty/actions/workflows/Linux-cmake.yml) |
| [![iOS Master](https://github.com/GeniusVentures/thirdparty/actions/workflows/iOS-cmake.yml/badge.svg?branch=master)](https://github.com/GeniusVentures/thirdparty/actions/workflows/iOS-cmake.yml) | [![Android Master](https://github.com/GeniusVentures/thirdparty/actions/workflows/Android-cmake.yml/badge.svg?branch=master)](https://github.com/GeniusVentures/thirdparty/actions/workflows/Android-cmake.yml) ||
This is the repository for third party of [SuperGenius](https://github.com/GeniusVentures/SuperGenius/).

===================================

### Speeding up the build tools
Set two environment variables
- CMAKE_BUILD_PARALLEL_LEVEL=8
- MAKEFLAGS="-j8" # this errors on Windows nmake, so don't use on Windows
# Download pre-built libraries

# Download Prebuilt libs
Pre-built libraries are available on the [release page](https://github.com/GeniusVentures/thirdparty/releases). The tags are named with the following convention:

Requirements:
- Python3 (3.7+)
- pip install tqdm
- pip install aiohttp
`${PLATFORM}-${BRANCH}-${BUILD_TYPE}`

In thirdparty root directory, with GeniusNetwork as root directory
python ../util/install_from_github.py build/tp-dl-prebuilt-config.txt
Where:

# Download thirdparty project for development
- `PLATFORM` is Android, iOS, Linux, OSX or Windows
- `BUILD_TYPE` is either Debug or Release

```bash
git clone [email protected]:GeniusVentures/thirdparty.git
cd thirdparty
git checkout develop
git submodule update --init --recursive
```
# Building
The `master` branch receives few merges, download from the `develop` branch to get the newest builds.

Chose the CMAKE_BUILD_TYPE according to the desired configuration (Debug or Release).
# Building

## Windows
If you want to build `thirdparty` for yourself, you'll need to recursively checkout every submodule.

Using Visual Studio 17 2022 to compile thirdparty project.
## Requirements

### Requirements
- CMake
- Visual Studio 2019 or 2022
- Strawberry Perl (https://strawberryperl.com/)
- Python >=3.5
- rvm/Ruby 2.7.8
- ```rvm --default use ruby-2.7.8```
- wallet-core dependency tools
- Rust, cargo
- ```rustup set default-host x86_64-pc-windows-msvc```
- ```rustup target add x86_64-pc-windows-msvc```
- ```cargo install cbindgen cargo-lipo```
- ```rustup target add wasm32-unknown-emscripten``` (to be deprecated)
-
### Build instructions
```bash
cd build/Windows
mkdir [Debug or Release]
cd [Debug or Release]
cmake .. -G "Visual Studio 17 2022" -A x64 -DCMAKE_BUILD_TYPE=[Debug or Release]
cmake --build . --config [Debug or Release]
```
- Perl
- `wallet-core` dependency tools
- Ruby
- Rust
- `bindgen` (install with `cargo install cbindgen`)
- WASM target (install with `rustup target add wasm32-unknown-emscripten`)
- `clang` or `MSVC` as a compiler

## Linux
### Requirements

- Ubuntu 22.04 (or compatible) recommended
### Android

Open a terminal as root ("sudo" without su won't do it because of Ruby installation)
- NDK, preferably version 27b
- Remember to set the environment variable `ANDROID_NDK_HOME` to point to the install path
- Rust Android target
- Installable with `rustup target add aarch64-linux-android`

```bash
sudo su root
```
Note: we do not test cross-compiling for Android using Windows.

Install default requirements
### iOS

```bash
#!/bin/bash
apt-get -y update
apt-get -y install g++ clang llvm cmake ntp zlib1g-dev libgtk-3-dev ninja-build libjsoncpp25 libsecret-1-0 libjsoncpp-dev libsecret-1-dev git cmake default-jre curl libc++-dev libc++abi-dev
cd /usr/local/src
wget --no-check-certificate https://www.openssl.org/source/openssl-1.1.1t.tar.gz
tar -xf openssl-1.1.1t.tar.gz
cd openssl-1.1.1t/
./config --prefix=/usr/local/ssl --openssldir=/usr/local/ssl shared zlib >build.log
make install >>build.log
cd ~/
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
. "$HOME/.cargo/env"
cargo install cbindgen >rust-install.log
rustup target add x86_64-unknown-linux-gnu >rust-install.log
cp -R /root/.cargo /home/$SUDO_USER
cp -R /root/.rustup /home/$SUDO_USER
chown -R $SUDO_USER:$SUDO_USER /home//$SUDO_USER/.cargo /home//$SUDO_USER/.rustup
apt-get -y install gnupg2
curl -sSL https://rvm.io/mpapis.asc | gpg2 --import -
curl -sSL https://rvm.io/pkuczynski.asc | gpg2 --import -
curl -sSL https://get.rvm.io | bash -s stable >>ruby-build.log
source /etc/profile.d/rvm.sh
rvm install ruby-2.7.8 --with-openssl-dir=/usr/local/ssl/ >>ruby-build.log
rvm --default use ruby-2.7.8
ln -s /usr/bin/python3 /usr/bin/python
```
- Rust iOS target and toolchain

```bash
# exit sudo su root
exit
source /etc/profile.d/rvm.sh
# this updates the path
rvm --default use ruby-2.7.8
echo '. "$HOME/.cargo/env"' >> $HOME/.bashrc
# default to use clang
sudo update-alternatives --set c++ /usr/bin/clang++
sudo update-alternatives --set cc /usr/bin/clang
rustup toolchain install nightly-aarch64-apple-darwin
rustup component add rust-src --toolchain nightly-aarch64-apple-darwin
rustup target add aarch64-apple-ios
```
These steps were extracted from the bootstrap.sh script on TestVMS [**(here)**](../../../TestVMs/blob/master/Ubuntu64Desktop/bootstrap.sh)

The following Rust target is needed for now but will be deprecated soon:
## CMake

- ```rustup target add wasm32-unknown-emscripten``` # this will be deprecated on wallet-core soon
### Build instructions
In the `build` directory, there'll be a folder for every supported platform, and inside each there will be a `CMakeLists.txt` file. To build, you must configure CMake using this platform-specific subdirectory and build from there.

Our convention is to create a subdirectory inside `build/${PLATFORM}`, called either `Debug` or `Release`, depending on the `BUILD_TYPE`. So to build the debug version for Linux, you would:

```bash
cd build/Linux
mkdir [Debug or Release]
cd [Debug or Release]
cmake .. -DCMAKE_BUILD_TYPE=[Debug or Release]
make
cmake -B Debug -CMAKE_BUILD_TYPE=Debug
cmake --build Debug --config Debug -j
```

## Android Cross-Compile on Linux/OSX Hosts
Some CMake projects rely on having `CMAKE_BUILD_TYPE` set, so even if you're using a multi-config generator like Visual Studio, it is important to set it accordingly.

Another example, for Windows using release mode:

### Requirements
- CMake
- Android NDK r25b Version [(link)](https://github.com/android/ndk/wiki/Unsupported-Downloads)
- rvm/Ruby 2.7.8
- ```rvm --default use ruby-2.7.8```
- wallet-core dependency tools
- Rust, cargo
- ```rustup target add aarch64-linux-android armv7-linux-androideabi x86_64-linux-android i686-linux-android```
#### Host settings in .bash_profile (ex.)
○ 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"
### Build instructions
* armeabi-v7a
```bash
cd build/Android
mkdir -p [Debug or Release]/armeabi-v7a
cd [Debug or Release]/armeabi-v7a
cmake ../../ -DCMAKE_BUILD_TYPE=[Debug or Release] -DANDROID_ABI="armeabi-v7a" -DCMAKE_ANDROID_NDK=$ANDROID_NDK -DANDROID_TOOLCHAIN=clang
make
```
* arm64-v8a
```bash
cd build/Android
mkdir -p [Debug or Release]/arm64-v8a
cd [Debug or Release]/arm64-v8a
cmake ../../ -DCMAKE_BUILD_TYPE=[Debug or Release] -DANDROID_ABI="arm64-v8a" -DCMAKE_ANDROID_NDK=$ANDROID_NDK -DANDROID_TOOLCHAIN=clang
make
cd build/Windows
cmake -B Release -CMAKE_BUILD_TYPE=Release
cmake --build Release --config Release -j
```
* x86_64

When building for Android, we expect each ABI to have its own subdirectory.

```bash
cd build/Android
mkdir -p [Debug or Release]/x86_64
cd [Debug or Release]/x86_64
cmake ../../ -DCMAKE_BUILD_TYPE=[Debug or Release] -DANDROID_ABI="x86_64" -DCMAKE_ANDROID_NDK=$ANDROID_NDK -DANDROID_TOOLCHAIN=clang
make
mkdir Debug && cd Debug
cmake -S .. -B arm64-v8a -CMAKE_BUILD_TYPE=Debug -DANDROID_ABI=arm64-v8a
cmake --build arm64-v8a --config Debug -j
```
## OSX
### Requirements
- CMake
- Python >=3.5
- xCode Command line Tools & SDK
- rvm/Ruby 2.7.8 install
- Undo OpenSSL 3 install
- ```brew unlink openssl@3```
- ```brew link [email protected] --force```
- Install RVM
- ```curl -sSL https://get.rvm.io | bash -s stable```
- Install version 2.7.8
- ```rvm install ruby-2.7.8```
- use 2.7.8 as default
- ```rvm --default use ruby-2.7.8```
- wallet-core dependency tools
- Rust, cargo
```bash
rustup update
rustup toolchain install stable
rustup default stable
rustup target add x86_64-apple-darwin
rustup target add aarch64-apple-darwin
rustup target add wasm32-unknown-emscripten
cargo install cbindgen cargo-lipo
```

### Build instructions

When building for Apple platforms, you'll need to configure the project with the `PLATFORM` variable set to one of these values:

- `OS64` for iOS
- `MAC` for macOS **x86**
- `MAC_ARM64` for macOS **arm64**

Example for macOS x86:

```bash
cd build/OSX
mkdir [Debug or Release]
cd [Debug or Release]
cmake .. -DCMAKE_BUILD_TYPE=[Debug or Release]
make
```

## iOS cross compile
### Requirements
- CMake
- xCode Command line Tools & SDK
- rvm/Ruby 2.7.8
- wallet-core dependency tools
- Rust, cargo
```bash
rustup update
rustup toolchain install stable
rustup default stable
rustup toolchain install stable-x86_64-apple-darwin
rustup toolchain install nightly-x86_64-apple-darwin
rustup component add rust-src --toolchain nightly-x86_64-apple-darwin
rustup component add rust-src --toolchain nightly-aarch64-apple-darwin
rustup target add x86_64-apple-ios aarch64-apple-ios-sim aarch64-apple-ios
cargo install cbindgen cargo-lipo
```

### Build instructions
``` bash
cd build/iOS
mkdir [Debug or Release]
cd [Debug or Release]
cmake .. -DCMAKE_BUILD_TYPE=[Debug or Release]
make
cmake -B Release -CMAKE_BUILD_TYPE=Release -DPLATFORM=MAC
cmake --build Release --config Release -j
```

0 comments on commit 7ff036e

Please sign in to comment.