Dependency Issues

Dependency Issues

Note:

IncrediBuild builds several files and even several projects concurrently. Therefore, it is essential to correctly define the dependencies between files and projects in your solution/workspace, in order to avoid potential problems and errors in your build.

This section provides a review of dependency issues that you may come across. Reading this carefully may save you considerable time troubleshooting dependency-related problems at a later stage.

Project-Level Dependencies

Source file dependencies

File dependencies for source files are automatically handled by IncrediBuild. Running an incremental build only compiles files that are either directly out of date, or references a file (using an #include or an #import statement, for example) that is out of date.

Precompiled headers

All files using a precompiled header do not start compiling before the precompiled header has been built. Note that if MSVC's default option of using a precompiled header was kept in your project, but stdafx.h is practically empty, it is recommended to remove stdafx.cpp from the project and set the project settings to "Not using precompiled headers".

File-level custom build steps

File-level custom build step definitions always specify one or more output files. If your project contains a file-level custom build step that generates files referenced by source files in that project, it is essential that all of the files generated by that step be included in its output file list.
Consider the following example scenario: The file "my.cpp" #includes the header file "lang.h". "lang.h" is generated by a custom build step defined for another file, "lang.y". The custom build step has not defined "lang.h" as an output file. Consequently, IncrediBuild may start compiling "my.cpp" on a remote Agent before the custom build step "lang.y" has completed, resulting in either a "file not found" compilation error or, worse still, an old version of "lang.h" being used in the compilation.

Sometimes you may want to force one of the file-level custom build steps in a project to run before others. To do this, use the incredibuild_RunFirst directive.

Solution/Workspace-Level Dependencies

Dependencies between projects in a solution/workspace can be defined using the "Dependencies..." command in the Project menu. The following cases require special attention when defining inter-project dependencies:

Link dependencies

Projects that link with libraries generated by other projects in the solution/workspace must include these projects as sub-projects, to avoid starting the link phase before one of the LIB files is ready. Note that solutions and workspaces that build correctly in MSVC builds may fail when built with IncrediBuild because of missing dependency declarations of this sort.

MIDL, custom, pre-link, post-build, and pre-build steps

Projects containing build steps that affect compilation of another project in the solution/workspace must be included as sub-projects of that project. Common examples for such steps are code-generation tools such as YACC and LEXX, and steps that copy output files to a location used by another project. Another common case is when a source file contains preprocessor references to files generated by the MIDL compiler (TLB files, header files, etc.) in another project. If the solution/workspace does not correctly define the dependency between the two projects, the compiler may use an incorrect version of the file or fail with a compilation error.

A note concerning build speed and the use of custom, pre-link, post-build, and pre-build steps:
Consider the following case: Project B is a sub-project of project A, and contains either a project-level custom build step, a pre-link step, or a post-build step. Consequently, project A does not start to compile until project B's step has been performed. While this ensures that projects are successfully  built as long as dependencies have correctly been defined, it may also unjustifiably slow down the build if project B's step is not required by project A's source files. In this case, using the IncrediBuild_AllowOverlap directive instructs IncrediBuild not to postpone project A's compilation.