Author Topic: how to force a dependency ?  (Read 3879 times)

Offline Elena

  • Multiple posting newcomer
  • *
  • Posts: 49
how to force a dependency ?
« on: March 07, 2021, 07:15:00 pm »
Hi all I am new to cb! I have just set up a working cb+mingw setup for writing modules for Synthedit, being exhausted by VS and by microsoft's invasive policy.
In my usual projects (they are DLLs) I have some resource files to be compiled and linked. In particular I have a .rc file which internally references an .xml.file. So when I modify the .xml I need the project to be updated. Unfortunately CB cannot automatically detect such dependency of the .rc file from the .xml file. Is there a clean way to force this dependency without having to manually edit the .depend database ? Thanks in advance

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline Elena

  • Multiple posting newcomer
  • *
  • Posts: 49
Re: how to force a dependency ?
« Reply #2 on: March 08, 2021, 07:22:00 pm »
Thanks, the link is interesting but despite my efforts I still can't figure out how to set up the advanced compiler options properly to suit my needs...
I try to explain my situation better.
First of all I am using the last cb+mingw. I need to write modules for Synthedit, they are pretty DLLs.
They contain regular .cpp and .h files plus three special files: one .rc, one resource.h and one .xml. The .rc includes resource.h (here cb can still create a dependency) but it also refers to the xml file with some strange macros I am not very familiar with:
IDR_GMPXML1   GMPXML   "test.xml"
Everything compiles fine and works even if I ignore the inner workings of that .rc source.
Anyway the object (resource ?) Test.res generated by the three files must depend by the .xml file aswell,.so that everytime I have to modify the xml (a frequent task) only the test.rc object will be compiled, while now I have to rebuild the whole project! Can you help me ?

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: how to force a dependency ?
« Reply #3 on: March 08, 2021, 08:27:26 pm »
Can you help me ?
Personally I don't have the time. Someone should investigate the compiler plugin to see how it calculates dependencies for .rc files.
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline Elena

  • Multiple posting newcomer
  • *
  • Posts: 49
Re: how to force a dependency ?
« Reply #4 on: March 08, 2021, 09:07:54 pm »
I am not demanding that you help me. I am asking rather if somebody can. Thanks.the same

Offline Pecan

  • Plugin developer
  • Lives here!
  • ****
  • Posts: 2750
Re: how to force a dependency ?
« Reply #5 on: March 10, 2021, 08:02:03 pm »
If I understand this correctly, the .rc file must be compiled if the .xml file is modified.

If that is true, then the solution is to 'touch' the rc.h file (reset the modification time) so that only .rc gets compiled when the build (not rebuild) menu item is clicked.

Given the above, I'd use the project options preBuild step to 'touch' the .h file if the xml modTime is later than the .xml modTime using a command line batch file.

]https://stackoverflow.com/questions/40272150/how-to-get-a-files-last-modified-date-on-windows-dos-command]
]https://stackoverflow.com/questions/21698300/cmd-comparingvariables/21701765]

Now. How to touch the .h file?
https://superuser.com/questions/10426/windows-equivalent-of-the-linux-command-touch/764716

Code
Get clever with the arcane mysteries of CMD.
As mentioned in the other answer, COPY /B myfile+,, will update a
file's last modification datestamp, using the little-known
"plus" syntax of the COPY command (more on which can be found
here, incidentally). This of course can be combined with FOR /R to
perform the operation recursively, as hinted at in another answer here.

Wrap all this up in cmd.bat file and insert it in the prebuild steps as:
cmd /c name-of-your-bat-file

Menu\Project\Build options...\Pre/Post build steps tab
« Last Edit: March 11, 2021, 01:05:30 am by Pecan »

Offline Elena

  • Multiple posting newcomer
  • *
  • Posts: 49
Re: how to force a dependency ?
« Reply #6 on: March 10, 2021, 11:01:35 pm »
Thanks Pecan. I will try to figure out how to do since I know pretty nothing of batch files.
Anyway I hoped that C::B provided an easier solution, a pity there aren't any...
I think I will issue a feature request