1
votes

Today I'm trying to figure out why something works when I think it should be broken.

I have little Delphi experience, and I've inherited a Delphi codebase and am setting up a machine where it will be maintained and compiled. I have a package that compiles successfully but can't figure out how it is resolving one of the types. My understanding is that when you use a unit, you must either

  1. Include the source file in your package directly
  2. Resolve the source pas or dcu file on your project search path
  3. Resolve the source pas or dcu file on your IDE library path

None of these appear to be happening, and yet the package compiles. How else could this be compiling successfully?

Details

I have 'base' package that has a direct include on the file THotLog.pas. The file appears under the project's Contains folder in Project Manager. THotLog is NOT one of the components in the package, it is not in the register procedure for base package.

I then have 'consuming' package that requires base package. Consuming package has several components with THotLog members, and consuming package compiles. This surprises me, because I thought consuming package would have to be able to locate THotLog.pas or THotLog.dcu.

This is for RAD Studio 10.1. The project search path (Project > Options : Search path) is empty, and the IDE search paths (Tools > Options , then Environment Options > Delphi Options > Library) do not include where THotLog is.

I've also tried renamed all THotLog files on the hard drive and consuming package still compiles.

Hypothesizing that my understanding about type resolution is wrong, I tried making a set of sample projects with a similar layout and the sample consuming package cannot resolve sample THotLog without locating the pas or dcu file.

1

1 Answers

1
votes

When you build a Delphi package, the compiler/linker creates a Compiled Package File named [package-name].dcp. It is a binary file containing all of the compiled units included in that package.

Compiling your "base" package created a [base-package].dcp file that is visible to the "consuming" package. The "consuming" package is referencing the base-package in its "Requires" section; this is the link to the base package's DCP file.

Delphi Compiled Package File