Format of the build specification file for C/C++ projects

The Klocwork build specification for C/C++ projects, called kwinject.out by default, is a text file in semicolon-separated format.

The first field is a tag to identify the type of line. The possible tags are as follows:

Tag Description
version build specification format version
compile used to track compiler execution
link used to track linker/librarian execution, that is, how executables/libraries are created
config user compiler configuration

version line

The version line is used to define the build specification format version. It must be the first line in the build specification. Only one version line may appear in a build specification.

Example version line:
version;108

The three-digit integer is used to encode the version. The first (left-most) digit encodes the major version ("1" in above example); the last two digits encode the minor version ("08" in above example, resulting in the "1.8" full version code).

Version 1.4 or later indicates that the build specification was generated using a source encoding of UTF-8, allowing multibyte characters (for example, Japanese). To ensure that kwbuildproject processes the build specification with UTF-8 encoding, the version must be version;104 or later.

compile line

Compile lines are used to track compiler execution.

Example compile line:
compile;/tmp/zlib-1.2.2;/usr/bin/gcc;/tmp/zlib-1.2.2/example.o;example.c;-DUSE_MMAP

The fields are:

Field Description
"compile" tag tag for compilation lines
work directory current working directory at linker execution time (/tmp/zlib-1.2.2 in the above example)
compiler full path to user compiler executable (for example, /usr/bin/gcc)
output file name of the "native" object file (for example, /tmp/zlib-1.2.2/example.o)
source file name of the source file (for example, example.c)
compiler flags extra compiler options, separated by semi-colon; generally a list of include directories and macro definitions (for example, -DUSE_MMAP)

link lines

Link lines are used to track linker execution, that is, how executables/libraries are created.

Example link line:
link;/tmp/zlib-1.2.2;/tmp/zlib-1.2.2/example;/tmp/zlib-1.2.2/example.o;/tmp/zlib-1.2.2/libz.a

The fields are:

Field Description
"link" tag tag for link lines
work directory current working directory at compiler execution time (/tmp/zlib-1.2.2 in the above example)
output file name of the executable or library (for example, /tmp/zlib-1.2.2/example)
object files semi-colon-separated list of object files and/or libraries linked into executable/library (for example, /tmp/zlib-1.2.2/example.o;/tmp/zlib-1.2.2/libz.a)

config line

The config line is used to record the list of defines and include directories implicitly used by the native compiler. This line is optional, but in order to obtain an accurate analysis, system defines and includes must be specified.

Example config line (truncated):
config;/usr/bin/gcc;-e;gnu;-DGNUC=3;...;-J/usr/include;...

The fields are:

Field Description
"config" tag tag for config lines
compiler path to compiler (for example, /usr/bin/gcc )
flags a list of semicolon-separated compilation options to be passed to the Klocwork compiler. The listed flags will be automatically added to every compile command line using the same compiler.