Example: Caching temporary source files
The Windows DDK (Driver Development Kit) suggests that you use a Build Utility to compile and link the provided source code:
The Build Utility generates temporary source files and uses them to create a precompiled header (PCH) for a specific project. When generation of the precompiled header is complete, the temporary source files are deleted.
Let's say you are building a project, test, with the precompiled header, test.h. The Build Utility creates a temporary source file named pch_hdr.src:
-- file: pch_hdr.src #include "test.h"
This file is used as an input to the compiler to generate the precompiled header test.pch, and is then deleted.
kwinject and kwwrap intercept this kind of compiler call and write an appropriate record to the build specification. The problem is that when your build is complete, the generated build specification references a nonexistent source file. Hence, if you try to generate a build specification, or directly use the build specification to run the build, you will not be able to access this type of source file, and your Klocwork analysis will fail.
To resolve this issue, kwinject has a cached sources mechanism. Use the --cache-files <pattern>[,<pattern>...] option of kwinject. This option will restore source files matching any of the specified patterns to their original location. For example:
kwinject --cache-files "*.src" build -zcg