Add perforce support to showrev.sh
authorSam Lantinga
Wed, 08 Apr 2020 08:41:55 -0700
changeset 13711a375181874ce
parent 13710 a1a6885cff94
child 13712 b413bea8ccc0
Add perforce support to showrev.sh

In order to generate meaningful output from SDL_GetRevision()
build-scripts/showrev.sh
     1.1 --- a/build-scripts/showrev.sh	Wed Apr 08 08:34:27 2020 -0700
     1.2 +++ b/build-scripts/showrev.sh	Wed Apr 08 08:41:55 2020 -0700
     1.3 @@ -2,4 +2,24 @@
     1.4  #
     1.5  # Print the current source revision, if available
     1.6  
     1.7 -hg parents --template 'hg-{rev}:{node|short}' || (echo "hg-0:baadf00d"; exit 1)
     1.8 +SDL_ROOT=$(dirname $0)/..
     1.9 +cd $SDL_ROOT
    1.10 +
    1.11 +if [ -x "$(command -v hg)" ]; then
    1.12 +    rev="$(hg parents --template 'hg-{rev}:{node|short}' 2>/dev/null)"
    1.13 +    if [ "$?" == 0 ]; then
    1.14 +        echo $rev
    1.15 +        exit 0
    1.16 +    fi
    1.17 +fi
    1.18 +
    1.19 +if [ -x "$(command -v p4)" ]; then
    1.20 +    rev="$(p4 changes -m1 ./...\#have 2>/dev/null| awk '{print $2}')"
    1.21 +    if [ "$?" == 0 ]; then
    1.22 +        echo $rev
    1.23 +        exit 0
    1.24 +    fi
    1.25 +fi
    1.26 +
    1.27 +echo "hg-0:baadf00d"
    1.28 +exit 1