Is there any simple automated way of finding out all the source files associated with a Delphi project?

若如初见. 提交于 2019-12-07 17:43:56

问题


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?


回答1:


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.




回答2:


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




回答3:


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.




回答4:


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.



来源:https://stackoverflow.com/questions/5228042/is-there-any-simple-automated-way-of-finding-out-all-the-source-files-associated

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!