程序中添加svn版本信息

如果一个可执行文件能输出版本信息,会带来非常大的便利,本文就是介绍一种自动添加svn版本信息的方法。

Svn keywords可以实现自动更新,比如ID, Version, Author等,可以利用这些svn关键词来实现。主要的keywords如下所示:

     svn:keywords                          - Keywords to be expanded.  Valid keywords are:

     URL,HeadURL                       - The URL for the head version of the object.

     Author, LastChangedBy        - The last person to modify the file.

     Date, LastChangedDate       - The date/time the object was lastmodified.

     Rev, Revision,                         -The last revision the object changed.

     LastChangedRevision          - last revision

     Id                                                - A compressed summary of the previous 4 keywords.

     Header                                     - Similar to Id but includes the full URL.

 我在自己机器上试了一下,好像并非上述的每个关键词都能工作。

首先在.subversion/config文件中添加以下信息

enable-auto-props = yes

 [auto-props]
* = svn:keywords=Rev Author URL Date LastChangedRevision Id Header

我们可以这么实现,比如新建一个文件叫Conifg.h,内容如下

string version = "

$Rev$: Revision of last commit

$Author$: Author of last commit";

Svn check in以后会自动更新成如下内容:

$Rev:8466 $: Revision of last commit

$Author:zhangle $: Author of last commit

这样我们就可以把它include到main.cpp文件中,每次提交代码后就可以自动生成你指定的信息。代码中可以解析该string,获取当前的版本信息。
现在还有一个问题是需要Conifg.h的内容发生改变时,关键词才能自动扩展,所以还需要思考以下如何才能更加自动化。
————————————————
版权声明:本文为CSDN博主「zhanglehes」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/zhanglehes/article/details/38065097

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值