diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 4ff40beda3..f9b71b572a 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -266,6 +266,16 @@ include_directories(${LEAN_SOURCE_DIR}) # Git HASH include(GetGitRevisionDescription) get_git_head_revision(GIT_REFSPEC GIT_SHA1) +set(LEAN_PACKAGE_VERSION "NOT-FOUND") +if(${GIT_SHA1} MATCHES "GITDIR-NOTFOUND") + message(STATUS "Failed to read git_sha1") + if(EXISTS "${LEAN_SOURCE_DIR}/../bin/package_version") + file(STRINGS "${LEAN_SOURCE_DIR}/../bin/package_version" LEAN_PACKAGE_VERSION) + message(STATUS "Package version detected: ${LEAN_PACKAGE_VERSION}") + endif() +else() + message(STATUS "git commit sha1: ${GIT_SHA1}") +endif() configure_file("${LEAN_SOURCE_DIR}/githash.h.in" "${LEAN_BINARY_DIR}/githash.h") # Version diff --git a/src/shell/lean.cpp b/src/shell/lean.cpp index a983c668a4..b9e9bf3fa7 100644 --- a/src/shell/lean.cpp +++ b/src/shell/lean.cpp @@ -64,7 +64,11 @@ static void on_ctrl_c(int ) { static void display_header(std::ostream & out) { out << "Lean (version " << LEAN_VERSION_MAJOR << "." << LEAN_VERSION_MINOR << "." << LEAN_VERSION_PATCH; - if (!std::strcmp(g_githash, "GITDIR-NOTFOUND")) { + if (std::strcmp(g_githash, "GITDIR-NOTFOUND") == 0) { + if (std::strcmp(LEAN_PACKAGE_VERSION, "NOT-FOUND") != 0) { + out << ", package " << LEAN_PACKAGE_VERSION; + } + } else { out << ", commit " << std::string(g_githash).substr(0, 12); } out << ", " << LEAN_STR(LEAN_BUILD_TYPE) << ")\n"; diff --git a/src/version.h.in b/src/version.h.in index 13a89ae264..b488731852 100644 --- a/src/version.h.in +++ b/src/version.h.in @@ -1,4 +1,7 @@ -// the configured options and settings for Tutorial #define LEAN_VERSION_MAJOR @LEAN_VERSION_MAJOR@ #define LEAN_VERSION_MINOR @LEAN_VERSION_MINOR@ #define LEAN_VERSION_PATCH @LEAN_VERSION_PATCH@ + +// When git_sha1 is not avilable, lean reads bin/version file and +// assign its contents to LEAN_PACKAGE_VERSION +#define LEAN_PACKAGE_VERSION "@LEAN_PACKAGE_VERSION@"