Skip to content

Commit

Permalink
chore: use bazelisk in GETTING_STARTED.md (#476)
Browse files Browse the repository at this point in the history
  • Loading branch information
tongke6 authored Feb 25, 2025
1 parent 4c529a6 commit 6bc36b1
Showing 1 changed file with 16 additions and 17 deletions.
33 changes: 16 additions & 17 deletions GETTING_STARTED.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,28 +38,28 @@ The following is an example of downloading and setting up bazelisk v1.20.0, you
```sh
# 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
$ 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 bazel && chmod +x bazel
$ sudo mv bazel /usr/local/bin # you need sudo to do this
$ mv bazelisk-linux-arm64 bazelisk && chmod +x bazelisk
$ sudo mv bazelisk /usr/local/bin # you need sudo to do this
```

To build Yacl, at yacl's root directory, run the following

```sh
$ 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
$ 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 mode
```

To test Yacl

```sh
$ bazel test //yacl/...
$ bazelisk test //yacl/...
```

### MacOS
Expand All @@ -84,26 +84,25 @@ $ brew install bazelisk cmake ninja nasm automake libtool libomp
To build Yacl, at yacl's root directory, run the following

```sh
$ 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
$ 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 mode
```

To test Yacl

```sh
$ bazel test //yacl/...
$ bazelisk 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.

```sh
$ 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)
$ git clone https://github.com/secretflow/devtools.git ../devtools
$ python3 ../devtools/refresh-compile-command-bazel-module.py
```

## (Optional) Recommended vscode extensions
Expand Down

0 comments on commit 6bc36b1

Please sign in to comment.