3.1.4. Waf Tool Clang Format

The tool is located in tools/waf-tools.

3.1.4.1. Tool Documentation

Implements a waf tool to run clang-format.

Listing 3.12 shows how to use this tool.

Listing 3.12 f_clang-format.py
1
2
3
4
5
6
7
8
9
def options(opt):
    opt.load("clang_format")

def configure(conf):
    conf.load("clang_format")

def build:
    files = bld.path.ant_glob("\*\*/\*.c")
    bld(features="clang-format", files=files)
class f_clang_format.clang_format(*args: Any, **kwargs: Any)

Bases: waflib.Task.

Task to run clang-format on all given source files

color = 'BLUE'

color in which the command line is displayed in the terminal

Type

str

f_clang_format.configure(conf)

configuration step of the clang-format tool

  • searches for the program clang-format

  • applies configured options

f_clang_format.options(opt)

Passing options to clang-format

f_clang_format.process_clang_format(self)

creates clang-format task for each input source