I'm trying to use Pre-/Post-Build-Events (Delphi 10.1 Berlin, if that matters). Is there a variable, parameter, option etc to distinguish between a "make" and a "build"? The Events are fired in both cases, but I would like to do some special handling only if I "build" the project.

I'm trying to use Pre-/Post-Build-Events (Delphi 10.1 Berlin, if that matters). Is there a variable, parameter, option etc to distinguish between a "make" and a "build"? The Events are fired in both cases, but I would like to do some special handling only if I "build" the project.

(Yes, I have googled for that several hours)

TIA
Achim

Comments

  1. Interesting idea! I've not noticed any environment variables that could help me there yet.

    ReplyDelete
  2. Why build on your workstation when you can set up a build server? Every commit can trigger unit tests, exe builds, exe signing, copying the exe files to their staging directories, building install scripts, upgrade the test servers.

    ReplyDelete
  3. There is nothing. I wrote a plugin to get around that. If I recall I hooked the compiler notifications and set environment variables to distinguish between make and build.

    This was important to me because my pre build actions involve compiling C code outside the project and so not part of the compiler's make logic.

    ReplyDelete
  4. David Heffernan I think more than just Achim Kalwa is interested for that plugin (:

    ReplyDelete
  5. David Heffernan thanks a lot! I've not done OTA work for a long time so I assumed it would be a much more complex job. Your code is a great OTA example which I'm sure to mention in my blog.

    ReplyDelete
  6. David Heffernan That is exactly what I need! Thank you very much, David!

    ReplyDelete
  7. Did you (David, Achim) enter a feature request QP?

    ReplyDelete
  8. David Millington No, I did not. What are the chances to get this implemented in the near future?

    ReplyDelete
  9. Achim Kalwa Well, no promises, and it'd be post-Godzilla, but it seems likely to be fairly small and simple to me.

    ReplyDelete
  10. I did not. How would you see it working? An environment variable presented to the build action?

    ReplyDelete
  11. Not sure - we'd investigate what's possible or useful. Maybe you can comment in the QP your use case, ie what you'd like it to be? But certainly providing something that changes / is set or not set / similar based on either a build or make (build or compile) should be possible.

    ReplyDelete
  12. May I ask: why it's not possible to create a new build configuration (something like Debug, Release, FullRelease)? You can just add different post-build events to each configuration...

    ReplyDelete
  13. Andrei Aleksandrov It is possible - right-click on the Build Configurations item in the Project Manager tree, and select New Configuration.

    ReplyDelete
  14. David Millington​ thanks for response! :) I know it, but wrote unclear comment, sorry.
    I'm just wondering, why was it necessary to write a plugin for such a task and not use many build configurations with different pre-/post-build tasks...

    ReplyDelete
  15. Andrei Aleksandrov Read the question. Asker wants to distinguish between make and build actions, from the same configuration.

    ReplyDelete
  16. David Heffernan cool. What is the difference between distinguishing between make/build and two different build configurations?

    ReplyDelete
  17. David Heffernan, Andrei Aleksandrov Since the Delphi IDE distinguishes between "make" and "build", the "Build events" should also do: I use a pre-build event to increase the build number (in an external .rc file), and signtool in a post-build-event. Both needs to be run on a build (Shift+F9) only. On a normal compile/make (Ctrl+F9) or run (F9) this external tools are not required. A distinct build configuration would be a solution, but is not accessable by simple keyboard shortcuts.

    ReplyDelete
  18. Achim Kalwa that is what I wanted to know. Thanks for answer :)

    ReplyDelete
  19. Achim Kalwa Makes sense, although I'm not sure why the external tools (including signing) are not needing on a make? But the general use case is clear. Can you point me at a QP? I'll see if we can make this more powerful in an upcoming release.

    ReplyDelete
  20. David Millington can you add shortcuts for switching build configurations? :))))

    ReplyDelete
  21. David Millington in my build environment I compile C source files which are then linked with $LINK. For obvious reasons I'd like to be able to compile only outdated ones when doing a make, but compile all when doing a build.

    I have achieved that crudely using an IDE design time package that sets an environment variable depending on whether the action is make or build.

    It would be helpful if Delphi had something built in for this.

    As far as signing the executable goes then that is fine to happen every time in my view, but perhaps the asker here wants to save even more time.

    ReplyDelete
  22. David Heffernan Can't you achieve that by putting the C files in their own project, which is first in the build order before the project linking them?

    ReplyDelete
  23. David Millington They are compiled by cl, so no

    ReplyDelete

Post a Comment