Jump to content
GabrielMoraru

About the compiler (not) finding the DFM files

Recommended Posts

So, I have a program that uses the precompiled units of a library.

This:

  1. Allows me to keep the Search Paths totally empty (as they should be)
  2. Prevents the compiler from keep recompiling the files of the library unnecessarily, saving compilation time.

 

But if the library has DFM files, the compiler will throw that famous "where are my DFM files?" error message.

The "solution" (well, it is not a real solution, but rather a dirty trick) is to (manually or by script) copy the DFM files to the DCU folder of that library.

Four output DCU paths, four copies. What a nasty "solution"...

 

So, did anyone found a more elegant way to solve this?
I see in some old DProj files an entry called <DCC_ResourcePath>, but there is no page in "Project options" or in IDE's  "Tools -> Options" to set that path.

Edited by GabrielMoraru

Share this post


Link to post
1 hour ago, GabrielMoraru said:

So, I have a program that uses the precompiled units of a library.

This:

  • Allows me to keep the Search Paths totally empty (as they should be)
  • Prevents the compiler from keep recompiling the files of the library unnecessarily, saving compilation time.

 

But if the library has DFM files, the compiler will throw that famous "where are my DFM files?" error message.

The "solution" (well, it is not a real solution, but rather a dirty trick) is to (manually or by script) copy the DFM files to the DCU folder of that library.

Four output DCU paths, four copies. What a nasty "solution"...

 

So, did anyone found a more elegant way to solve this?
I see in some old DProj files an entry called <DCC_ResourcePath>, but there is no page in "Project options" or in IDE's  "Tools -> Options" to set that path.

I just add the "library" foms to the project that needs them, this way the required path is in the dpr file uses clause.

Btw.: I think this DCC_RessourcePath is for the resource compiler and you can set it under that node in the Options dialog. Never needed that myself, though.

Share this post


Link to post

> "I just add the "library" forms to the project that needs them"
a) Won't this break the second rule: "2. Prevents the compiler from keep recompiling the files of the library unnecessarily, saving compilation time"?

b) Plus, this way you have to maintain the files twice. If you add/remove a form from your package, you need to manually add/remove it also from all DPR files that use that form.

 

If so, then copying the forms to the binary output (DCU) folder of the library via a post-build script it is still the best "hack".

:classic_happy:

 

> "I think this DCC_RessourcePath is for the resource compiler and you can set it under that node in the Options dialog. Never needed that myself, though"

I will try that! Thanks!

Edited by GabrielMoraru

Share this post


Link to post

Could you please share your PostBuild script and the entire sequence copying those files to the sub-folders.
I've done something similar, but on many libraries msbuild fails under 64-bit mode while compiling the .dproj files under command-line using a bat file.
In Delphi IDE all is OK, but msbuild fails building some 64-bit libraries.

build.bat:

call "C:\Program Files (x86)\Embarcadero\Studio\23.0\bin\rsvars.bat"
msbuild /t:rebuild /p:Config=Release /p:platform=Win32 MyPackage.dproj
msbuild /t:rebuild /p:Config=Debug /p:platform=Win32 MyPackage.dproj


64bit build.bat:

call "C:\Program Files (x86)\Embarcadero\Studio\23.0\bin64\rsvars64.bat"
msbuild /t:rebuild /p:Config=Release /p:platform=Win64 MyPackage.dproj
msbuild /t:rebuild /p:Config=Debug /p:platform=Win64 MyPackage.dproj


This is my postbuild event:

.\..\copyres.bat "$(PROJECTDIR)\..\" "$(PROJECTDIR)\$(Platform)\$(Config)"

 

copyres.bat:

@echo off
for /r %1 %%x in (*.res) do @copy "%%x" %2 /Y > NUL
for /r %1 %%x in (*.dfm) do @copy "%%x" %2 /Y > NUL
for /r %1 %%x in (*.dcr) do @copy "%%x" %2 /Y > NUL

The bigger problem I have is that I need to set some component packages Library path to point to their \Source\ folder (instead of to the precompiled Win32\ and Win64\ .dcu folders) if my program overrides some of the Delphi files like Vcl.Forms.pas/Vcl.Controls.pas, etc.

So my question is: Is there anyway to recompile a component package using custom Vcl.Forms, Vcl.Controls?

Share this post


Link to post
3 hours ago, GabrielMoraru said:

Prevents the compiler from keep recompiling the files of the library unnecessarily, saving compilation time.

Why would it recompile if it hasn't changed? Do you mean when building the app? Why would you build the app so often?

3 hours ago, GabrielMoraru said:

So, did anyone found a more elegant way to solve this?

Yeah, compiling them into binary DFMs would be more elegant 😄

I don't know how many DFMs a library can have, but it's not typical.

 

Share this post


Link to post
3 hours ago, PeterBelow said:

I think this DCC_RessourcePath is for the resource compiler and you can set it under that node in the Options dialog.

Not quite, that setting is stored as BRCC_IncludePath.

 

DCC_ResourcePath is indeed the correct way to provide the paths to look for the DFM resources. Unfortunately there is no UI to edit that.

 

Manually editing the dproj file adding a node like

        <DCC_ResourcePath>..\lib\Source;$(DCC_ResourcePath)</DCC_ResourcePath>

under the appropriate PropertyGroup will make the DFM files located in ..\lib\source to be found without exposing the PAS files in that folder.

  • Thanks 1

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×