Kwbazel
The kwbazel build integration command allows Linux users to analyze projects built with the Bazel build system. kwbazel is an executable shell script that runs the Bazel build and generates trace and build specification files (kwinject.trace and kwinject.out).
Prerequisites
-
To use kwbazel, install Bazel and the Klocwork command line tools.
-
Ensure that source compilation with Bazel works fine by executing
bazel build <target>
. -
Run kwbazel from a Bazel workspace directory (directory where ROOT workspace file is present).
Limitations
-
Kwbazel is only compatible with Linux operating systems.
-
Kwbazel does not support remote execution, it exclusively facilitates local builds.
-
Kwbazel supports the default mnemonics for building C/C++, Java, and C# code. Other programming languages are not supported.
-
Custom mnemonics are supported via explicit options in Kwbazel.
-
Kwbazel does not monitor other build systems, such as make or CMake, invoked by Bazel. For such scenarios, consider using Kwinject for your build integration.
-
Kwbazel snould not be used with Android Bazel builds (Kleaf). For Android Bazel builds, use Kwandroid with the --bazel option instead.
Usage
kwbazel --bazel_version <version> --target <bazel_target> --klocwork_path <path_directory> [--arguments <bazel_arguments>] [--lang <language>]
- <version> specifies the version of Bazel. The string bazel is also accepted
- <bazel_target> specifies the build target
- <path_directory> specifies the Klocwork output directory
- Optional: <bazel_arguments> specifies the arguments used to run the build
- Optional: <language> specifies the language option to separate the build for C/C++, C#, and Java
Options
Name (and short name) | Description |
---|---|
--bazel_version (-b) <version> | specifies the version of Bazel. If a single Bazel version is installed, use the string bazel. If multiple versions are installed, specify the version. Example: --bazel_version bazel-6.4.0 You can check your Bazel version in /usr/bin or /usr/local/bin |
--klocwork_path (-o) <path_directory> | specifies Klocwork output directory. kwinject.trace and kwinject.out will be created inside this directory |
--target (-t) <bazel_target> |
specifies the build target. Example: -t //:hello_bazel For multiple targets, run -t "//:hello_bazel hello_klocwork" |
Optional arguments
Name (and short name) | Description |
---|---|
--arguments (-a) <bazel_argument> | specifies Bazel arguments. Example: --arguments "--spawn_strategy=linux-sandbox --sandbox_debug" |
--custom_mnemonics <string> | specifies use of custom mnemonics created by the user. Example: --custom_mnemonics mnemonic1 mnemonic2 mnemonic3 |
--lang (-l) <language> | specifies the language option to separate the build for C/C++ (cxx), C# (csharp), and Java (java). Default is cxx,csharp,java |
Optional kwinject arguments
Name (and short name) | Description |
---|---|
--config (-c) <file> | read filter configuration from <file>. The default is <Klocwork_install>/config/kwfilter.conf. Allows you to use a "private" copy of kwfilter.conf and the compiler configuration files, so that the originals do not need to be modified. |
-f <variable_file> | read variables from a specified file |
--ignore-files (-I)<pattern>[,<pattern>...] | ignore source files that match one of the specified patterns. <pattern> may contain the * and ? wildcards. For example: --ignore-files conftest.* specifies that temporary files created by the configure script will be ignored. |
--no-config | do not read filter configuration from compiler mapping file, kwfilter.conf |
--no-resolve | do not resolve symbolic links. When the --no-resolve option is specified, it does not resolve paths in compiler options. |
--prog (-P) <prog>[=<filter>][,<prog>[=<filter>]...] |
the program or programs kwinject should use to intercept programs, if you want to use something other than the compilers searched for by default. Specify the comma-separated list of programs to intercept, along with the appropriate filter to use. The default list of known programs and their filters is taken from the compiler mapping file, kwfilter.conf. The filter bindings defined through this option override any bindings read from a compiler filter file. |
--variable (-V) <variable>=<string> | replace every occurrence of <string> in the output file with a reference to <variable> instead. |