4

I would like to detect the build target, i.e. make or build, in a build event.

I have pre-build event that compiles a number of C files into objects (.obj) which are then included in one of my Pascal files. At the moment the C files are compiled every time the pre-build event runs. I would like to be able to skip this stage if the build target is make and if the objects are up-to-date.

Being able to skip this stage would give me significant reductions in compile time whilst in edit/compile/debug development mode.

So, is it possible to detect the build target?

David Heffernan
  • 601,492
  • 42
  • 1,072
  • 1,490
  • I realize it's a bit of a hack, but why not launch the C build via a separate project-item in a project group? If this was visual studio, it would be a '.lib' target, perhaps you can get somewhere that way. You could even create dependencies so that the one gets built when the other is rebuilt? – Warren P Feb 11 '12 at 19:23

1 Answers1

5

Given that the IDE will only compile a single project at a time, one solution would be to register an IOTAProjectCompileNotifier. Depending on the value of CompileInfo.Mode, it could remove the build event in BeforeCompile and add it back in AfterCompile.

Henrick Hellström
  • 2,556
  • 16
  • 18
  • 2
    Thanks. If I went down that route I would set an environment variable and let the build event code modify its behaviour according to the value of that env var – David Heffernan Feb 11 '12 at 17:43
  • 2
    I like this solution. If you detect a *compile* set an environment variable. Your build event should treat everything as a build unless the special environment variable is present: that way you're "safe" against IDE's that don't have your plugin installed. – Cosmin Prund Feb 11 '12 at 18:39
  • 2
    @cosmin I guess this will do the job but it's something that should be handled by delphi itself in my view – David Heffernan Feb 11 '12 at 18:50
  • Thanks for this suggestion. I have just successfully implemented it. – David Heffernan Feb 15 '12 at 16:14