--- /dev/null
+#include "AliVersion.h"
+#include "ARVersion.h"
+#include <TClass.h>
+
+AliVersion* AliVersion::fgInstance = 0;
+
+AliVersion* AliVersion::Instance()
+{
+ if (!fgInstance) fgInstance = new AliVersion;
+ return (AliVersion*)fgInstance;
+}
+
+AliVersion::AliVersion()
+ : TNamed("alirootVersion", "AliROOT Version"),
+ fHash(ALIROOT_REVISION),
+ fTag(ALIROOT_BRANCH)
+{ SetUniqueID(ALIROOT_SERIAL); }
+
+Int_t AliVersion::Compare(const TObject* o) const
+{
+ if (!o->IsA()->InheritsFrom(AliVersion::Class()))
+ Fatal("Compare", "Cannot compare an AliVersion object to a %s object",
+ o->IsA()->GetName());
+ const AliVersion* av = static_cast<const AliVersion*>(o);
+ return (av->GetSerial() == GetSerial() ? 0 :
+ av->GetSerial() > GetSerial() ? -1 : 1);
+}
+
+void AliVersion::Print(Option_t *) const
+{
+ // print aliroot version
+ printf("AliRoot serial:\t%d\nAliRoot hash:\t%s\nAliRoot tag:\t%s\n",GetSerial(),fTag.Data(),fHash.Data());
+}
--- /dev/null
+#include <TNamed.h>
+
+class AliVersion : public TNamed
+{
+public:
+ AliVersion();
+ virtual ~AliVersion() {if (fgInstance==this) fgInstance=0;};
+ static AliVersion* Instance();
+ const TString& GetHash() const { return fHash; }
+ const TString& GetTag() const { return fTag; }
+ UInt_t GetSerial() const { return GetUniqueID(); }
+ Bool_t IsSortable() const { return kTRUE; }
+ Int_t Compare(const TObject* other) const;
+ virtual void Print(Option_t *opt) const;
+protected:
+ //
+ TString fHash; //last hash
+ TString fTag; //revision/tag name
+ static AliVersion* fgInstance;
+ //
+ AliVersion &operator=(const AliVersion& c); //dummy assignment operator
+ AliVersion(const AliVersion& c); //dummy copy constructor
+ //
+ ClassDef(AliVersion,1);
+};
include_directories(${AliRoot_SOURCE_DIR}/STEER/${MODULE})
# Additional includes - alphabetical order except ROOT
-include_directories(${ROOT_INCLUDE_DIRS})
+include_directories(${ROOT_INCLUDE_DIRS}
+ ${AliRoot_BINARY_DIR}/version
+ )
# Sources - alphabetical order
set(SRCS
AliVCaloTrigger.cxx
AliVCluster.cxx
AliVCuts.cxx
+ AliVersion.cxx
AliVEvent.cxx
AliVEventHandler.cxx
AliVEventPool.cxx
#define ALIROOT_ARVersion
#define ALIROOT_REVISION "@ALIROOT_REVISION@"
#define ALIROOT_BRANCH "@ALIROOT_BRANCH@"
+#define ALIROOT_SERIAL @ALIROOT_SERIAL@
#endif
if(NOT res EQUAL 0)
set(GIT_SHORT_SHA1 ${GIT_SHA1})
endif()
+
+ # generate the short version of the revision hash
+ execute_process(COMMAND git rev-list --count ${GIT_SHA1}
+ WORKING_DIRECTORY ${AliRoot_SOURCE_DIR}
+ OUTPUT_STRIP_TRAILING_WHITESPACE
+ RESULT_VARIABLE revcount
+ OUTPUT_VARIABLE ALIROOT_SERIAL)
+
# GIT_REFSPEC is empty for detached mode = tags in detached mode or checkout to specific hash
# returns the closest reference to the current hash
# name of the current tag or heads/branch in the case of branches
+ # Older git version of Git report only the name of the tag
+ # Newer version report tags/vAN-20141215
+ # Just in case we replace tags/ with nothing
git_describe(ALIROOT_GIT_TAG "--all" "--abbrev=0")
-
+
+ if(ALIROOT_GIT_TAG)
+ string(STRIP ${ALIROOT_GIT_TAG} ALIROOT_GIT_TAG)
+ string(REPLACE "tags/" "" ALIROOT_GIT_TAG ${ALIROOT_GIT_TAG})
+ endif(ALIROOT_GIT_TAG)
+
STRING(REGEX REPLACE "^(.+/)(.+)/(.*)$" "\\2" BRANCH_TYPE "${GIT_REFSPEC}" )
# the revision is not set in the case of a branch, it means we are doing development
# and the revision will trigger a reconfiguration
if(BRANCH_TYPE STREQUAL "heads")
set(ALIROOT_REVISION "ThisIsaBranchNoRevisionProvided")
+ set(ALIROOT_SERIAL 0)
STRING(REGEX REPLACE "^(.+/)(.+/)(.*)$" "\\3" SHORT_BRANCH "${GIT_REFSPEC}" )
+ message(STATUS "This is a working branch, ARVersion will not contain the revision and the serial number")
else()
set(SHORT_BRANCH ${ALIROOT_GIT_TAG})
set(ALIROOT_REVISION ${GIT_SHORT_SHA1})
# Replace - with . for rpm creation
string(REPLACE "-" "." ALIROOT_VERSION_RPM ${ALIROOT_VERSION})
- message(STATUS "Aliroot branch/tag: \"${ALIROOT_VERSION}\" - Revision: \"${GIT_SHORT_SHA1}\" ")
+
+ message(STATUS "Aliroot branch/tag: \"${ALIROOT_VERSION}\" - Revision: \"${GIT_SHORT_SHA1}\" - Serial: \"${ALIROOT_SERIAL}\"")
else()
message(STATUS "Git not installed. I can't tell you which revision you are using!")