简体   繁体   English

在Delphi 7中,如何跟踪编译单元的顺序?

[英]In Delphi 7, how do I trace the order in which the units are being compiled?

I have an application which was started in Turbo Pascal 5 and is now at Delphi 7 (the roots of the project are over 20 years old). 我有一个应用程序,它是在Turbo Pascal 5中开始的,现在是Delphi 7(该项目的根源已超过20年)。 We are attempting to move this project to Delphi XE. 我们正在尝试将此项目移至Delphi XE。

There is a unit which is being compiled into the exe which should not be compiled into this project at all. 有一个单元正在编译成exe,根本不应该编译到这个项目中。 I have been unable to properly trace how it is entering into the compilation. 我无法正确追踪它是如何进入编辑的。

Is there a log or some other means that I can use to see the order of the units being compiled so that I can trace down this problem? 是否有日志或其他方法,我可以用来查看正在编译的单位的顺序,以便我可以追查这个问题?

NOTE: I have already attempted to use the ICARUS tool to accomplish the trace without success. 注意:我已经尝试使用ICARUS工具来完成跟踪而没有成功。

EDIT: I'm sure that using brute force and enough time I can solve this issue. 编辑:我确信使用蛮力和足够的时间我可以解决这个问题。 What I'm seeking is a more elegant solution if one is available. 我正在寻求的是一个更优雅的解决方案,如果有的话。

To trace the order, you might try using a tool like Process Monitor to monitor disk I/O. 要跟踪订单,您可以尝试使用Process Monitor之类的工具来监控磁盘I / O. Delphi doesn't log that kind of information itself. Delphi本身不记录这种信息。

To discover why the unit is being included in your program, there's an easier way, though. 要了解为什么该单元被包含在您的程序中,有一种更简单的方法。 Simply delete (or hide) the unit. 只需删除(或隐藏)单位即可。 Compilation will fail, and the compiler will point at the uses clause that mentions the nonexistent unit. 编译将失败,编译器将指向提及不存在单元的uses子句。

My answer in the question Can I determine the order in which my units have been initialized? 我在问题中的答案我可以确定我的单位初始化的顺序吗? can help here. 可以帮到这里。

It will list the load order of units and it's likely that the unit before is responsible for loading it. 它将列出单位的加载顺序,并且之前的单位可能负责加载它。

When I find such a problem in my compilations, I do the following: 当我在编辑中发现这样的问题时,我会执行以下操作:

  1. Inspect IDE library path. 检查IDE库路径。 Remove unnecessary and extraneous directories. 删除不必要的和无关的目录。

  2. Inspect project search path. 检查项目搜索路径。 Remove unnecessary and extraneous directories. 删除不必要的和无关的目录。

  3. Delete ALL DCUS. 删除所有DCUS。

  4. Find all Windows Vista/Windows 7/Windows8 "virtualstore" content and remove, as well, find any extraneous BPL or DCP, and remove. 找到所有Windows Vista / Windows 7 / Windows8“虚拟商店”内容并删除,同时找到任何无关的BPL或DCP,然后删除。

  5. Create a UnitAlias for the undesired unit. 为不需要的单元创建UnitAlias。 unit Alias "UnwantedUnit=GoAway". 单位别名“UnwantedUnit = GoAway”。

  6. Build. 建立。 (Always use Build, not Compile, in such situations) (在这种情况下,始终使用Build,而不是编译)

This makes finding the unit that fails much easier. 这使得找到失败的单位变得容易得多。

Rename all de occurences of the .pas file in your filesystem and remove all the corresponding DCU files. 重命名文件系统中.pas文件的所有出现并删除所有相应的DCU文件。 Then build your project. 然后构建您的项目。 If a uses is made, the compiler will spot it. 如果进行了使用,编译器将发现它。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM