Skip to content

Commit

Permalink
chore(leanpkg/lean_version): recognize nightlies as releases separate…
Browse files Browse the repository at this point in the history
… from master
  • Loading branch information
Kha authored and leodemoura committed Mar 20, 2018
1 parent e247355 commit 0c0646f
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 3 deletions.
4 changes: 4 additions & 0 deletions leanpkg/leanpkg/lean_version.lean
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,16 @@ sformat!("{major}.{minor}.{patch}")
def lean_version_string :=
if lean.is_release then
lean_version_string_core
else if lean.special_version_desc ≠ "" then
lean.special_version_desc
else
"master"

def ui_lean_version_string :=
if lean.is_release then
lean_version_string_core
else if lean.special_version_desc ≠ "" then
lean.special_version_desc
else
"master (" ++ lean_version_string_core ++ ")"

Expand Down
4 changes: 4 additions & 0 deletions library/init/version.lean.in
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,7 @@ def lean.githash : string :=

def lean.is_release : bool :=
@LEAN_VERSION_IS_RELEASE@ ≠ 0

/-- Additional version description like "nightly-2018-03-11" -/
def lean.special_version_desc : string :=
"@LEAN_SPECIAL_VERSION_DESC@"
2 changes: 1 addition & 1 deletion script/setup_nightly.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,4 @@ else
fi

LEAN_VERSION_STRING="nightly-$(date -uI)"
OPTIONS+="-DLEAN_VERSION_STRING=$LEAN_VERSION_STRING"
OPTIONS+="-DLEAN_SPECIAL_VERSION_DESC=$LEAN_VERSION_STRING"
6 changes: 5 additions & 1 deletion src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,11 @@ set(LEAN_VERSION_MAJOR 3)
set(LEAN_VERSION_MINOR 3)
set(LEAN_VERSION_PATCH 1)
set(LEAN_VERSION_IS_RELEASE 0) # This number is 1 in the release revision, and 0 otherwise.
set(LEAN_VERSION_STRING "${LEAN_VERSION_MAJOR}.${LEAN_VERSION_MINOR}.${LEAN_VERSION_PATCH}" CACHE STRING "Lean version string")
set(LEAN_SPECIAL_VERSION_DESC "" CACHE STRING "Additional version description like 'nightly-2018-03-11'")
set(LEAN_VERSION_STRING "${LEAN_VERSION_MAJOR}.${LEAN_VERSION_MINOR}.${LEAN_VERSION_PATCH}")
if (LEAN_SPECIAL_VERSION_DESC)
set(LEAN_VERSION_STRING "${LEAN_VERSION_STRING}-${LEAN_SPECIAL_VERSION_DESC}")
endif()

set(LEAN_EXTRA_LINKER_FLAGS "" CACHE STRING "Additional flags used by the linker")
set(LEAN_EXTRA_CXX_FLAGS "" CACHE STRING "Additional flags used by the C++ compiler")
Expand Down
4 changes: 3 additions & 1 deletion src/library/util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1131,7 +1131,9 @@ void initialize_library_util() {

out << LEAN_VERSION_MAJOR << "."
<< LEAN_VERSION_MINOR << "." << LEAN_VERSION_PATCH;
if (std::strcmp(LEAN_GITHASH, "GITDIR-NOTFOUND") == 0) {
if (std::strlen(LEAN_SPECIAL_VERSION_DESC) > 0) {
out << ", " << LEAN_SPECIAL_VERSION_DESC;
} else if (std::strcmp(LEAN_GITHASH, "GITDIR-NOTFOUND") == 0) {
if (std::strcmp(LEAN_PACKAGE_VERSION, "NOT-FOUND") != 0) {
out << ", package " << LEAN_PACKAGE_VERSION;
}
Expand Down
3 changes: 3 additions & 0 deletions src/version.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
#define LEAN_VERSION_MINOR @LEAN_VERSION_MINOR@
#define LEAN_VERSION_PATCH @LEAN_VERSION_PATCH@

// Additional version description like "nightly-2018-03-11"
#define LEAN_SPECIAL_VERSION_DESC "@LEAN_SPECIAL_VERSION_DESC@"

// 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@"

0 comments on commit 0c0646f

Please sign in to comment.