This document includes guidelines.
To build Yacl from source, you will need the following tools:
- bazel: We recommend to use the official bazelisk to manage bazel version.
- If not use bazelisk, please set the environment variable
USE_BAZEL_VERSIONto the specified version, which can be found in the.bazeliskrcfile.
- If not use bazelisk, please set the environment variable
- gcc >= 10.3, g++ >= 10.3
- cmake
- ninja/ninja-build
- Perl 5 with core modules (Required by OpenSSL)
Please make sure you already have git installed on your system, then clone Yacl via the github link,
$ git clone https://github.com/secretflow/yacl.gitThe building process of YACL is as following.
Download the dependencies
$ sudo apt install gcc g++ wget cmake ninja-build nasm automake libtool libomp-devWe recommend to use bazelisk to manage different versions of bazel. On Linux, You can download Bazelisk binary on our Releases page and add it to your PATH manually, which also works on macOS and Windows. You can download the newest bazelisk binary from its official github release page.
The following is an example of downloading and setting up bazelisk v1.20.0, you may change the tag v1.20.0 to any latest version, or any version you prefer.
# If you use a x86 architecture cpu
$ wget https://github.com/bazelbuild/bazelisk/releases/download/v1.20.0/bazelisk-linux-amd64
$ mv bazelisk-linux-amd64 bazelisk && chmod +x bazelisk
$ sudo mv bazelisk /usr/local/bin # you need sudo to do this
# If you use an arm architecture cpu
$ wget https://github.com/bazelbuild/bazelisk/releases/download/v1.20.0/bazelisk-linux-arm64
$ mv bazelisk-linux-arm64 bazelisk && chmod +x bazelisk
$ sudo mv bazelisk /usr/local/bin # you need sudo to do thisTo build Yacl, at yacl's root directory, run the following
$ bazelisk build //yacl/...
$ bazelisk build //yacl/... -c opt # build as optimized mode
$ bazelisk build //yacl/... -c dbg # build as debug mode
$ bazelisk build //yacl/... --config gm # build with gm modeTo test Yacl
$ bazelisk test //yacl/...First you need to download XCode and homebrew,
# Install Xcode
$ https://apps.apple.com/us/app/xcode/id497799835?mt=12
# Select Xcode toolchain version
$ sudo xcode-select -s /Applications/Xcode.app/Contents/DeveloperThen download the dependencies,
# Install dependencies
$ brew install bazelisk cmake ninja nasm automake libtool libompTo build Yacl, at yacl's root directory, run the following
$ bazelisk build //yacl/...
$ bazelisk build //yacl/... -c opt # build as optimized mode
$ bazelisk build //yacl/... -c dbg # build as debug mode
$ bazelisk build //yacl/... --config gm # build with gm modeTo test Yacl
$ bazelisk test //yacl/...$ cd docs
$ pip install -r requirements.txt
# build English docs
$ make clean && make html # html docs will be generated in _build/html
# build Chinese docs
$ make clean && make -e SPHINXOPTS="-D language='zh_CN'" html # html docs will be generated in _build/htmlLanguage servers accept a compile_commands.json file input to help it with linting, jumping to definitions/references, and other functions. This file consists of an array of “command objects”, where each command object specifies one way a translation unit is compiled in the project. A lot of modern C/C++ build system can generate this file with simple steps, it's the same for bazel.
$ git clone https://github.com/secretflow/devtools.git ../devtools
$ python3 ../devtools/refresh-compile-command-bazel-module.pyWe recommend to use the following extensions for vscode users: