5

I have successfully registered an IDE notifier (IOTAIDENotifier80) so I get AfterCompile notifications.

Is it possible to find out whether the project was built versus just being compiled/made?

I've found this answer about implementing a IOTAProjectCompileNotifier but this is not available in D2007.

Any other way? I'd be fine with an undocumented way as this is for an inhouse expert only.

Update: I need this to replicate the "AutoInc build number" feature with an external .rc file containing the version info resource. Maybe this can be done via BuildEvents? Although I like the ability to log a message in the IDE showing the updated version number...

Community
  • 1
  • 1
msohn
  • 326
  • 2
  • 12
  • FWIW, I think the interface is `IOTACompileNotifier` and was added in D2010. If there's an undocumented way, this is it. Perhaps the interface you need to register the notifier `IOTACompileServices` is implemented by D2007, but just not published in D2007 ToolsAPI.pas. Worth a go. It's GUID is `{68C486EF-C079-4D40-B462-2C0DD21FE342}`. If not you're left with the option of installing code hook to intercept the event that invokes the make/build. That's tricky because you'll need to install a trampoline and you'll need a decent hooking library. – David Heffernan Oct 15 '13 at 12:47
  • Unfortunately, no luck. I've copied the declaration of IOTACompileServices into my unit, but casting `BorlandIDEServices as IOTACompileServices` failed. – msohn Oct 15 '13 at 12:54
  • I had the hope that there was an "old way" to do this that would still be somewhat supported in D2007. – msohn Oct 15 '13 at 12:55

1 Answers1

1

I have no idea about writing experts or hooking into the IDE, and I'm scared of trampolines. Having said that, I've noticed that you can tell the difference between a compile and build by monitoring the timestamps of the files in your project output folder, but this difference is only evident if no code (*.pas or *.dfm) has changed since last compile or build. In other words, when there is a code change, you can NOT tell the difference by monitoring the timestamps. However, when there is no code change since last compile or build, a compile will only change the timestamp of the exe (the dcu timestamps are not changed).

Therefore, in the absence of other more elegant solutions, and only if you are really desperate for this information (ie, was it compiled or was it built?) then I can suggest a 2-part solution for you.

Part 1. Write a process to monitor changes in timestamps in your output folder, and

Part 2. Tell your fellow developers there is a bug in D2007 which complicates your build process, but that this bug is easily overcome by simply compiling twice or building twice (or if you know how to automate this then go for your life). If you can get your developers to compile twice or build twice then upon the second compile or build you will be able to deduce whether it was a compile or build by testing if the timestamp of the dcu changed upon the second compile or build.

Now, I will go and stand in the naughty corner and ask myself "why me?". Cheers.

Sam
  • 2,663
  • 10
  • 41
  • 60
  • 1
    Thanks for the entertaining response. I'll keep that in mind, although it would be quite a bit of work, considering you'd have to get the output folder from the project config and it would have to work for different kind of output files (dll/bpl/exe). – msohn Oct 17 '13 at 08:03