Search code examples
delphiembedded-resourcedelphi-10.1-berlindfm

Can dfm files be linked into bpl files?


My project setup looks like this:

There are multiple runtime packages. I'm not using design time packages.

Each runtime package has its DCP, package and unit output directory set to .\Library\$(Platform)\$(Config). I'm not outputting them to the global IDE locations to gain co-installability of different versions of the packages.

Also there is a Pre-build event in each package that calls a script file which copies all the dfm files from the source folders to a directory called .\Library\Dfm.

In order to build dependent packages and executables I add the output paths for the dfm and the other files to each dependencies local search path, for example:

..\Package1\Library\$(Platform)\$(Config)
..\Package1\Library\Dfm
..\Package2\Library\$(Platform)\$(Config)
..\Package2\Library\Dfm
..\Package3\Library\$(Platform)\$(Config)
..\Package3\Library\Dfm

Technically I only need to add the Dfm directories to the final executables search path since dfm files are linked into the PE executables resource section.

Still it seems like an unneccessary extra step to have two paths for each package.

So I am asking: Is it possible to link the dfm files into the bpl file for each package instead of the final executable?

One problem I can think of myself is that this would only work when runtime packages are enabled for the executable, because the compiler couldn't move the resources from the bpls to the exe otherwise?!

Is it even in principle possible to have the dfm resources in a different module than the one of the executable?


Solution

  • When compiling an executable with runtime packages enabled the compiler does not need access to the dfm files for forms inside the packages.

    They are indeed linked into the bpl files.

    When compiling with runtime packages disabled the compiler complains about the missing dfm files. So it apparently can not pull the resources from the compiled package file (bpl).