是否有任何简单的自动化方法可以找出与 Delphi 项目关联的所有源文件?

发布于 2024-10-20 22:03:20 字数 269 浏览 2 评论 0原文

我喜欢在发布版本时备份项目的源代码集。我使用 GExperts 项目备份,它似乎将项目管理器中的所有文件收集到 ZIP 文件中。您还可以将任意文件添加到此文件集中,但我始终意识到我不一定获得所有文件。除非我专门仔细检查使用条款并将我拥有的所有单元添加到项目中,否则我永远无法确定是否存储了重新创建可安装/可执行文件所需的所有文件。

我考虑过滚动一个应用程序来遍历一个项目,跟踪所有使用的单元并查看所有搜索路径,看看是否有可用于该单元的源文件,并构建一个文件列表来备份,但是嘿 - 也许有人已经完成了这项工作?

I like to backup up the source code set for a project when I release a version. I use GExperts project backups, which seems to gather up all the files in the project manager into the ZIP file. You can also add arbitrary files to this file set, but I'm always conscious of the fact that I haven't necessarily got all the files. Unless I specifically go though the uses clauses and add all the units I have sources for to the project, I'll never be sure of storing all the files necessary to recreate the installable/executable.

I've thought about rolling an app to traverse a project, following all the units used and looking down all the search paths and seeing if there is a source file available for that unit, and building a list of files to back up that way, but hey - maybe someone has already done the work?

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

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

发布评论

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

评论(4

聽兲甴掵 2024-10-27 22:03:20

您应该(强烈推荐)研究一下版本控制。

例如SVN (subversion)、CVS

这将允许您控制所有源代码的修订。它将允许您添加或删除源文件、回滚合并以及与管理项目源相关的所有其他好东西。

这有一天将为您节省$%#。

You should (highly recommend) look into Version Control.

e.g. SVN (subversion), CVS

This will allow you to control revisions of all of your source. It will allow you to add or remove source files, roll back merge and all other nice things related to managing project sources.

This WILL save your a$%# one day.

南城追梦 2024-10-27 22:03:20

您可以用两种方式解释您的问题:

  1. 我如何确保备份至少足够的文件,以便我可以构建项目
  2. 如何确保我备份的文件不是太多,以便我仍然可以构建项目

第一个是确保您可以构建系统,第二个是允许您清理未使用的文件。

对于两者来说,包含单独构建系统的版本控制系统是最佳选择。

然后,对于每组新的更改,您可以使用以下步骤来确保这两个条件都成立:

  1. 在日常开发系统上,将源代码的新版本签入版本控制系统。
  2. 在单独的构建系统上,获取最新版本的源代码控制系统。
  3. 在构建系统上构建项目;如果失败,请转到步骤 1,并将缺少的文件从开发系统添加到版本控制系统。
  4. 开始从项目中删除(逐一)您怀疑不需要的文件,然后重建,直到失败。
  5. 当构建失败时,从版本控制系统恢复该特定文件,然后使用下一个候选文件继续步骤 3
  6. 当构建成功时,您将拥有最小的文件集。
  7. 现在对版本控制系统和构建机器中的文件进行不同的概述。
  8. 将版本控制系统中但不在构建计算机上的文件标记为已弃用或已删除。

大多数版本控制系统都有很好的方法来生成开发或构建系统上的文件与版本控制系统中的文件之间的差异(通常针对您在版本控制系统中添加/删除/更新文件的每个历史点进行细粒度处理) )。

您想要一个单独的构建系统(或两个单独的开发系统)的原因是您希望它们是独立的:您使用一个用于开发,另一个用于检查构建是否仍然正常。

这是第一步,将来您可能希望将其扩展到持续集成系统(运行单元测试,自动创建产品设置等等)。

——杰罗恩

You can interpret your question in two ways:

  1. How can I make sure that I backup at least enough files so I can build the project
  2. How can I make sure that I backup not too many files so I can still build the project

The first is to make sure you can build the system at all, the second to allow you to clean up unused files.

For both, a version control system including a separate build system is the way to go.

You then - for each new set of changes - can use these steps to assure that both conditions hold:

  1. On your daily development system, check in the new revision of your source code into your version control system.
  2. On your separate build system, get the latest version of your source control system.
  3. Build the project on the build system; if this fails, go to Step 1, and add the missing files to your version control system from your development system
  4. Start removing (one-by-one) files from the project that you suspect are not needed, then rebuild until it fails.
  5. When the build fails, restore that particular file from the version control system, then continue step 3 with the next candidate
  6. When the build succeed you have the minimum set of files.
  7. Now make a difference overview of the files in your version control system, and the build machine.
  8. Mark the files that are in your version control system but not on your build machine as deprecated or deleted.

Most version control systems have good ways of generating a difference between the files on your development or build system against the files in the version control system (usually fine grained for each historic point in time you added/removed/updated files in your version control system).

The reason you want a separate build system (or two separate development systems) is that you want them to be independent: you use one for developing, and the other for checking if the build is still OK.

This is the first step that in the future you might want to extend this into a continuous integration system (that runs unit tests, automatically creates product setups and much more).

--jeroen

凡间太子 2024-10-27 22:03:20

我不确定您是否在询问版本控制或如何确保您已获得所有文件。

我偶尔运行的一个有用的实用程序是一个程序,它可以为我的 dcu 输出文件夹中的所有文件创建一个 DirList。将扩展名从 .dcu 更改为 .pas 为我提供了所有源代码文件的列表。

当然,它会错过 .inc 文件和其他非 .pas 文件,但也许这种思路在某种程度上对您有帮助?

该实用程序对我的价值在于,第二个内务管理实用程序会列出我的源代码树中没有相应 .dcu 文件的所有 .pas 文件。这(在完全编译所有程序之后)通常会显示一些不再使用的“垃圾”.pas 文件。

I'm not sure if you're asking about version control or how to be sure you've got all the files.

One useful utility I run occasionally is a program that makes a DirList of all of the files in my dcu output folder. Changing the extensions from .dcu to .pas gives me a list of all of the source code files.

Of course it misses .inc files and other non-.pas files, but perhaps this line of thinking would be helpful to you in some way?

The value of this utility to me is that a second housekeeping utility program then makes a list of all .pas files in my source tree that do not have corresponding .dcu files. This (after a full compile of all programs) generally reveals some "junk" .pas files that are no longer in use.

澜川若宁 2024-10-27 22:03:20

为了获取编译成可执行文件的所有单元的列表,您可以让编译器生成一个 MAP 文件。该文件将包含所有使用的单位的条目。

For getting a list of all units compiled into an executable, you could let the compiler generate a MAP file. This file will contain entries for all the units used.

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