How do I save dcu files in my project folder (eg .. \ $ (Platform) \ $ (Config) \ $ (ProjectFilename)?

I have many Delphi projects in a project group. I can install Unit output directory

in .\$(Platform)\$(Config)

and all dcu files will be stored in the directory according to the values platform

and config

.

In my build environment, I would like to install Unit output directory

to something like .\$(Platform)\$(Config)\$(ProjectFilename)

, so all DCU files must contain their own directory, identified by the current project file.

Build events in Project | Options

have a macro $(ProjectFilename)

, but I cannot use it in Unit output directory

.

I want to install .\$(Platform)\$(Config)\$(ProjectFilename)

for all projects Unit output directory

and it will save all DCU files in a unique project directory.

+3


source to share


2 answers


I found this answer by coincidence. I pick one project and (ms) build with verbosity diagnostic

. Examining the output msbuild

, I simply select the variable: MSBuildProjectName

and specify in my file optset

, which is divided into 300 projects:

<DCC_DcuOutput>.\$(Platform)\$(Config)\$(MSBuildProjectName)</DCC_DcuOutput>

      



And I am trying to create all projects in the IDE. Surprisingly, Delphi

create folders for each project and save the DCU files in folders accordingly.

+6


source


Build Events pre-processors support a number of macros, some of which are equivalent to some environment variables.

The DCU Output folder option only supports environment variables , not these macros.

Possible alternative approach

To get the DCU folder for each project, you can use a different approach by entering the dcu subfolder of the current project, for example:

Unit Output Directory: .\dcu

      

(or maybe just "dcu", but I prefer to include "." if only to make it clear that the relative setting is intentional)

This keeps the DCUs separate for each project, but means you no longer have DCUs in a separate location outside of the project folder.



Of course, you can use the $ (platform) and $ (config) variables in this relative path if that's important to you:

Unit Output Directory: .\dcu\$(platform)\$(config)

      

If this is an acceptable compromise, you can only say in your situation.

Often the intent to store the DCU in a location other than the project folder is:

  • save project folder "clean"

  • no need to maintain a long list of "ignore" entries for every dcu file in VCS (SubVersion / Git, etc.)

Storing the DCU in a project subfolder achieves the first of these, and the second problem is greatly simplified by the fact that you can add only the DCU subfolder to the VCS ignore list to ignore any file in that DCU folder.

+1


source







All Articles