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.
- gcc >= 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.git
The building process of YACL is as following.
Download the dependencies
$ sudo apt install gcc wget cmake ninja-build nasm automake libtool libomp-dev
We 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 bazel && chmod +x bazel
$ sudo mv bazel /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 bazel && chmod +x bazel
$ sudo mv bazel /usr/local/bin # you need sudo to do this
To build Yacl, at yacl's root directory, run the following
$ bazel build //yacl/...
$ bazel build //yacl/... -c opt # build as optimized mode
$ bazel build //yacl/... -c dbg # build as debug mode
$ bazel build //yacl/... --config gm # build with gm mode
To test Yacl
$ bazel 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/Developer
Then download the dependencies,
# Install dependencies
$ brew install bazelisk cmake ninja nasm automake libtool libomp
To build Yacl, at yacl's root directory, run the following
$ bazel build //yacl/...
$ bazel build //yacl/... -c opt # build as optimized mode
$ bazel build //yacl/... -c dbg # build as debug mode
$ bazel build //yacl/... --config gm # build with gm mode
To test Yacl
$ bazel test //yacl/...
Language 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.
$ sudo apt install curl
$ cd /path/to/yacl/ # change to yacl path
$ bash <(curl -s https://raw.githubusercontent.com/secretflow/devtools/9efb0bc93068a122864fdb661946695badacbe24/refresh_compile_commands.sh)
We recommend to use the following extensions for vscode users: