Generate files from a YAML configuration file

barectf ships with the barectf command-line interface (CLI) tool.

The barectf CLI tool has a command interface, like Git.

This page focuses on the barectf generate command. See barectf CLI tool usage for the complete CLI tool’s documentation.

Generate files from a YAML configuration

Use the barectf generate command to generate files from a barectf YAML configuration file:

$ barectf generate my-config.yaml

On success, this command writes the following files to the current working directory:

File name Description

metadata

The CTF metadata stream file.

You’ll need to place this file in a directory with the data stream files which your application will write through the generated tracer.

See How barectf works to learn more.

barectf.h

The generated tracer’s public C header file.

This header contains the prototypes of the packet opening, packet closing, and tracing functions.

barectf generates one packet opening/closing function per configured data stream type and one tracing function per configured event record type.

Your application and platforms need to include this file.

barectf-bitfield.h

Internal macros for the generated tracer (included by barectf.c).

barectf.c

The generated tracer’s C source code.

Those file names assume that my-config.yaml uses the default prefixes.

Use dedicated output directories

Because the metadata file which barectf generates is part of an eventual CTF trace, you’ll probably want to make barectf write it to its own directory.

Use the barectf generate command’s --metadata-dir option to specify the metadata file’s output directory:

$ barectf generate my-config.yaml --metadata-dir=my-trace

barectf generate also offers the --code-dir and --headers-dir options to select the output directories of the generated tracer source file and headers.

Control inclusions

Set the most significant inclusion search directories with the barectf generate command’s --include-dir option. You can use the option more than once:

$ barectf generate my-config.yaml \
                   --include-dir=/path/to/project/barectf \
                   --include-dir=/path/to/base/barectf

By default, if barectf generate can’t find an inclusion file, it prints an error and exits with a non-zero status.

However, it’s possible that some YAML file A includes a file B which barectf can’t find, but A doesn’t need anything from B.

Force barectf generate to continue silently instead with its --ignore-include-not-found option:

$ barectf generate my-config.yaml --ignore-include-not-found \
                   --include-dir=/path/to/project/barectf \
                   --include-dir=/path/to/base/barectf \