Checking dependencies of RC files in Delphi

If the RC file is modified, Delphi will compile it again. If there are RCDATA or BITMAP declarations in the RC file that refer to files that have been modified, Delphi will not recompile the .RC file to .RES again until I force it by deleting the .RES file or by making a “touch” (change the timestamp file) at the top level .RC file.

Here is an example TEST.RC file:

SAMPLE RCDATA "File.txt" 

When TEST.RC is changed, it will lead to recompilation when "File.txt" is changed, however Delphi will not recompile resources in "Compilation". I don’t want to just use “Build” because it increases the time from a few seconds to a few minutes.

Has anyone ever gotten Delphi to work properly with .RC text files and dependencies? Provided by some people, they add resources and never change them, but I started using .RC files for things that I can often change, such as binary or text data, which are in the RCDATA sections in the .RC file.

Please note that attempting to put the “remove .res” step into pre-build or post-build may break the Delphi IDE / compiler. I can sort this from the outside when creating outside the IDE (always delete certain .res files before running msbuild), but inside the IDE, Delphi gives me no choice.

Has anyone got a solution? (I have this problem in Delphi 2007, but any solution that works with any version of Delphi from 2007 to XE3 would be welcome.)

+6
source share
1 answer

This is not quite an ideal answer, since compliance checking is not performed using the example below, however, the main problem of a resource that is not rebuilt often enough is Always Rebuilding Every Time, which is good enough.

This is ultimately more correct than Delphi's built-in behavior, which varies from (a) rather than recompiling often enough when you build from an ad {$ R foo.res foo.rc} when you use it inside the IDE to even the worst state (b) is not created at all from the command line if you include the declaration {$ R foo.res foo.rc} in the .dpr file.

So, with all of this, here's the pre-build work step that does what David suggested I do:

  call $(PROJECTDIR)\SubDir\foo.cmd $(PROJECTDIR) 

here is what my foo.cmd contains:

  cd %1\SubDir rc.exe foo.rc echo compiled foo RCDATA 

For those who are wondering what foo.rc might contain, it might look like this:

  SQL_QUERY_1 RCDATA "SqlDir1\MYSQL.SQL" 

ERRATA:

I found that {$R foo.res foo.rc} only builds correctly in Delphi 2007 from the IDE. From the MSBUILD command line, it will not be created. You just get "DCC ERROR 1" and the assembly is interrupted without a real error message. You may be interested to know that one of the reasons delphi MSBUILD compiles mysteriously without error output in the error log or in stdout is when RC.exe returns the error level. RC.exe displays a real error message (Hey Delphi, you sent me invalid command line parameters, I give up), and either Delphi DCC32 does not send this back to you, or it is somehow absorbed and not returned to users, so they may have enough information to know why their creation mysteriously breaks. An unpleasant little integration function msbuild-dcc32, which.

Instead of {$ R subdir \ foo.res subdir \ foo.rc} you should have this in your DPR:

  {$R SubDir\foo.res} 

This means that "bind this binary resource and do not try to recompile, because we did it already." All of the above simply explains what David suggested in the commentary. Hat tip to David.

+2
source

All Articles