Getting the subversion repository number into code

前端 未结 6 390
醉梦人生
醉梦人生 2020-11-30 01:24

I\'d like to implement a way of recording the version of a project within code, so that it can be used when testing and to help track bugs. It seems the best version number

6条回答
  •  情话喂你
    2020-11-30 01:33

    A good up-to-date solution:

    Create a Makefile containing the following line (in the same folder as YourFile.dox):

    sed "s~RevNumber~$(shell svnversion ../)~g" YourFile.dox > YourFileDummy.dox; doxygen YourFileDummy.dox
    

    And YourFile.dox should contain this:

    ...
    PROJECT_NUMBER         = "Revision RevNumber"
    ...
    

    Now:

    1. sed replaces RevNumber in the .dox with the output of svnversion (executed in the main folder of your repository) and saves the modified file to YourFileDummy.dox
    2. doxygen is executed on YourFileDummy.dox to generate the documentation
    3. Your documentation will now contain the revision number!

提交回复
热议问题