Skip to content

ci: update readme with how to setup bazel #31

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 15, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 32 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,38 @@

# Table of Contents

1. [Tooling](#1-tooling)
- [Clang-Tidy](#11-clang-tidy)
- [Clang-Tidy Analysis](#111-clang-tidy-analysis)
- [Automatic Fixes Locally](#112-automatic-fixes-locally)
- [Clang-Format](#12-clang-format)
- [Clang-Format Analysis](#121-clang-format-analysis)
- [Automatic Fixes Locally](#122-automatic-fixes-locally)
- [Bazel Buildifier](#13-bazel-buildifier)
- [How to Run](#131-how-to-run)
- [1. Tooling](#1-tooling)
- [1.1. Bazel](#11-bazel)
- [Setup](#111-setup)
- [Test Run](#112-test-run)
- [1.2. Clang-Tidy](#12-clang-tidy)
- [Clang-Tidy Analysis](#121-clang-tidy-analysis)
- [Automatic Fixes Locally](#122-automatic-fixes-locally)
- [1.3. Clang-Format](#13-clang-format)
- [Clang-Format Analysis](#131-clang-format-analysis)
- [Automatic Fixes Locally](#132-automatic-fixes-locally)
- [1.4. Bazel Buildifier](#14-bazel-buildifier)
- [How to Run](#141-how-to-run)

# 1. Tooling

## 1.1. Clang-Tidy
## 1.1. Bazel

## 1.1.1 Setup

Follow step 1 and 2 of bazel documentation: <https://bazel.build/install/ubuntu>

## 1.1.2 Test Run

```bash
bazel run //examples/cpp:bin
```

## 1.2. Clang-Tidy

Clang-Tidy is a static analysis tool for C++ code. It helps identify potential issues, enforce coding standards, and suggest improvements to your code. This section describes how to integrate and use Clang-Tidy with your project for both analysis and automatic fixes.

### 1.1.1. Clang-Tidy Analysis
### 1.2.1. Clang-Tidy Analysis

To run Clang-Tidy analysis on your codebase using Bazel, execute the following command:

Expand All @@ -31,7 +46,7 @@ bazel build //... \

The checks are define on .clang-tidy file.

### 1.1.2. Automatic Fixes Locally
### 1.2.2. Automatic Fixes Locally

To automatically apply fixes suggested by Clang-Tidy, follow these steps:

Expand All @@ -58,11 +73,11 @@ To automatically apply fixes suggested by Clang-Tidy, follow these steps:
Runs Clang-Tidy on each file using the compile_commands.json for accurate analysis.
Applies any fixes Clang-Tidy suggests (e.g., code style corrections, best practice recommendations).

## 1.2. Clang-Format
## 1.3. Clang-Format

Clang-Format is a tool that automatically formats C++ source code according to a set of predefined or custom style rules. Below are instructions for running Clang-Format analysis and applying automatic fixes to your code locally.

### 1.2.1. Clang-Format Analysis
### 1.3.1. Clang-Format Analysis

To check the formatting of your code without making any changes, use the following command. It will run `clang-format` in "dry-run" mode, which simulates formatting and reports any issues without modifying files.

Expand All @@ -74,17 +89,17 @@ find . -name "*.cpp" -o -name "*.h" -o -name "*.hpp" -o -name "*.cc" -o -name "*
- `-name` "*.cpp" -o -name "*.h" ... ensures all common C++ file extensions are included.
- `xargs clang-format --dry-run --Werror` applies clang-format to the found files, in "dry-run" mode (no changes are made), and treats any formatting violations as errors (--Werror).

### 1.2.2. Automatic Fixes Locally
### 1.3.2. Automatic Fixes Locally

To automatically fix the formatting of your code based on the predefined style, you can use the following command. It will rewrite the files in-place according to Clang-Format's rules.

```bash
find . -name "*.cpp" -o -name "*.h" -o -name "*.hpp" -o -name "*.cc" -o -name "*.cxx" -o -name "*.hxx" | xargs clang-format -i
```

## 1.3. Bazel Buildifier
## 1.4. Bazel Buildifier

### 1.3.1. How to Run
### 1.4.1. How to Run

`Buildifier` is a tool for formatting Bazel build files (e.g., `BUILD`, `WORKSPACE`). It automatically reformats these files according to a consistent style, improving readability and maintaining consistency across your project.

Expand Down
Loading