Using svnversion with svn:keywords

孤者浪人 提交于 2020-01-10 05:50:27

问题


I'm using Visual SVN on my Windows Box.

I have Repository Application, which has Framework as an svn:external. All well and good.

When I make a checkout of Application, I'd like to have the version of Application and Framework for inclusion in a footer file. This way I could have something like:

Application Version $ApplicationVersion$, Framework Version $FrameworkVersion$

Ordinarily, I understand I could use svn:keywords and add the revision - but as I understand it, svn:keywords apply on a per-file basis. A few sites have suggested using svnversion to produce the output for each variable, but I'm not entirely sure how to go about this.

Once again, on a Windows Box, using VisualSVN. I also develop on a Mac using Versions.app if it provides a more familiar interface for people to answer :)

Edit - my application is a PHP web application. As such, there is no compiling.

Thanks!


回答1:


To use svnversion, you need to integrate it into the build process. If you run it on a subversion checkout, it will output a string like 73597:73598, indicating what version your tree has (notice that different files may have different versions, plus files may have also local modifications). You put something like

CFLAGS+=-DSVNVERSION="\"`svnversion`\""  

into your Makefile, and then put

#define VERSION_STRING "Application version" SVNVERSION ", Framework version" FRAMEWORK_VERSION

into the code. If you don't use Make, or cannot readily have your build process run a command whose output produces a compiler command line option, then you can also use the subwcrev utility that comes with TortoiseSVN. You use that as a pre-build step, and have it transform some file with placeholders into a copy of the file with the placeholders replaced with the actual version; then your compilation will compile and link the new file.

Edit: For the PHP case, it is not possible to have the revision written automatically into a file on checkout or update. Instead, you could run svnversion on every PHP access, putting its output into the HTML response. If that gets too expensive, you can cache the svnversion result in a file and only regenerate the file if it is older than one hour (say), leaving it up to the user to remember to delete the file after an update to make it recompute the cache right away.



来源:https://stackoverflow.com/questions/1105753/using-svnversion-with-svnkeywords

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