Thomas Mueller - 14 hours ago

Measured with RAD Studio 13 and MSBuild, which builds the same way as the IDE: the compiler searches the project's folder first, then the project's search path, then the library path. This applies to units and to {$I} files alike. MSBuild runs the compiler in the project's folder even when it is started from another folder, and the compiler searches the current folder before the -U and -I folders. A unit that the .dpr lists with in '...' is taken from exactly that file.

So the order the description asks for is right. One point of the description is wrong: the project's folder is not dropped. GetEffectiveLibraryPath clears the list, but GetProjectSourcePathStrings then adds the project's folder as the first entry.

What remains:

  • GetEffectiveLibraryPath is called without the Project that was passed in, and the project's folder that GetAllPossiblePaths adds before that call is cleared right away.
  • A unit that the .dpr lists with in '...' from a subfolder is found after a copy of it on the search path or the library path, because the folders of the project's units come after those paths. The compiler takes the file named in the in clause.