views:

174

answers:

2

I would like to know, is there a way to automatically make the IDE/Compiler/other copy all the resource that needs to be linked with the DCU to the DCU output folder.

I often use forms that I pre-compile to avoid the needs to recompile the unit all the time in my main projects. The DCU gets updated, but we need to copy the DFM manually everytime it changes. Same goes for any {$R *.res} specified. Maybe we could maintain those file directly in the DCU folder... but doesn't quite make sense to have a .DFM in a different folder than a .PAS

I looked for a compiler switch that would do it... Unsuccesfully.

Anyone knows if/how it can be achieved?

I'm using Delphi 2010

+4  A: 

You could create a simple Post Build event which performed the copying. That way whenever you did a build, the system would copy the necessary files for you. The build events are available from the Project Options menu, there is a Pre-build and a Post-Build script.

skamradt
Well, if you have a MSBUILD based version (D2007+?) that is.
Marco van de Voort
I didn't tinker with those events yet. I thought about it, but am I right to assume that for every {$R MyFile.res} I will need to manually add it to the script... or is there a way I could enumerate all $R files in the script?
Ken Bourassa
You can easily create a batch file that you call that copies '*.RES' from your source directories to your destination directories, and then call the batch file from the event.
skamradt
+2  A: 

For *.res files you can specify output path in "Project Options | Resource Compiler | Directories and Conditionals | Output directory for .res files"

But for *.DFM files you have to use skamradt's suggestion (Post Build event).

vcldeveloper
That option doesn't seem to work. I guess it only works with *.res created by Delphi and not those linked in the source. I'm using *.res file created by a 3rd party application to make bitmap resources for my application and they are not copied in that directory on build.
Ken Bourassa