Delphi条件编译

发布于 2024-09-06 09:30:41 字数 158 浏览 3 评论 0原文

我需要知道是否有任何选项可以仅在源或任何使用的单元、包等已更改的情况下编译 delphi 项目。

如果这是不可能的,第二种选择:是否有任何选项可以生成完全相同的二进制文件,对同一项目进行两次编译。

谢谢。

编辑:该用法用于基于哈希的 WebUpdate。

I need to know if is there any option to compile a delphi project only if the source or any used unit, package etc has been changed.

If this is not possible, second alternative : Is there any option to generate exactly the same binary compiling two times the same project.

Thanks.

Edit: The usage is for a hash based WebUpdate.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

南烟 2024-09-13 09:30:41

Delphi“编译”将仅编译更改的单元。但如上所述,单元有数据,因此编译器可以检查哪些需要更新,哪些不需要。并且可执行文件可能会更改,因为构建过程可以重新排列 exe。您的网络更新不应使用文件哈希,而应使用版本信息来决定更新哪些内容和不更新哪些内容。这就是安装程序检查应替换哪些文件的方式。

A Delphi "compile" will compile only changed units. But as said, unit have data so the compiler can check which needs updating and which not. And the executable can change because the build process can rearrange the exe. Your web updates should not use a file hash, it should use version information to decide what to update and what not. That's the way installers check which files should be replaced.

风向决定发型 2024-09-13 09:30:41

Delphi 仅编译编译时更改的单元,并编译所有单元,无论构建时的更改状态如何。

在二进制层面上,Exe 从来都不相同。刚刚构建了一个项目两次,将 exe 重命名为 txt 扩展名,并将它们与 Beyond Compare 进行比较:它显示了差异。

Delphi compiles only changed units on a compile, and compiles all units regardless of change-status on a build.

Exe's are never the same, on a binary level. Just built a project twice, renamed the exe's to have a txt extension and compared them with Beyond Compare: it shows differences.

忘羡 2024-09-13 09:30:41

一个(困难的)解决方案:使用 Makefile 来创建你的 exes! makefile 允许您说“这个 exe 是使用这些命令从这些文件生成的”。仅当您列出的构成 exe 的文件中至少有一个比您的 exe 新时,Make 才会运行“这些命令”。

其中最困难的部分是设置组成 exe 的文件列表:您可以轻松获取 DPR/DPROJ 中列出的文件列表,但您还需要识别所有链接的资源 ($R),所有包含的文件 ($INCLUDE),所有由 Delphi 隐式编译的文件,因为它们在“uses”子句中使用并在库路径中找到。

为一般情况生成 Makefile 非常困难,但对于一个特定项目来说可能可行。例如,您可能认为您的文件仅依赖于 DPR 文件中列出的文件,然后确保将所有相关文件添加到 DPR。

One (hard) solution: Make your exes using a Makefile! A makefile allows you to say "this exe is made from those files, using those commands". Make will only run "those commands" if at least one of the files you list as making up your exe is newer then your exe.

The hard part in this is setting up the list of files that make up your exe: You can easily get the list of files listed in the DPR/DPROJ, but you'll also need to identify all the linked resources ($R), all the included files ($INCLUDE), all the files that are implictelly compiled by Delphi because they're used in the "uses" clauses and are found on the Library Path.

Generating a Makefile for the general case is very difficult, but for one particular project it might work. For example you might consider your file dependent on only the files listed in the DPR files and then make sure you add all the relevant files to the DPR.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文