This is not exactly a perfect answer since no dependency checking is done by the below sample, however the basic problem of the resource not being rebuilt frequently enough is fixed by Always Rebuilding Every Time, which is Good Enough.
That in the end is more correct than Delphi's built in behaviour which varies from (a) not recompiling frequently enough while you build from an {$R foo.res foo.rc} declaration when you use it inside the IDE to the even worse state of (b) not building at all from the commandline if you include a {$R foo.res foo.rc} declaration in your .dpr file.
So, with all that, here's a working pre-build step, which does what David suggested I do:
call $(PROJECTDIR)\SubDir\foo.cmd $(PROJECTDIR)
here's what my foo.cmd contains:
cd %1\SubDir
rc.exe foo.rc
echo compiled foo RCDATA
For anyone wondering what foo.rc might contain it might look like this:
SQL_QUERY_1 RCDATA "SqlDir1\MYSQL.SQL"
ERRATA:
I have found that {$R foo.res foo.rc}
only builds properly in Delphi 2007 from within the IDE. From the commandline MSBUILD, it won't build. You just get "DCC ERROR 1"
and the build aborts without a real error message. You may be interested to know that one of the reasons delphi MSBUILD compiles mysteriously abort without any error output in the error log or to stdout, is when RC.exe returns an errorlevel. RC.exe outputs a real error message (Hey Delphi you sent me invalid command line parameters, I'm giving up), and either Delphi DCC32
doesn't forward that along back to you, or it is somehow otherwise gobbled up and not given back to users so they can have enough information to know why their build mysteriously breaks. Nasty little msbuild-dcc32 integration mis-feature, that.
Instead of {$R subdir\foo.res subdir\foo.rc}, you should have this in your DPR:
{$R SubDir\foo.res}
That means "link that binary resource and don't try to recompile, because we did it fer ya already". All of the above is just by way of making explicit what David suggested in a comment. Hat tip to David.