Method Two

Method Two

Sometimes a custom build step, build event or a build tool can be further broken down to smaller tasks, and parallelized to achieve further acceleration.

This method can be used in Visual Studio versions 2010 and higher, and allows the distribution and parallelization of the contents of the build steps, on the process level.

This feature is only available in scenarios where:
1. The IncrediBuild predicted feature (on by default) is not turned off.
2. The IncrediBuild UseMSBuild directive is not used.
3. The build is not executed with "build regardless of errors".

Example 1: If within a custom step a user executes a complete Make command that builds a complete project, you can instruct IncrediBuild to highly accelerate your Make command execution by using the IncrediBuild Make and Build Tools package. Instead of treating the Make command as a single task, IncrediBuild will instead “break” this command to its sub-tasks and will execute the compilation in a parallel and distributed manner.

Example 2: In the case that you have a custom step, which has a tool that runs many rendering commands, you can use Profile XML not only to distribute the rendering but also to intercept the tool that spawns the rendering processes. In this case, you can expand IncrediBuild’s Profile XML, as described below, to control and also accelerate and distribute custom steps, rules, and events.

You can integrate Profile XML file into Visual Studio 2010 and later, provided that you have the appropriate package (Dev Tools (see IncrediBuild for Dev Tools) or Make and Other Build Tools (see IncrediBuild for Make and Other Build Tools)). Integrating Profile XML enables you to have complete control on the way IncrediBuild treats the custom tools.

By default, custom steps, exec tasks, and special build tools are not distributed to remote agents.
In order to allow IncrediBuild to distribute and manage these tasks, an XML file should be used based on IncrediBuild's Automatic Interception interface.
There are two ways in which a profile.xml file can be used in order to manage such tasks:

1.     In the IncrediBuild BuildConsole command, use the /profile directive to specify a profile for IncrediBuild to use: /profile=[profile_file_name].xml (without the square brackets characters).

2.     If you are building from within the Visual Studio IDE or would like your solution to have a default profile to use, per solution, create [solution_folder]\[solution_name].ib_profile.xml profile xml file This profile will be automatically loaded by IncrediBuild in case that no profile file was specified with the /profile=[profile_file_name].xml switch.

The following XML file instructs IncrediBuild to distribute every "gawk" task that is executed by the build. Note that even though the real file is "gawk.exe", we do not specify the file extension:

<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
<Profile FormatVersion="1">
<Tools>
<Tool Filename="gawk" AllowRemote="true" />
</Tools>
</Profile>

Note: If your Custom Build Steps and Build Events appear as a single task (single bar in the build monitor labeled “IBCustomStep” ) after adding the profile.xml file, please change the registry value CustomStepVs10Support from the default “1” to “0” under the HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Xoreax\IncrediBuild\Builder registry key.

Parallelization of Custom Build tools and custom build rules using the .ib_profile.xml

Visual Studio 2010 and newer versions use the MSBuild engine which executes all custom build tools and custom build rules within the context of a single project in a sequential  manner – on a single CPU core

For example, in the following scenario: A custom build tool running moc.exe (as in the GUI SDK QT) will be executed in a sequential manner in project A for each file that needs to be generated.

Specifying in your IncrediBuild profile a tool name (the process name – moc.exe) with the AllowPredictedBatch option will instruct IncrediBuild to execute these moc tools in parallel resulting in a significant performance boost.

Since the tool will run in a parallel manner, it can also be configured to be distributed to remote machines (please see XML sample below).

Note that the tools that can be safely accelerated with this feature must have the following characteristics:

1)      Two Instances of the executable will not attempt to write to the same file (e.g. output file, log file)

2)      None of the instances of the executable should be dependent on anything that the other instances do. (e.g one instance does not depend on the output file of another instance, none of the instances deletes any files or folders the other instances use).

Parallelization will be applied on the defined tools up to the point where a different executable will be invoked (CL, LINK or anything else).

To use the feature add AllowPredictedBatch="true" tool tag to your solution’s .ib_profile.xml

Usage Example:

If your solution name file is my_solution.sln, and you would like to parallelize and distribute moc.exe execution, add the file my_solution.ib_profile.xml to the folder where my_solution.sln resides – this will apply the profile to any build of this solution ran from within the IDE. Alternatively, if building from the command line, you can use the “/profile” switch to specify the profile file:

Buildconsole my_solution.sln /rebuild /cfg=”debug|win32” /profile=”my_solution.ib_profile.xml”

Example contents of my_solution.ib_profile.xml:

<?xml version="1.0" encoding="UTF-8" standalone="no" ?>

<Profile FormatVersion="1">

  <Tools>

    <Tool Filename="moc" AllowRemote="true" AllowPredictedBatch="true"/>

  </Tools>

</Profile>