No more SYNCHRONIZE_DRAIN!

Most BSPs use the SYNCHRONIZE_DRAIN and SYNCHRONIZE_BLOCK macros to serialize the build process on multiprocessor machines. Since almost all machines are multi-processor (or hyperthreading) nowadays, these macros really have to be used.

SYNCHRONIZE_DRAIN and SYNCHRONIZE_BLOCK work on the entire build tree, so if module "A" has the SYNCHRONIZE_DRAIN macro set in its sources file this module won't be build until all other modules in the entire build tree have been built, even if module "A" was only depending on one other module.

You can see that the brute force method of SYNCHRONIZE_DRAIN and SYNCHRONIZE_BLOCK can really slow down your build performance.

Luckily, there are some better macros we can use that provide a much more granular method of serializing the build system: BuildPassName_PRODUCES and BuildPassName_CONSUMES. These macros are now finally well documented in MSDN for WEC2013.

The usage of these macros is very easy and better to understand than the SYNCHRONIZE_DRAIN and _BLOCK macros:

The directory with a Sources file that contains a BuildPassName_PRODUCES macro with a particular value will be built before any directories with a corresponding BuildPassName_CONSUMES macro value. This build order happens regardless of the directories' position in the Dirs File.

In other words:

If module "A" needs module "B" to link, then module "B" has to add LINK_PRODUCES=B to its sources file and module "A" has to add LINK_CONSUMES=B to its sources file. This way module A won't be linked to module B before module B is built but any other non-dependent modules will continue to build in parallel. Easy as that!

You can specify multiple modules by separating them with a space:

LINK_CONSUMES=A B C D

Make sure to use unique names throughout your BSP tree, or build errors will result.