]> git.uio.no Git - u/mrichter/AliRoot.git/commitdiff
ARVersion update
authoragrigora <alina.grigoras@cern.ch>
Mon, 15 Dec 2014 16:04:41 +0000 (17:04 +0100)
committeragrigora <alina.grigoras@cern.ch>
Mon, 15 Dec 2014 16:07:55 +0000 (17:07 +0100)
- Adding ALIROOT_SERIAL to ARVersion
- Adding  AliVersion class

STEER/STEERBase/AliVersion.cxx [new file with mode: 0644]
STEER/STEERBase/AliVersion.h [new file with mode: 0644]
STEER/STEERBase/CMakeLists.txt
cmake/ARVersion.h.tmp
cmake/CheckGitVersion.cmake

diff --git a/STEER/STEERBase/AliVersion.cxx b/STEER/STEERBase/AliVersion.cxx
new file mode 100644 (file)
index 0000000..5339586
--- /dev/null
@@ -0,0 +1,33 @@
+#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());
+}
diff --git a/STEER/STEERBase/AliVersion.h b/STEER/STEERBase/AliVersion.h
new file mode 100644 (file)
index 0000000..ba6120e
--- /dev/null
@@ -0,0 +1,25 @@
+#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);
+};
index eef5981e082311e251fed83395c485d535549417..2183040c59eaf9fb6b0c9550e8c249f7ce169eec 100644 (file)
@@ -20,7 +20,9 @@ set (MODULE STEERBase)
 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
@@ -107,6 +109,7 @@ set(SRCS
     AliVCaloTrigger.cxx
     AliVCluster.cxx
     AliVCuts.cxx
+    AliVersion.cxx
     AliVEvent.cxx
     AliVEventHandler.cxx
     AliVEventPool.cxx
index a2f2609c10ec5bddb5592c8140de520166118538..0402e382c78b0a029dcc90bd90974eedbcfa363e 100644 (file)
@@ -2,4 +2,5 @@
 #define ALIROOT_ARVersion
 #define ALIROOT_REVISION "@ALIROOT_REVISION@"
 #define ALIROOT_BRANCH "@ALIROOT_BRANCH@"
+#define ALIROOT_SERIAL @ALIROOT_SERIAL@
 #endif
index 61ab6ebe8d193a5d4c75bbe20a584e193e953796..0283dfd76eb96c4b240a3fcb801df13ca8d6038a 100644 (file)
@@ -42,20 +42,38 @@ if(EXISTS ${PROJECT_SOURCE_DIR}/.git/)
         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})
@@ -67,7 +85,8 @@ if(EXISTS ${PROJECT_SOURCE_DIR}/.git/)
         # 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!")