How to remove duplicate resources (RES, DFM) while using Delphi with non specific Library paths?
Asked Answered
W

3

4

I followed the advice received in a previous discussion ( Should "Library path" point to the source files of packages? ) and now my Library Path points to folders containing the compiled code (DCU) and NOT to the source code of my controls. The problem is that I have to duplicate the RES and DFM files and copy them from the 'source code' folder to the 'compiled' folder. It is not a elegant solution at all since, every time I change something (and I do often) to my controls I have to remember to copy the new resource files to the compiled folder.

There must be an elegant way to solve the mystery of the paths! All I want is to push the compile button and to have my program compiled. It doesn't seem so complicated. Right? Well, actually it work with my previous setup (point Delphi to source code of all controls). I just changed it to do it the way the 'good people' are doing it.

Addendum
I still think this is the wrong approach since Delphi's (scarce) documentation says that Library path should point to the "source files for the package".


Using:
Delphi 7, Win 7 (32), simple Delphi setup (single developer with no versioning system installed).

Wharfinger answered 16/9, 2010 at 8:39 Comment(1)
versioning systems are very useful for single developers as well. I'd recommend you to use one because 1) It will make working with different version of your code easier 2) It will protect you from your onwn mistakes 3) You will learn how to use oneTreulich
W
0

Though answers provided here by others are definitively good and correct (everybody receives a vote up), after experimenting a bit I decided to keep my previous (KISS) set up. It worked for years and it will work for many more. I know, it trades speed (recompiling the source code) for stability but it keeps the "paths, libraries, source, browsing and output folders" madness at bay. I just don't have to worry about settings paths anymore (except first time when I install Delphi but this can be automated) or to quit current DPR Delphi project and load a DPK library and compile it every time I add changes to it.

Wharfinger answered 29/9, 2010 at 17:39 Comment(0)
T
2

You have two solution:

  1. Use a build tool to build and copy all files where they should be properly deployed (my preferred solution) after each build
  2. Put the .pas/.dfm/.res directory after the .dcu ones. It will find the .dcu first and won't recompile unless you build, and it will keep on looking for .res/.dfm, etc.
Treulich answered 16/9, 2010 at 10:52 Comment(1)
IIRC in Delphi 7 you can still add bat/cmd files to be part of a project and executed when "building" you can use them to copy files. Solution 2 has the downside you can have dcu using an older version of .dfm - be carefulTreulich
H
1

If you look inside a D2007 project file (*.dproj) you'll see that the search path occurs multiple time for each configuration. There is

  • <DCC_UnitSearchPath>,
  • <DCC_ResourcePath>,
  • <DCC_ObjPath> and
  • <DCC_IncludePath>.

Maybe you can point <DCC_ResourcePath> to the source directory containing the resource files while you point the other variables to the DCU directory.

NB: I haven't tried this and can't check if the situation is different in other Delphi versions.

Hyla answered 16/9, 2010 at 9:15 Comment(3)
Hi Ulrich. I cannot find <DCC_ResourcePath> in Delphi 7.Wharfinger
Hmm, I found some old D5 project - this should be the same as D7. It looks like the *.dof contains only one path (SearchPath) while the *.cfg has multiple paths (-U, -O, -I, -R). IIRC the *.dof options controlled compiler inside the IDE, so I guess this approach would be hard to use for you.Hyla
There is a field in the IDE GUI where I can set the <DCC_ResourcePath> ? If not, I am afraid this is just a hack as Emba will might decide later to get rid of it!Wharfinger
W
0

Though answers provided here by others are definitively good and correct (everybody receives a vote up), after experimenting a bit I decided to keep my previous (KISS) set up. It worked for years and it will work for many more. I know, it trades speed (recompiling the source code) for stability but it keeps the "paths, libraries, source, browsing and output folders" madness at bay. I just don't have to worry about settings paths anymore (except first time when I install Delphi but this can be automated) or to quit current DPR Delphi project and load a DPK library and compile it every time I add changes to it.

Wharfinger answered 29/9, 2010 at 17:39 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.