views:

70

answers:

3

I followed the advice received in a previous discussion ( http://stackoverflow.com/questions/3666292/should-library-path-point-to-the-source-files-of-packages/3686542#3686542 ) 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).

+1  A: 

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.

Ulrich Gerhardt
Hi Ulrich. I cannot find <DCC_ResourcePath> in Delphi 7.
Altar
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.
Ulrich Gerhardt
+2  A: 

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.
ldsandon
I like solution (2). Thanks.
Altar
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 careful
ldsandon
A: 

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.

Altar