2

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?

Jens Mühlenhoff
  • 14,565
  • 6
  • 56
  • 113
  • 1
    DFM files are always linked into the BPL. When you compile with packages they are loaded from the BPL at runtime. When you compile without packages neither the BPL nor the DCP is used. Instead you must have the DCU and DFM in the search path. – Uwe Raabe Apr 10 '18 at 14:16
  • I see, then the compiler is cleverer than I thought. I have to check this in a test setup. – Jens Mühlenhoff Apr 10 '18 at 14:19
  • 1
    DFM/LFM/FMX files are just "win32 resources", linked into PAS files via the same `{$R }` directive as you can use to link ".RES" files. It is typical that one PAS file has one or none DFM resources. The compiler itself can have many DFM resources in one PAS file, but the IDE would go crazy. Delphi DFM files today can be in binary or textual form. Textual DFM was introduced in late 1990s in either Delphi 4 or Delphi 5. However as compiled resources DFMs are kept as binary (`TComponent.SaveToStream`). You can find those resources using any binary files resource viewer or Delphi Decompilers – Arioch 'The Apr 10 '18 at 15:36
  • Granted, generic tools like ntCore CFF Explorer would show DFM resources just like binary HEX dumps, while tools like DeDe maybe can do better. There were a number of resource editors in the internet while ago. – Arioch 'The Apr 10 '18 at 15:37
  • If your DFM's are shared between all three of your packages wouldn't it be better to create a new package which would only contain your DFM's and then simply add that package into Contains section of your packages instead of copying your DFM's all around the place? – SilverWarior Apr 10 '18 at 17:32
  • @UweRaabe You are correct, when compiling with runtime packages the search path of the executable does not have to include the path where the dfm files are. That is because they are indeed linked into the packages bpl files. – Jens Mühlenhoff Apr 11 '18 at 09:33
  • @SilverWarior I only copy them once to a location where there are no `*.pas` files. This is only necessary because otherwise the compiler would recompile the units which is annoying. IMO the compiler should never try to compile something that is not part of its current project, but that is how things are. – Jens Mühlenhoff Apr 11 '18 at 09:46
  • @Arioch'The I don't see the relevance of your comments to the question? I know what resources are, the question is about in which module (`bpl` / `exe`) the resources are put by the compiler / linker with and without runtime packages. – Jens Mühlenhoff Apr 11 '18 at 09:48
  • If you know it, them you know where your PAS files ends: ini exe, in BPL, in both or in none. And you can check for every DFM file which PAS files included it. See CFF explorer: http://www.ntcore.com/exsuite.php Also see Analyze Project IDE extension from JCL. – Arioch 'The Apr 11 '18 at 12:42
  • That's true, I could have checked for myself. My intention in asking this question was more like: Maybe there is some compiler or linker option that I'm not aware of or somebody has a better insight into those things. Also I couldn't find a similar question, yet. – Jens Mühlenhoff Apr 11 '18 at 14:14

1 Answers1

1

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).

Jens Mühlenhoff
  • 14,565
  • 6
  • 56
  • 113