In order to make the last digit of the software version number, that is, the revision number is consistent with the revision number of the svn-managed code base and automatically updated, you can use vs2005 to generate events and subwcrev programs in SVN, the steps are as follows: Tools/Raw Materials
- Visual Studio 2005
- SVN client (tortoisesvn or other)
STEP/Method
-
- Compile a template file, for example, version_template.h. The content is as follows:
# Ifndef _ version_h _
# DEFINE _ version_h _
# Define ver_major 1
# Define ver_minor 0
# Define ver_revision $ wcrev $
# Endif //! _ Version_h _
-
- Find the subwcrev.exe executable file, which is generally located in the svn Client installation directory. For example, tortoisesvn is located in the bin folder of its installation directory. Here, I copied subwcrev.exe to the Code project directory for ease of use.
- On the project properties page of vs2005-> pre-generated events-> command line, add the following sentence:
$ (Solutiondir) \ subwcrev.exe $ (solutiondir) \ SRC \ qmlv \ version_template.h $ (solutiondir) \ SRC \ qmlv \ version. h
Subwcrev call Syntax:
Subwcrev workingcopypath [srcversionfile dstversionfile]
-
- After the code is compiled, the pre-generated event is triggered. vs2005 calls the subwcrev.exe program, replaces the macro $ wcrev $ in version_template.h with the current SVN revision number, and saves it as version. h file, version. h will be similar:
# Ifndef _ version_h _
# DEFINE _ version_h _
# Define ver_major 1
# Define ver_minor 0
# Define ver_revision 2821
# Endif //! _ Version_h _
- To display the version number in the program, reference the ver_revision macro.