summaryrefslogtreecommitdiff
path: root/src/git_sha1.sh
blob: f44f078ac7b85a728d464e0d2636130d67ebb493 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#!/bin/bash

SOURCE_DIR=$1
FILE=$2

touch ${SOURCE_DIR}/${FILE}_tmp
if test -d ${SOURCE_DIR}/../.git; then
        if which git > /dev/null; then
            git --git-dir=${SOURCE_DIR}/../.git log -n 1 --oneline | \
                sed 's/^\([^ ]*\) .*/#define BEIGNET_GIT_SHA1 "git-\1"/' \
                > ${SOURCE_DIR}/${FILE}_tmp
        fi
fi

#updating ${SOURCE_DIR}/${FILE}
if ! cmp -s ${SOURCE_DIR}/${FILE}_tmp ${SOURCE_DIR}/${FILE}; then
                mv  ${SOURCE_DIR}/${FILE}_tmp ${SOURCE_DIR}/${FILE}
else
                rm  ${SOURCE_DIR}/${FILE}_tmp
fi