mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
Merge pull request #3584 from justinmk/gitdescribe
build: Use `git describe` for version strings.
This commit is contained in:
commit
ea4b8f9c8f
@ -47,24 +47,26 @@ if(NOT CMAKE_BUILD_TYPE)
|
||||
endif()
|
||||
|
||||
# Version tokens
|
||||
# - In a git repo, these tokens are _ignored_.
|
||||
# - If the current HEAD is tagged, the tag name is used.
|
||||
# - Otherwise the result of `git describe` is used.
|
||||
# - If not in a git repo (e.g. a tarball) these tokens set the version string.
|
||||
set(NVIM_VERSION_MAJOR 0)
|
||||
set(NVIM_VERSION_MINOR 1)
|
||||
set(NVIM_VERSION_PATCH 0)
|
||||
set(NVIM_VERSION_PRERELEASE "-dev")
|
||||
|
||||
file(TO_CMAKE_PATH ${CMAKE_CURRENT_LIST_DIR}/.git FORCED_GIT_DIR)
|
||||
include(GetGitRevisionDescription)
|
||||
if(NVIM_VERSION_PRERELEASE)
|
||||
get_git_head_revision(GIT_REFSPEC NVIM_VERSION_COMMIT)
|
||||
|
||||
# TODO(justinmk): UTC time would be nice here #1071
|
||||
git_timestamp(GIT_TIMESTAMP)
|
||||
if(GIT_TIMESTAMP)
|
||||
set(NVIM_VERSION_BUILD "+${GIT_TIMESTAMP}")
|
||||
get_git_head_revision(GIT_REFSPEC NVIM_VERSION_COMMIT)
|
||||
if(NVIM_VERSION_COMMIT) # is a git repo
|
||||
git_get_exact_tag(NVIM_VERSION_MEDIUM)
|
||||
if(NVIM_VERSION_MEDIUM) # is a tagged release
|
||||
unset(NVIM_VERSION_COMMIT)
|
||||
else() # is a dev build
|
||||
git_describe(NVIM_VERSION_MEDIUM)
|
||||
get_git_head_revision(GIT_REFSPEC NVIM_VERSION_COMMIT)
|
||||
endif()
|
||||
else()
|
||||
# If possible, get the Git tag for the current revision.
|
||||
git_get_exact_tag(NVIM_VERSION_COMMIT)
|
||||
set(NVIM_VERSION_BUILD "")
|
||||
endif()
|
||||
|
||||
set(NVIM_VERSION_BUILD_TYPE "${CMAKE_BUILD_TYPE}")
|
||||
|
@ -5,8 +5,9 @@
|
||||
#define NVIM_VERSION_MINOR @NVIM_VERSION_MINOR@
|
||||
#define NVIM_VERSION_PATCH @NVIM_VERSION_PATCH@
|
||||
#define NVIM_VERSION_PRERELEASE "@NVIM_VERSION_PRERELEASE@"
|
||||
#define NVIM_VERSION_BUILD "@NVIM_VERSION_BUILD@"
|
||||
#cmakedefine NVIM_VERSION_COMMIT "@NVIM_VERSION_COMMIT@"
|
||||
#cmakedefine NVIM_VERSION_MEDIUM "@NVIM_VERSION_MEDIUM@"
|
||||
|
||||
#define NVIM_VERSION_CFLAGS "@NVIM_VERSION_CFLAGS@"
|
||||
#define NVIM_VERSION_BUILD_TYPE "@NVIM_VERSION_BUILD_TYPE@"
|
||||
|
||||
|
@ -25,17 +25,18 @@
|
||||
#define STR_(x) #x
|
||||
#define STR(x) STR_(x)
|
||||
|
||||
// for the startup-screen ( ":intro" command )
|
||||
#define NVIM_VERSION_MEDIUM STR(NVIM_VERSION_MAJOR) "." STR(NVIM_VERSION_MINOR)
|
||||
|
||||
// for the ":version" command and "nvim --version"
|
||||
#define NVIM_VERSION_LONG "NVIM " NVIM_VERSION_MEDIUM "." STR(NVIM_VERSION_PATCH) NVIM_VERSION_PRERELEASE NVIM_VERSION_BUILD
|
||||
// for ":version", ":intro", and "nvim --version"
|
||||
#ifndef NVIM_VERSION_MEDIUM
|
||||
#define NVIM_VERSION_MEDIUM STR(NVIM_VERSION_MAJOR) "." STR(NVIM_VERSION_MINOR)\
|
||||
"." STR(NVIM_VERSION_PATCH) NVIM_VERSION_PRERELEASE
|
||||
#endif
|
||||
#define NVIM_VERSION_LONG "NVIM " NVIM_VERSION_MEDIUM
|
||||
|
||||
|
||||
char *Version = VIM_VERSION_SHORT;
|
||||
char *longVersion = NVIM_VERSION_LONG;
|
||||
char *longVersionWithDate = NVIM_VERSION_LONG " (compiled " __DATE__ " " __TIME__ ")";
|
||||
char *mediumVersion = NVIM_VERSION_MEDIUM;
|
||||
char *longVersionWithDate = NVIM_VERSION_LONG \
|
||||
" (compiled " __DATE__ " " __TIME__ ")";
|
||||
#ifdef NVIM_VERSION_COMMIT
|
||||
char *version_commit = "Commit: " NVIM_VERSION_COMMIT;
|
||||
#endif
|
||||
|
@ -3,7 +3,6 @@
|
||||
|
||||
// defined in version.c
|
||||
extern char* Version;
|
||||
extern char* mediumVersion;
|
||||
extern char* longVersion;
|
||||
|
||||
//
|
||||
|
Loading…
Reference in New Issue
Block a user