10
votes

Currently I have not set any specific output directory for Delphi DCUs in my main project. This results in the DCU files ending up in the same directory as my .pas source files. To me, this feels ugly as I don't like the idea of mixing .pas and .dcu files in the same directory. What is the best practice for storing Delphi .dcu files - keep them all one directory for each project? Or maybe create one DCU directory for each source folder? Any ideas welcome.

3

3 Answers

8
votes

The best way to do it is to create a DCU folder for each project, especially if you have more than one project that uses the same files. Otherwise, you can end up with different compiles with different compiler settings stomping each other's DCUs.

0
votes

.dcu's are also dependant on defines, and e.g. debugging vs release configuration (*).

(*) While Delphi XE allows to put the "configuration" in the output path, IMHO that cure is worse than the problem

So I regularly recursively delete all .dcu's from the root of the dir where I do all my SVN checkouts.

The directory with components has a delphi version suffixed, and is outside the SVN checkout directory.

0
votes

Agreed...mixing PAS and DCU files in the same directory is 'dirty'.

Whenever you start a new application, dll, or other Delphi project, one of the first things to do is to set the output directory. In later versions of Delphi this is done for you as the output directory is set as .\$(Config)\$(Platform) which correlates to the Debug or Release config option and Win32 platform. (Ending up with a default output directory of Debug\Win32)

If you build with custom compiler defines then it would be wise to have different project build options to include separate output directories for each set of custom compiler defines otherwise you have to do a full build to ensure that units are built correctly.