Introducing version tracking
authorMichael Schuldt <michael.schuldt@bmw-carit.de>
Mon, 29 Aug 2011 15:01:49 +0000 (17:01 +0200)
committerMichael Schuldt <michael.schuldt@bmw-carit.de>
Mon, 29 Aug 2011 15:01:49 +0000 (17:01 +0200)
This will enhance the version which is used for the last build.
It is possible to set the version outside of the build, for rpm generation.

CMakeLists.txt
LayerManagerService/src/main.cpp

index 1c4e23c..021fa02 100644 (file)
@@ -25,15 +25,25 @@ set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/cmake/mo
 SET( ${PROJECT_NAME}_MAJOR_VERSION 0 )
 SET( ${PROJECT_NAME}_MINOR_VERSION 9 )
 SET( ${PROJECT_NAME}_PATCH_LEVEL 1 )
-set(VERSION ${${PROJECT_NAME}_MAJOR_VERSION}.${${PROJECT_NAME}_MINOR_VERSION}.${${PROJECT_NAME}_PATCH_LEVEL})
 
+SET(VERSION ${${PROJECT_NAME}_MAJOR_VERSION}.${${PROJECT_NAME}_MINOR_VERSION}.${${PROJECT_NAME}_PATCH_LEVEL})
+if(NOT DEFINED ILM_VERSION)
+execute_process(COMMAND git describe --tags WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} 
+                OUTPUT_VARIABLE ILM_VERSION 
+                OUTPUT_STRIP_TRAILING_WHITESPACE)
+endif(NOT DEFINED ILM_VERSION)
+                
 set(LICENSE "APACHE 2.0")
 
 set(GENIVI_PROJECT_VERSION ${VERSION})
+message(STATUS
+        "Build for Version ${VERSION} build ${ILM_VERSION}"
+        )
 
+set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DILM_VERSION='\"${ILM_VERSION}\"' " CACHE STRING "" FORCE)        
 
 ##################### RPM CONFIG ########################
-set(GENIVI_RPM_RELEASE "1${SVN_REVISION}")
+set(GENIVI_RPM_RELEASE "1${ILM_VERSION}")
 set(SPEC_DIR ".")
 #########################################################
 
@@ -76,7 +86,7 @@ set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra")
 
 option (WITH_FORCE_COPY 
         "Force Software Copy of Pixmaps" OFF)
-        
+
 if (WITH_XTHREADS)
 set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DUSE_XTHREADS" CACHE STRING "" FORCE)
 endif(WITH_XTHREADS)
index 7a87e5c..6c1e74a 100644 (file)
@@ -68,8 +68,10 @@ const char* USAGE_DESCRIPTION = "Usage:\t LayerManagerService [options]\n"
                                 "\t-d: displayName \t\n"
                                 "\t-f: loglevel file \t 0 [default] \n\t\t\t\t[0=disabled,1=error,2=info,3=warning,4=debug]\n"
                                 "\t-c: loglevel console \t 2 [default] \n\t\t\t\t[0=disabled,1=error,2=info,3=warning,4=debug]\n"
+                                "\t-v: show version info\t\n"
                                 "\nexample: LayerManagerService -w800 -h480 -d:0\n";
 
+const char* VERSION_STRING = ILM_VERSION;
 template<class T>
 T* getCreateFunction(string libname)
 {
@@ -123,7 +125,7 @@ void parseCommandLine(int argc, char **argv)
 {
     while (optind < argc)
     {
-        int option = getopt(argc, argv, "w::h::d::?::c::f::");
+        int option = getopt(argc, argv, "w::h::d::?::c::f::v::");
         switch (option)
         {
         case 'd':
@@ -147,8 +149,13 @@ void parseCommandLine(int argc, char **argv)
                 Log::fileLogLevel = (LOG_MODES) atoi(optarg);
             }
             break;
+        case 'v':
+            printf("LayerManagerService\nVersion: %s\n",VERSION_STRING);            
+            exit(-1);
+            break;
         case '?':   
         default:
+            printf("LayerManagerService\nVersion: %s\n",VERSION_STRING);
             puts(USAGE_DESCRIPTION);
             exit(-1);
         }