Enable Charm++/Converse build identification from program output
authorPhil Miller <mille121@illinois.edu>
Wed, 25 May 2011 23:07:02 +0000 (18:07 -0500)
committerPhil Miller <mille121@illinois.edu>
Thu, 26 May 2011 22:26:12 +0000 (17:26 -0500)
When making anything in the base build directory, check whether any
code has been changed or commited, and generate a version string
accordingly. Embed this string in a standalone object linked into
converse. Print the string at startup.

src/conv-core/convcore.c
src/scripts/Makefile
src/scripts/commitid.sh [new file with mode: 0755]

index 002384094f8c7bb1da7c6ceb903508d2221762cf..0a93295bc040a9865c2f7b2629d8241dfb76f322 100644 (file)
@@ -69,6 +69,8 @@
 #include "traceCoreCommon.h"    /* projector */
 #include "machineEvents.h"     /* projector */
 
+extern const char * const CmiCommitID;
+
 #if CMK_OUT_OF_CORE
 #include "conv-ooc.h"
 #endif
@@ -3426,6 +3428,10 @@ void ConverseCommonInit(char **argv)
 #if ! CMK_CMIPRINTF_IS_A_BUILTIN
   CmiIOInit(argv);
 #endif
+
+  if (CmiMyPe() == 0)
+    CmiPrintf("Converse/Charm++ Commit ID: %s\n", CmiCommitID);
+
 /* #if CONVERSE_POOL */
   CmiPoolAllocInit(30);  
 /* #endif */
index 3a7ef0c3f87aeee842ac7b5db0270cfe8e718f55..1358eaaf2898ea0fe27f13b602e5c5a98132eb55 100644 (file)
@@ -266,6 +266,15 @@ conv-autoconfig.h: configure config_opts.sh
        @. ./config_opts.sh; echo ./configure $(QUIET) $$CONFIG_OPTS;  \
        ./configure $(QUIET) $$CONFIG_OPTS && touch conv-autoconfig.h
 
+.PHONY: clean veryclean VERSION.new
+
+VERSION: VERSION.new
+       ./commitid.sh
+
+commitid.c: VERSION
+       echo "const char * const CmiCommitID = \"`cat VERSION`\";" > $@
+commitid.o: CC=$(CHARMC)
+
 headerlinks: dirs+sources Makefile $(ALLHEADERS)
        @[ "x$QUIET" = "x--quiet" ] || echo "Soft-linking headers..."
        -@for hdr in $(ALLHEADERS) ; do test ! -f "../include/$$hdr" && ./system_ln "../tmp/$$hdr" ../include ; done
@@ -374,7 +383,7 @@ LIBCONV_CORE= convcore.o conv-conds.o queueing.o msgmgr.o \
        converseProjections.o machineProjections.o \
        quiescence.o isomalloc.o mem-arena.o conv-counter.o \
        global-nop.o cmipool.o cpuaffinity.o cputopology.o  \
-       cmitls.o memoryaffinity.o
+       cmitls.o memoryaffinity.o commitid.o
 
 #############################################
 #Comlib Core objects that go into libck.a
diff --git a/src/scripts/commitid.sh b/src/scripts/commitid.sh
new file mode 100755 (executable)
index 0000000..eb400fe
--- /dev/null
@@ -0,0 +1,21 @@
+#!/bin/bash
+
+# Get a string describing the current code, and compare it to the
+# recorded value in VERSION. Copy over that if it's changed, so that
+# Make sees a more recent file.
+
+VOLD=""
+if [ -r VERSION ]
+then
+    VOLD=`cat VERSION`
+fi
+
+git describe --long --dirty > VERSION.new || touch VERSION.new
+
+VNEW=`cat VERSION.new`
+
+if [ "$VOLD" != "$VNEW" ]
+then
+    cp VERSION.new VERSION
+    echo Copying VERSION.new = $VNEW over VERSION = $VOLD
+fi