Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt Creator and other tools
  4. [SOLVED] qmake. How to get SVN revision number?
Forum Updated to NodeBB v4.3 + New Features

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

Scheduled Pinned Locked Moved Qt Creator and other tools
4 Posts 3 Posters 6.7k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • _ Offline
    _ Offline
    _Dima
    wrote on 26 Mar 2014, 12:00 last edited by
    #1

    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
    @

    1 Reply Last reply
    0
    • S Offline
      S Offline
      SGaist
      Lifetime Qt Champion
      wrote on 26 Mar 2014, 21:37 last edited by
      #2

      Hi,

      "This":http://stackoverflow.com/questions/15837185/how-to-pass-a-cmd-command-output-to-a-define-macro-in-qmake might be of interest

      Hope it helps

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • _ Offline
        _ Offline
        _Dima
        wrote on 4 Apr 2014, 09:18 last edited by
        #3

        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}'")
        @

        1 Reply Last reply
        0
        • A Offline
          A Offline
          alexbu
          wrote on 19 Dec 2021, 22:15 last edited by
          #4

          SVNR = $$system("svn info --show-item=revision")

          1 Reply Last reply
          0

          • Login

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved