delphi - Why does the compiler place DCUs that do not belong to the current package in its unit output directory? -
i created 2 packages, p1.dproj
, p2.dproj
.
i put 2 empty units packages, p1
contains unit1.pas
, p2
contains unit2.pas
.
i edited unit output directory .\p1\$(platform)\$(config)
, .\p2\$(platform)\$(config)
in respective packages.
i added p1 reference p2 project, p2 depends on p1.
the project files stored in same folder.
the directory structure looks this:
root\ source\ p1\ unit1.pas p2\ unit2.pas packages\ p1.dpk p1.dproj p2.dpk p2.dproj p1\ win32\ debug\ p2\ win32\ debug\
before added dependency p1 outputting packages\p1\win32\debug\unit1.dcu
, p2 outputting packages\p21\win32\debug\unit2.dcu
.
nothing unexpected.
after added dependency when build p2 ide automatically compiles p1 well, unit1.dcu
file outputted packages\p2\win32\debug\unit1.dcu
.
why that?
the unit1.dcu
file not in contains
list of p2.droj
nor listed in library path or browsing path (neither delphi global nor project local).
why compiler put stuff unit output directory of current project not have access source directory of?
when move p1 dpk/dproj files away sub folder , restart ide correctly complain can not find p1.dcp
file , not start compile p1.
i had noticed behaviour in bigger, more complicated setup , driving me crazy ...
it's doing because source files both packages in same directory and p1 set "rebuild needed" in it's project options.
think simple project proj1 contains , uses unit u1. u1 uses u2 not included in proj1. compiler must able see u2.dcu; in current library path or other common "lib" directory. when proj1 compiled, u1.dcu goes proj1's unit output directory u2.dcu "used" wherever lives , not appear in proj1's unit output directory.
now, suppose add directory u2.pas exists proj1's search path. compiler can see u2.pas, compiles , places resulting u2.dcu proj1's unit output directory along u1.dcu
it's same thing here...p2 "requires" p1. is, when compiling p2, compiler needs see either p1.dcp or of source files p1 (p1.dpk , unit1.pas in case).
in case, can see p1.dpk because it's in same directory, compiles , places resulting dcu's (unit1.dcu in case) p2's unit output directory.
you can prevent behavior setting p1 "explicit rebuild" in it's project options. when building p2 or package "requires" p1, tells compiler "even though can see p1's source, not build it."
Comments
Post a Comment