Search code examples
delphi

How can I run code at compile-time in Delphi?


I'd like to create a version.rc file without having to put in place a whole pipeline. I'd simply like for some code to run whenever Delphi build an executable in order to create that file.

I'm using 10.3.


Solution

  • You can use the build events for that purpose. You find those events in project options / Building / Build events.

    You have the choice of 3 event groups : one before Delphi build your project, one before Delphi linker is called and one after the build is done.

    In you case, you shall use pre-build events. As command, you can specify a program or batch file which will create your rc file.

    The documentation is there : https://docwiki.embarcadero.com/RADStudio/Athens/en/Creating_Build_Events