Commits

Peter Hosey  committed 4b7b06d

Make generateHgRevision.sh only regenerate the hgRevision.h file when the revision has changed, cutting out a possible cause of #179.

  • Participants
  • Parent commits dc09185
  • Branches maintenance-1.2

Comments (0)

Files changed (3)

File Tools/printRevision/Makefile

+CFLAGS+=-std=c99 -include "$(HEADERPATH)"
+LDFLAGS+=
+
+printRevision: printRevision.o

File Tools/printRevision/printRevision.c

+//Note: hgRevision.h must be included on the command line. The Makefile does this when run by generateHgRevision.sh.
+#include <stdio.h>
+
+int main(void) {
+	return !printf("%s\n", HG_REVISION_STRING);
+}

File generateHgRevision.sh

 		REVISION=0
 	fi
 fi
+
+mkdir -p "`dirname "$HEADERPATH"`"
+
+if [[ -f "$HEADERPATH" ]]; then
+	#Determine whether the header already contains our current revision.
+	pushd Tools/printRevision > /dev/null
+	make HEADERPATH="../../$HEADERPATH" > /dev/null
+	LAST_REVISION=$(./printRevision)
+	popd > /dev/null
+
+	if [[ "$REVISION" -eq "$LAST_REVISION" ]]; then
+		#The revision has not changed! No need to rewrite the file.
+		exit 0
+	fi
+fi
+
 echo "*** Building Growl Revision: $REVISION"
-mkdir -p "`dirname "$HEADERPATH"`"
 
 echo "#define HG_REVISION $REVISION" > "$HEADERPATH"
 echo "#define HG_REVISION_STRING \"$REVISION\"" >> "$HEADERPATH"