#!/bin/sh createVersion() { local gitVersion=`git describe --long --always --dirty` local versionLoc="../src/version.h" local currentVersion=$(grep -oP '"\K.*(?=")' $versionLoc 2>/dev/null) if [ ! -z "$1" ] && [ "$1" == "-d" ]; then gitVersion="${gitVersion}-debug" fi if [ "$gitVersion" == "$currentVersion" ]; then return 0 else echo "Creating version header: ${gitVersion}" cat < "$versionLoc" #define GITVERSION "${gitVersion}" VERSION_END fi } createVersion $*