Skip to content

Latest commit

 

History

History
113 lines (79 loc) · 4.06 KB

GETTING_STARTED.md

File metadata and controls

113 lines (79 loc) · 4.06 KB

Getting Started

This document includes guidelines.

Prerequisites

To build Yacl from source, you will need the following tools:

Download and build

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.

Ubuntu

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/...

MacOS

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/...

Setup compilation database for your lsp

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)

(Optional) Recommended vscode extensions

We recommend to use the following extensions for vscode users:

  • Bazel: Bazel BUILD integration
  • clangd: C/C++ completion, navigation, and insights
  • cpplint: code style check tool extension for cpplint (requires cpplint binary)