Skip to content

Files

Latest commit

e969626 · Jul 15, 2021

History

History
63 lines (39 loc) · 1.5 KB

README.md

File metadata and controls

63 lines (39 loc) · 1.5 KB

Bazel clang cpp example

Here is the summary of what I learned while using bazel build system with cpp & clang 12.

I have build on WSL2 ubuntu 20.04 with Clang-12 Compiler.

Build

Build with Clang-12.

foo@bar:cpp-tutorial/stage1$ bazel build --config=clang_config  //main:hello-world

Test

Test with uftrace and valgrind.

Install uftrace and valgrind in ubuntu.

foo@bar:~$ sudo apt -y install uftrace valgrind

uftrace

Test hello-world program with uftrace in terminal.

foo@bar:cpp-tutorial/stage1$ uftrace ./bazel-bin/main/hello-world

valgrind

Test hello-world program with valgrind in terminal.

foo@bar:cpp-tutorial/stage1$ valgrind ./bazel-bin/main/hello-world

lint

Install cpplint.

foo@bar:~$ sudo apt -y install python3  && pip install cpplint
foo@bar:~$ echo "export PATH=\$PATH:\$HOME/.local/bin" >> .bashrc && source .bashrc

And do lint.

foo@bar:cpp-tutorial/stage1$ cpplint main/hello-world.cc

Reference

Installing Bazel on Ubuntu

Bazel Tutorial: Build a C++ Project

Bazel Tutorial: Configure C++ Toolchains

Bazel command line options