开发者

Delphi RES files and Git

I have a big project written in Delphi an开发者_运维问答d I want to manage its sources using Git. I created Git repository, which includes my application's sources and 3rd party components. All that stuff is automatically building using msbuild.

The biggest problem is RES files. Some of them are updated every time I rebuild my application, some are not. Some have *.rc sources, some don't. I can't ignore all res files (.gitignore) because without resources my project will fail to build. Also, I can't include res files - they change from build to build, I don't want to see them in diffs.

What do you do with your *.res files under Git? Any advices?


Welcome to the club. The application .res file in Delphi is a pain in the lower back for everybody using source control. You want to use auto-inc-buildnumber but it messes up your scource control. What I have done is

  • split the icon and the version resources like this:

    {$R *_icon.res}

    {$R *._version.res}

  • disable auto inc of the buildnumber

  • add a pre-build event to the project that

    • increments the build number in a .ini file corresponding the project
    • generates a .rc file with the version info from the .ini file
    • compiles a .res file from the .rc file
  • add the *_icon.res file to source control, it never changes so this is safe

  • add the .ini file with the version info to source control, it is a text file so it is easy to diff

The tool I have written for generating the version .res file is free software, available here and also from OSDN


I keep my project RES files in git (those that match the name of the dpr).

I believe the only reason the project RES file would change every time you build is if you have increment build number set, which to me either means you need to keep the res in source control or you don't care about the build number so you should turn off that option.

I do also have RES files that I build from RC, which change every compile, so I have a gitignore for *.res and I then add git add -f project.res for the project RES files


By definition, RES files are compiled RC files. So ideally you should ignore all RES files and commit only RC changes. If it happened somehow that you don't have an RC source for some particular RES file, then add only this "orphan" RES file to git - such files shouldn't change from build to build (cause there is no RC file to generate them from). If for some strange reasons (Delphi, huh) such RES files do change, then you are doomed.

Bottom line: RES files are compilation targets - no different from other binaries (obj,exe,etc)


It's strongly advised to disable the "Auto increment build number" in the project settings, with any kind of version control system. This way it's 'safe' to add the .res files to the repository.

I have been searching for a long time for a way to auto-update the build number in the version info in the project's .res file, but the best thing is to update an extra .rc with the version info. In practice though, I generally update the build number to the current subversion revision number only right before the final build for a release of the binaries.


I don't know GIT, but under SVN I simply only "SVN ADD" the few that matter, and not the automatically generated ones. Since unversioned files are excluded from diffs, that's taken care off too then.


Could you:

  • ignore all .res files
  • generate the .res files that can be generate (compiling the resources script .rc files)
  • add only the .res files without .rc files to generate them: if you had specified in a .gitignore that they are to be ignored, then adding them is ok: they won't show up in the diff.
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜