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

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-07 07:40:20

问题


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


回答1:


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.



回答2:


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.




回答3:


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.



来源:https://stackoverflow.com/questions/3725033/how-to-remove-duplicate-resources-res-dfm-while-using-delphi-with-non-specifi

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!