C+ code for deployment on Android, Windows, linux, MacOS
Build requirements:
- Git (for clone codes and submodules)
git clone --recurse-submodules git@git.woa.com:InteractionAlgorithm/Juglans.git
- CMake 3.21.0 or later
- C++ 17 compiler
- MSVC 2017 version 15.7 or later, MSVC 2022 is recommended.
- GCC 7.0 or later
- Clang 6.0 or later
- Android NDK r17, see instructions below
- (Optional) If build with command line, install
make
,jom
orninja
. Recommend to useninja
on Windows andmake
on other platforms. - Have clang-format 14 in PATH, see Code format section for details.
- TensorRT (Windows and Linux), see instructions below
These steps assumes you haven't installed Android SDK or NDK before.
If you already has Android SDK, you can install NDK r17c and set it folder as ANDROID_NDK_r17c
environment variable.
It's recommended to use NDK r17c to match the same version that is used by SNPE.
- Download Tencent JDK 8.
- Extract binary and set
TencentKona-8.xxx
folder asJAVA_HOME
environment variable - Add
TencentKona-8.xxx/bin
folder toPATH
- Download Android command line tools.
- Extract binary to a temp place
- Create a new folder for android sdk on the disk. Referred as
<Android SDK Path>
in following commands. - Run
cmdline-tools\bin\sdkmanager.bat --sdk_root=<Android SDK Path> "cmdline-tools;latest" platform-tools "ndk;21.4.7075529"
- Add
<Android SDK Path>\platform-tools
and optionally<Android SDK Path>\cmdline-tools\latest\bin
toPATH
. - Set
<Android SDK Path>\ndk\21.4.7075529
asANDROID_NDK_r21e
environment variable. - Remove the temp command line tools
- Install latest NVIDIA GPU driver from official website
- Install CUDA Toolkit 11.3 Update 1, which is same version used by Pytorch in Hawthorn.
- On Windows, download and run setup exe. Make sure unselect GPU driver as we have installed newer version in previous step.
- On Linux (including WSL2), follow instruction on pages to install with package manager.
- Register NVIDIA developer account, which is required to download cuDNN and TensorRT.
- Download and install latest cuDNN for CUDA 11.x
- On Windows, extract zip file and add bin subfolder to PATH.
- On Windows, extract
zlibwapi.dll
from zlib release and put in cuDNN bin folder (or any other foler in PATH).
- Download and install lastest TensorRT GA for CUDA 11.x.
- On Windows, extract zip file and add lib & bin subfolders to PATH.
Run the following commands in command line to generate VS solution and projects, assuming current workdir is root of juglans repo.
md build
cd build
cmake -G "Visual Studio 17 2022" ..
start Juglans.sln
If you are using older VS version, change cmake generator to Visual Studio 15 2017 Win64
or Visual Studio 16 2019
.
- Open Developer Command Prompt for VS
- Run following commands to generate ninja makefiles, assuming current workdir is root of juglans repo.
md build
cd build
cmake -G Ninja -DCMAKE_BUILD_TYPE=Release ..
- To build targets, run
ninja <target>
.
- Make sure
ANDROID_NDK_r17c
environment variable is set. - Run following commands to generate ninja makefiles, assuming current workdir is root of juglans repo.
md build
cd build
cmake -G Ninja -DCMAKE_BUILD_TYPE=Release -DANDROID=ON ..
- To build targets, run
ninja <target>
.
- Module targets:
juglans_<module>
, e.g.juglans_core
. - Tool targets:
<tool>
, e.g.capture
. - Test targets:
<module>_test
, e.g.core_test
. - Run test targets (command line generator only):
run_<module>_test
orrun_all
to run all tests. - Unity related targets:
unity
to copy binaries to unity demo's plugin folder. - Code format targets:
clangformat
to format all, orclangformat_<module>
/clangformat_<tool>
to format only 1 module/tool.
We use clang-foramt 14 to format all source files in the repo.
- Windows
- Download
LLVM-14.0.5-win64.exe
from release page - Install LLVM and add bin folder to PATH.
- Alternatively, copy
clang-format.exe
from bin folder and put it in any folder inside PATH.
- Download
- Mac
brew install clang-format@14
- Ubuntu
- Ubuntu 18.04
echo "deb http://apt.llvm.org/bionic/ llvm-toolchain-bionic-14 main" | sudo tee /etc/apt/sources.list.d/llvm.list echo "deb-src http://apt.llvm.org/bionic/ llvm-toolchain-bionic-14 main" | sudo tee -a /etc/apt/sources.list.d/llvm.list wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | sudo apt-key add - sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test sudo apt install clang-format-14
- Ubuntu 20.04 or newer
echo "deb http://apt.llvm.org/$(lsb_release -cs)/ llvm-toolchain-$(lsb_release -cs)-14 main" | sudo tee /etc/apt/sources.list.d/llvm.list echo "deb-src http://apt.llvm.org/$(lsb_release -cs)/ llvm-toolchain-$(lsb_release -cs)-14 main" | sudo tee -a /etc/apt/sources.list.d/llvm.list wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | sudo apt-key add - sudo apt update sudo apt install clang-format-14
Build clangformat
target generated by CMake.
This can be clangformat
project in your VS solution or make clangforamt
depending on your CMake generator.