From 5bfffd6f295678aedd53a53da77e0eaaafc21140 Mon Sep 17 00:00:00 2001 From: Brad King Date: Fri, 23 Apr 2010 09:44:23 -0400 Subject: [PATCH] New version scheme to support branchy workflow Prepare to switch to the workflow described by "git help workflows". In this workflow, the "master" branch is always used to integrate topics ready for release. Brand new work merges into a "next" branch instead. We need a new versioning scheme to work this way because the version on "master" must always increase. We no longer use an even/odd minor number to distinguish releases from development versions. Since we still support cvs checkout of our source tree we cannot depend on "git describe" to compute a version number based on the history graph. We can use the CCYYMMDD nightly date stamp to get a monotonically increasing version component. The new version format is "major.minor.patch.(tweak|date)". Releases use a tweak level in the half-open range [0,20000000), which is smaller than any current or future date. For tweak=0 we do not show the tweak component, leaving the format "major.minor.patch" for most releases. Development versions use date=CCYYMMDD for the tweak level. The major.minor.patch part of development versions on "master" always matches the most recent release. For example, a first-parent traversal of "master" might see v2.8.1 2.8.1.20100422 v2.8.2 | | | ----o----o----o----o----o----o----o----o---- Since the date appears in the tweak component, the next release can increment the patch level (or any more significant component) to be greater than any version leading to it. Topic branches not ready for release are published only on "next" so we know that all versions on master lead between two releases. --- CMakeLists.txt | 29 ++++++++++++++++++++--------- Source/cmDocumentVariables.cxx | 14 +++++++++++--- Source/cmMakefile.cxx | 8 +++----- Source/cmVersion.cxx | 3 ++- Source/cmVersion.h | 1 + Source/cmVersionConfig.h.in | 3 ++- Source/cmVersionMacros.h | 19 +++---------------- bootstrap | 25 ++++++++++++++++--------- 8 files changed, 58 insertions(+), 44 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 4cd11c458..f56beb371 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -339,18 +339,29 @@ ENDMACRO (CMAKE_BUILD_UTILITIES) SET(CMake_VERSION_MAJOR 2) SET(CMake_VERSION_MINOR 9) SET(CMake_VERSION_PATCH 0) +#SET(CMake_VERSION_TWEAK 0) -# We use odd minor numbers for development versions. -# Use a date for the development patch level. -IF("${CMake_VERSION_MINOR}" MATCHES "[13579]$") +# Releases define a tweak level. +IF(DEFINED CMake_VERSION_TWEAK) + SET(CMake_VERSION_IS_RELEASE 1) +ELSE() + SET(CMake_VERSION_IS_RELEASE 0) + + # Use the date as the tweak level. INCLUDE(${CMake_SOURCE_DIR}/Source/kwsys/kwsysDateStamp.cmake) - SET(CMake_VERSION_PATCH + SET(CMake_VERSION_TWEAK "${KWSYS_DATE_STAMP_YEAR}${KWSYS_DATE_STAMP_MONTH}${KWSYS_DATE_STAMP_DAY}" ) -ENDIF("${CMake_VERSION_MINOR}" MATCHES "[13579]$") +ENDIF() -SET(CMake_VERSION "${CMake_VERSION_MAJOR}.${CMake_VERSION_MINOR}") -SET(CMake_VERSION_FULL "${CMake_VERSION}.${CMake_VERSION_PATCH}") +# Compute the full version string. +SET(CMake_VERSION ${CMake_VERSION_MAJOR}.${CMake_VERSION_MINOR}.${CMake_VERSION_PATCH}) +IF(${CMake_VERSION_TWEAK} GREATER 0) + SET(CMake_VERSION ${CMake_VERSION}.${CMake_VERSION_TWEAK}) +ENDIF() +IF(CMake_VERSION_RC) + SET(CMake_VERSION ${CMake_VERSION}-rc${CMake_VERSION_RC}) +ENDIF() # Include the standard Dart testing module ENABLE_TESTING() @@ -370,9 +381,9 @@ SET(LIBRARY_OUTPUT_PATH "" CACHE INTERNAL # install tree. SET(CMAKE_SKIP_RPATH ON CACHE INTERNAL "CMake does not need RPATHs.") -SET(CMAKE_DATA_DIR "/share/cmake-${CMake_VERSION}" CACHE STRING +SET(CMAKE_DATA_DIR "/share/cmake-${CMake_VERSION_MAJOR}.${CMake_VERSION_MINOR}" CACHE STRING "Install location for data (relative to prefix).") -SET(CMAKE_DOC_DIR "/doc/cmake-${CMake_VERSION}" CACHE STRING +SET(CMAKE_DOC_DIR "/doc/cmake-${CMake_VERSION_MAJOR}.${CMake_VERSION_MINOR}" CACHE STRING "Install location for documentation (relative to prefix).") SET(CMAKE_MAN_DIR "/man" CACHE STRING "Install location for man pages (relative to prefix).") diff --git a/Source/cmDocumentVariables.cxx b/Source/cmDocumentVariables.cxx index c6f9ba5f7..b5830210f 100644 --- a/Source/cmDocumentVariables.cxx +++ b/Source/cmDocumentVariables.cxx @@ -250,13 +250,21 @@ void cmDocumentVariables::DefineVariables(cmake* cm) "This specifies the patch version of the CMake" " executable being run.",false, "Variables that Provide Information"); + cm->DefineProperty + ("CMAKE_TWEAK_VERSION", cmProperty::VARIABLE, + "The tweak version of cmake (i.e. the 1 in X.X.X.1).", + "This specifies the tweak version of the CMake executable being run. " + "Releases use tweak < 20000000 and development versions use the date " + "format CCYYMMDD for the tweak level." + ,false, "Variables that Provide Information"); cm->DefineProperty ("CMAKE_VERSION", cmProperty::VARIABLE, - "The full version of cmake in major.minor.patch format.", + "The full version of cmake in major.minor.patch[.tweak] format.", "This specifies the full version of the CMake executable being run. " "This variable is defined by versions 2.6.3 and higher. " - "See variables CMAKE_MAJOR_VERSION, CMAKE_MINOR_VERSION, and " - "CMAKE_PATCH_VERSION for individual version components.", false, + "See variables CMAKE_MAJOR_VERSION, CMAKE_MINOR_VERSION, " + "CMAKE_PATCH_VERSION, and CMAKE_TWEAK_VERSION " + "for individual version components.", false, "Variables that Provide Information"); cm->DefineProperty diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index d09188ad2..e51ee65f9 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -2368,11 +2368,9 @@ void cmMakefile::AddDefaultDefinitions() this->AddDefinition("CMAKE_MAJOR_VERSION", temp); sprintf(temp, "%d", cmVersion::GetPatchVersion()); this->AddDefinition("CMAKE_PATCH_VERSION", temp); - sprintf(temp, "%u.%u.%u", - cmVersion::GetMajorVersion(), - cmVersion::GetMinorVersion(), - cmVersion::GetPatchVersion()); - this->AddDefinition("CMAKE_VERSION", temp); + sprintf(temp, "%d", cmVersion::GetTweakVersion()); + this->AddDefinition("CMAKE_TWEAK_VERSION", temp); + this->AddDefinition("CMAKE_VERSION", cmVersion::GetCMakeVersion()); this->AddDefinition("CMAKE_FILES_DIRECTORY", cmake::GetCMakeFilesDirectory()); diff --git a/Source/cmVersion.cxx b/Source/cmVersion.cxx index bde5f9812..047d24d74 100644 --- a/Source/cmVersion.cxx +++ b/Source/cmVersion.cxx @@ -16,8 +16,9 @@ unsigned int cmVersion::GetMajorVersion() { return CMake_VERSION_MAJOR; } unsigned int cmVersion::GetMinorVersion() { return CMake_VERSION_MINOR; } unsigned int cmVersion::GetPatchVersion() { return CMake_VERSION_PATCH; } +unsigned int cmVersion::GetTweakVersion() { return CMake_VERSION_TWEAK; } const char* cmVersion::GetCMakeVersion() { - return CMake_VERSION_FULL CMake_VERSION_RC_SUFFIX; + return CMake_VERSION; } diff --git a/Source/cmVersion.h b/Source/cmVersion.h index f267ab6f6..e31352476 100644 --- a/Source/cmVersion.h +++ b/Source/cmVersion.h @@ -28,6 +28,7 @@ public: static unsigned int GetMajorVersion(); static unsigned int GetMinorVersion(); static unsigned int GetPatchVersion(); + static unsigned int GetTweakVersion(); static const char* GetCMakeVersion(); }; diff --git a/Source/cmVersionConfig.h.in b/Source/cmVersionConfig.h.in index ee6eca7e0..76bc8fe94 100644 --- a/Source/cmVersionConfig.h.in +++ b/Source/cmVersionConfig.h.in @@ -12,4 +12,5 @@ #define CMake_VERSION_MAJOR @CMake_VERSION_MAJOR@ #define CMake_VERSION_MINOR @CMake_VERSION_MINOR@ #define CMake_VERSION_PATCH @CMake_VERSION_PATCH@ -#cmakedefine CMake_VERSION_RC @CMake_VERSION_RC@ +#define CMake_VERSION_TWEAK @CMake_VERSION_TWEAK@ +#define CMake_VERSION "@CMake_VERSION@" diff --git a/Source/cmVersionMacros.h b/Source/cmVersionMacros.h index 412db6d46..67f58ca41 100644 --- a/Source/cmVersionMacros.h +++ b/Source/cmVersionMacros.h @@ -14,22 +14,9 @@ #include "cmVersionConfig.h" -#define CMAKE_TO_STRING(x) CMAKE_TO_STRING0(x) -#define CMAKE_TO_STRING0(x) #x - -#define CMake_VERSION \ - CMAKE_TO_STRING(CMake_VERSION_MAJOR) "." \ - CMAKE_TO_STRING(CMake_VERSION_MINOR) - -#define CMake_VERSION_FULL \ - CMAKE_TO_STRING(CMake_VERSION_MAJOR) "." \ - CMAKE_TO_STRING(CMake_VERSION_MINOR) "." \ - CMAKE_TO_STRING(CMake_VERSION_PATCH) - -#if !(CMake_VERSION_MINOR & 1) && defined(CMake_VERSION_RC) -# define CMake_VERSION_RC_SUFFIX "-rc" CMAKE_TO_STRING(CMake_VERSION_RC) -#else -# define CMake_VERSION_RC_SUFFIX "" +#define CMake_VERSION_TWEAK_IS_RELEASE(tweak) ((tweak) < 20000000) +#if CMake_VERSION_TWEAK_IS_RELEASE(CMake_VERSION_TWEAK) +# define CMake_VERSION_IS_RELEASE 1 #endif #endif diff --git a/bootstrap b/bootstrap index bcd11a560..c018b3c75 100755 --- a/bootstrap +++ b/bootstrap @@ -30,17 +30,22 @@ cmake_date_stamp_component() cmake_system=`uname` cmake_source_dir=`cd "\`dirname \"$0\"\`";pwd` cmake_binary_dir=`pwd` + +# Load version information. cmake_version_major="`cmake_version_component MAJOR`" cmake_version_minor="`cmake_version_component MINOR`" -if echo "${cmake_version_minor}" | grep "[0-9]*[13579]" > /dev/null 2>&1; then - cmake_version_patch="`cmake_date_stamp_component YEAR``cmake_date_stamp_component MONTH``cmake_date_stamp_component DAY`" -else - cmake_version_patch="`cmake_version_component PATCH`" +cmake_version_patch="`cmake_version_component PATCH`" +cmake_version="${cmake_version_major}.${cmake_version_minor}.${cmake_version_patch}" +cmake_version_tweak="`cmake_version_component TWEAK`" +if [ "x$cmake_version_tweak" = "x" ]; then + cmake_version_tweak="`cmake_date_stamp_component YEAR``cmake_date_stamp_component MONTH``cmake_date_stamp_component DAY`" fi -cmake_version="${cmake_version_major}.${cmake_version_minor}" -cmake_version_full="${cmake_version_major}.${cmake_version_minor}.${cmake_version_patch}" -cmake_data_dir="/share/cmake-${cmake_version}" -cmake_doc_dir="/doc/cmake-${cmake_version}" +if [ "$cmake_version_tweak" != "0" ]; then + cmake_version="${cmake_version}.${cmake_version_tweak}" +fi + +cmake_data_dir="/share/cmake-${cmake_version_major}.${cmake_version_minor}" +cmake_doc_dir="/doc/cmake-${cmake_version_major}.${cmake_version_minor}" cmake_man_dir="/man" cmake_init_file="" cmake_bootstrap_system_libs="" @@ -312,7 +317,7 @@ Directory and file names: # Display CMake bootstrap usage cmake_version_display() { - echo "CMake ${cmake_version_full}, Copyright 2000-2009 Kitware, Inc." + echo "CMake ${cmake_version}, Copyright 2000-2009 Kitware, Inc." } # Display CMake bootstrap error, display the log file and exit @@ -1246,6 +1251,8 @@ fi cmake_report cmVersionConfig.h${_tmp} "#define CMake_VERSION_MAJOR ${cmake_version_major}" cmake_report cmVersionConfig.h${_tmp} "#define CMake_VERSION_MINOR ${cmake_version_minor}" cmake_report cmVersionConfig.h${_tmp} "#define CMake_VERSION_PATCH ${cmake_version_patch}" +cmake_report cmVersionConfig.h${_tmp} "#define CMake_VERSION_TWEAK ${cmake_version_tweak}" +cmake_report cmVersionConfig.h${_tmp} "#define CMake_VERSION \"${cmake_version}\"" cmake_report cmConfigure.h${_tmp} "#define CMAKE_ROOT_DIR \"${cmake_root_dir}\"" cmake_report cmConfigure.h${_tmp} "#define CMAKE_DATA_DIR \"${cmake_data_dir}\"" cmake_report cmConfigure.h${_tmp} "#define CMAKE_BOOTSTRAP"