Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

[SOLVED] qmake. How to get SVN revision number?



  • Could you please advise how to get SVN revision number via qmake?
    I need get SVN revision number and set it to the source code file after that build project.
    It's something like this :
    @
    rem batch file

    rem getting of the SVN revision number
    set SVN_revision = ....

    rem set it to the source file
    rem ...

    qmake myProject.pro release
    nmake release
    @


  • Lifetime Qt Champion



  • Thank you for your help! It helped me.

    In the result:
    We can use "svnversion -n", but there is some important point is that received result can be like a mix of "work copy revision number" and "head revision number" and it can has some symbol's flags (M or S or P, or all symbols together). "Here":http://svnbook.red-bean.com/en/1.7/svn.ref.svnversion.re.html is some detailed description.

    If you want to use only SVN revision number of "checked out work copy" you have to parse the result.
    Under Mac or other Unix we can use "svn info" and "grep". Or under all platforms we can use "svnversion -n" and parse result in the pro file.

    It can can something like that:
    @
    #all platforms:
    SVNN = $$system("svnversion -n")
    SVNN = $$replace(SVNN,"M","")
    SVNN = $$replace(SVNN,"S","")
    SVNN = $$replace(SVNN,"P","")
    SVNN = $$section(SVNN, :, 0, 0)

    #Unix, Mac
    SVNN = $$system("svn info | grep "Revision" | awk '{print $2}'")
    @


Log in to reply