Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Reverted from v. 8(CHIANA CASE)

...

Section


Column


Table of Content Zone
locationtop

注意Note:

本节内容与
  • This section is relevant for VS 2008
及更低版本相关。

IncrediBuild 可同时构建多个文件,甚至是多个项目。 因此,必须正确定义Solution/工作区中文件和项目之间的依赖项,以避免构建中的潜在问题和错误。

本节对您可能遇到的依赖关系问题进行了回顾。 请仔细阅读本文,以节省您在后期阶段解决依赖关系相关问题将需要的大量时间。

项目级依赖项

源文件依赖项

源文件的文件依赖项由 IncrediBuild 自动处理。 运行增量构建仅会编译过时的文件,或引用过时的文件(例如使用“#include”或“#import”语句)。

预编译标头

使用预编译标头的所有文件在构建完预编译标头之前不会开始编译。 请注意,如果使用预编译标头的 MSVC 默认选项被保留在项目中,但 stdafx.h 几乎为空,则建议从项目中删除 stdafx.cpp 并将项目设置设置为“Not using precompiled headers”。

Solution/工作区级依赖项

您可以使用“Project”菜单中的“Dependencies...”命令来定义Solution/工作区中项目之间的依赖项。 在定义项目间依赖关系时,需要特别注意以下情况:

链接依赖项

与Solution/工作区中的其他项目生成的库相链接的项目必须将这些项目作为子项目包括在内,以避免在其中一个 LIB 文件准备就绪之前启动链接阶段。 请注意,在 MSVC 构建中可正确构建的Solutions和工作区可能因为缺少此类依赖关系声明而在 IncrediBuild 构建失败。

MIDL、自定义、预链接、构建后和预构建步骤

包含将会影响Solution/工作区中另一个项目的编译的构建步骤的项目必须作为受影响项目的子项目包含在内。 此类步骤的常见示例是代码生成工具(如 YACC 和 LEXX),以及将输出文件复制到另一个项目使用的位置的步骤。 另一种常见情况是源文件包含对 MIDL 编译器(TLB 文件、标头文件等)在另一个项目中生成的文件的预处理引用。 如果Solution/工作区未正确定义两个项目之间的依赖关系,则编译器可能使用不正确的文件版本或因编译错误而失败。

关于构建速度以及使用自定义、预链接、构建后和预构建步骤的注释:
请考虑以下情况:项目 B 是项目 A 的子项目,并包含项目级自定义构建步骤、预链接步骤或构建后步骤。因此,在项目 B 的步骤执行完成之前,项目 A 不会开始编译。 虽然这确保了项目能被成功构建(只要正确定义了依赖项),但如果项目 A 的源文件不需要项目 B 的步骤,它也可能无理地减慢构建速度。 在这种情况下,使用 IncrediBuild_AllowOverlap 指令将指示 IncrediBuild 不推迟项目 A 的编译。

Column
Div
VS 2008 及更低版本
  • and earlier.

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 compileuntil 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.



Column


Div

Visual Studio 2008 and Earlier:

Child pages (Children Display)
styleh4
pageVisual Studio 2008 and Earlier及更低版本

IncrediBuild Solutions 简介:

Child pages (Children Display)
styleh4
pageIncrediBuild Solutions

用户手册User Manual:

Child pages (Children Display)
styleh4
pageIncrediBuild Windows User Manual用户手册