]> sigrok.org Git - pulseview.git/commitdiff
build: Limit auto-versioning to git revision hash
authorDaniel Elstner <redacted>
Mon, 2 Nov 2015 21:14:39 +0000 (22:14 +0100)
committerDaniel Elstner <redacted>
Mon, 2 Nov 2015 21:14:39 +0000 (22:14 +0100)
When building from a git checkout and HEAD does not exactly match
a tag, append the shortened revision hash to the hardcoded version
string. Do not attempt to provide any information beyond that.

This brings the PulseView versioning in line with the other modules
in the sigrok stack.

CMake/GetGitRevisionDescription.cmake
CMake/writepackageversion.cmake [deleted file]
CMakeLists.txt

index 611b2969b33c87e98aff97eb759cf84bb9bb8dc9..c8d27f2e8ce494c96404086ce58982239916a44c 100644 (file)
@@ -107,7 +107,7 @@ function(git_describe _var)
        execute_process(COMMAND
                "${GIT_EXECUTABLE}"
                describe
-#              ${hash} commented to make --dirty work
+               ${hash}
                ${ARGN}
                WORKING_DIRECTORY
                "${CMAKE_SOURCE_DIR}"
diff --git a/CMake/writepackageversion.cmake b/CMake/writepackageversion.cmake
deleted file mode 100644 (file)
index 6426cec..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-# Include a version file in source packages, so that the version derived
-# from the git repository becomes available for builds from source tarballs.
-
-if(NOT CPACK_INSTALL_CMAKE_PROJECTS)
-       file(WRITE "${CPACK_TEMPORARY_DIRECTORY}/VERSION"
-               "${CPACK_SOURCE_PACKAGE_FILE_NAME}")
-endif()
index caf2eac3fedc3a063068ebdfb2b8f4c6808d7045..a82953cc166141af626ace0e5d2b3a285bf20eea 100644 (file)
@@ -124,26 +124,14 @@ set(PV_DESCRIPTION "A GUI for sigrok")
 set(PV_VERSION_STRING "0.3.0")
 
 include(GetGitRevisionDescription)
-git_describe(PV_TAG_VERSION_STRING --tags --dirty)
 
-if(NOT PV_TAG_VERSION_STRING AND EXISTS "${PROJECT_SOURCE_DIR}/VERSION")
-       # Read the version from a file that is distributed with
-       # the source package (see writepackageversion.cmake).
-       file(STRINGS "${PROJECT_SOURCE_DIR}/VERSION" PV_TAG_VERSION_STRING LIMIT_COUNT 1)
-endif()
-
-if(PV_TAG_VERSION_STRING MATCHES
-               "^pulseview-([0-9]+\\.[0-9]+\\.[0-9]+)(-[0-9a-z]+)?(-g[-0-9a-z]+)?$")
-       set(PV_TAG_VERSION ${CMAKE_MATCH_1})
-       set(PV_TAG_PATCHLEVEL ${CMAKE_MATCH_2})
-       set(PV_TAG_REVHASH ${CMAKE_MATCH_3})
-
-       if(PV_VERSION_STRING VERSION_GREATER ${PV_TAG_VERSION})
-               # Tagged version older than current one: indicate pre-release.
-               set(PV_VERSION_STRING "${PV_VERSION_STRING}-pre${PV_TAG_REVHASH}")
-       else()
-               # For post-release changes, indicate the patch level.
-               set(PV_VERSION_STRING "${PV_TAG_VERSION}${PV_TAG_PATCHLEVEL}${PV_TAG_REVHASH}")
+# Append the revision hash unless we are exactly on a tagged release.
+git_describe(PV_TAG_VERSION_STRING --match "pulseview-${PV_VERSION_STRING}" --exact-match)
+if(NOT PV_TAG_VERSION_STRING)
+       get_git_head_revision(PV_REVSPEC PV_HASH)
+       if(PV_HASH)
+               string(SUBSTRING "${PV_HASH}" 0 7 PV_SHORTHASH)
+               set(PV_VERSION_STRING "${PV_VERSION_STRING}-git-${PV_SHORTHASH}")
        endif()
 endif()
 
@@ -472,7 +460,6 @@ set(CPACK_RESOURCE_FILE_LICENSE ${CMAKE_CURRENT_SOURCE_DIR}/COPYING)
 set(CPACK_SOURCE_IGNORE_FILES ${CMAKE_CURRENT_BINARY_DIR} ".gitignore" ".git")
 set(CPACK_SOURCE_PACKAGE_FILE_NAME "${CMAKE_PROJECT_NAME}-${PV_VERSION_STRING}")
 set(CPACK_SOURCE_GENERATOR "TGZ")
-set(CPACK_INSTALL_SCRIPT ${CMAKE_CURRENT_SOURCE_DIR}/CMake/writepackageversion.cmake)
 
 include(CPack)