Changeset 14515


Ignore:
Timestamp:
Apr 24, 2015, 7:14:56 PM (2 years ago)
Author:
mikedld
Message:

#5934: Generate REVISION file and use it in case of missing reliable source

Location:
trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk

    • Property svn:ignore
      •  

        old new  
        33release
        44beta
         5REVISION
  • trunk/CMakeLists.txt

    r14514 r14515  
    5757endif()
    5858
     59set(TR_SCM_REVISION_FILE "${CMAKE_SOURCE_DIR}/REVISION")
     60set(TR_SCM_REVISION_RELIABLE ON)
     61
    5962if(IS_DIRECTORY ${CMAKE_SOURCE_DIR}/.svn)
    6063    find_package(Subversion)
     
    6265        Subversion_WC_INFO(${CMAKE_SOURCE_DIR} TR_SVN)
    6366        set(TR_SCM_REVISION "${TR_SVN_WC_REVISION}")
    64     endif()
    65 
    66     if("${TR_SCM_REVISION}" STREQUAL "")
    67         file(GLOB_RECURSE TR_ALL_SOURCES RELATIVE ${CMAKE_SOURCE_DIR} *.cc *.[chm] *.po)
    68         set(TR_SCM_REVISION 0)
    69         foreach(F ${TR_ALL_SOURCES})
    70             file(STRINGS ${F} F_ID REGEX "\\$Id:")
    71             if(F_ID MATCHES "\\$Id: [^ ]+ ([0-9]+) " AND CMAKE_MATCH_1 GREATER TR_SCM_REVISION)
    72                 set(TR_SCM_REVISION ${CMAKE_MATCH_1})
    73             endif()
    74         endforeach()
    7567    endif()
    7668elseif(IS_DIRECTORY ${CMAKE_SOURCE_DIR}/.git)
     
    8981endif()
    9082
     83if("${TR_SCM_REVISION}" STREQUAL "" AND EXISTS "${TR_SCM_REVISION_FILE}")
     84    file(READ "${TR_SCM_REVISION_FILE}" TR_SCM_REVISION)
     85    string(STRIP "${TR_SCM_REVISION}" TR_SCM_REVISION)
     86endif()
     87
     88if("${TR_SCM_REVISION}" STREQUAL "")
     89    # Give up and check the source files
     90    set(TR_SCM_REVISION 0)
     91    set(TR_SCM_REVISION_RELIABLE OFF)
     92    file(GLOB_RECURSE TR_ALL_SOURCES RELATIVE ${CMAKE_SOURCE_DIR} *.cc *.[chm] *.po)
     93    foreach(F ${TR_ALL_SOURCES})
     94        file(STRINGS ${F} F_ID REGEX "\\$Id:")
     95        if(F_ID MATCHES "\\$Id: [^ ]+ ([0-9]+) " AND CMAKE_MATCH_1 GREATER TR_SCM_REVISION)
     96            set(TR_SCM_REVISION ${CMAKE_MATCH_1})
     97        endif()
     98    endforeach()
     99endif()
     100
    91101if("${TR_SCM_REVISION}" STREQUAL "")
    92102    set(TR_SCM_REVISION 0)
     103else()
     104    if(TR_SCM_REVISION_RELIABLE)
     105        file(WRITE "${TR_SCM_REVISION_FILE}" "${TR_SCM_REVISION}")
     106    else()
     107        file(REMOVE "${TR_SCM_REVISION_FILE}")
     108    endif()
    93109endif()
    94110
  • trunk/Makefile.am

    r14447 r14515  
    4848  qt/CMakeLists.txt \
    4949  third-party/b64-01-newline.patch \
     50  third-party/b64-02-unsigned-char.patch \
    5051  third-party/b64.cmake \
    5152  third-party/dht.cmake \
    5253  third-party/event2.cmake \
    5354  third-party/natpmp.cmake \
     55  third-party/utp-01-ticket-5002.patch \
    5456  third-party/utp.cmake \
    5557  third-party/utp_config.h \
    5658  utils/CMakeLists.txt
    5759
     60if HAVE_REVISION_FILE
     61  EXTRA_DIST += REVISION
     62endif
     63
    5864dist-hook:
    59         rm -rf `find $(distdir)/qt -name .svn`
    60 
     65        find "$(distdir)/qt" "$(distdir)/cmake" -name .svn -exec rm -rf '{}' '+' -prune
    6166
    6267DISTCLEANFILES = \
  • trunk/configure.ac

    r14478 r14515  
    3232fi
    3333AM_CONDITIONAL(TR_UNSTABLE, test "x$supported_build" = "xno")
     34AM_CONDITIONAL(HAVE_REVISION_FILE, test -f REVISION)
    3435
    3536##
  • trunk/update-version-h.sh

    r14494 r14515  
    2121minor_version=`echo ${user_agent_prefix} | awk -F . '{print $2 + 0}'`
    2222
     23svn_revision_file=REVISION
     24svn_revision_reliable=true
     25
    2326if [ -n "$JENKINS_URL" -a -n "$SVN_REVISION" ]; then
    2427    # Jenkins automated build, use the set environment variables to avoid
     
    2932    # grab the version.
    3033    svn_revision=`svnversion -n . | cut -d: -f1 | cut -dM -f1 | cut -dS -f1`
     34elif [ -f "$svn_revision_file" ]; then
     35    svn_revision=`cat "$svn_revision_file"`
    3136else
    3237    # Give up and check the source files
    3338    svn_revision=`awk '/\\$Id: /{ if ($4>i) i=$4 } END {print i}' */*.cc */*.[chm] */*.po`
     39    svn_revision_reliable=false
     40fi
     41
     42if $svn_revision_reliable; then
     43    [ -f "$svn_revision_file" ] && [ "`cat "$svn_revision_file"`" -eq "$svn_revision" ] || echo "$svn_revision" > "$svn_revision_file"
     44else
     45    rm -f "$svn_revision_file"
    3446fi
    3547
Note: See TracChangeset for help on using the changeset viewer.