diff options
author | Daniel Hahler <git@thequod.de> | 2019-10-02 03:45:59 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-10-02 03:45:59 +0200 |
commit | 30ae60e7cac7e77005aa429bc13f8ffa3ce64eb1 (patch) | |
tree | 8723d4c2441f61df7f2c590d1f50b8b3f2e44cef /src | |
parent | ac32426b94deabb6843fab797957f0064a54c5a5 (diff) | |
download | rneovim-30ae60e7cac7e77005aa429bc13f8ffa3ce64eb1.tar.gz rneovim-30ae60e7cac7e77005aa429bc13f8ffa3ce64eb1.tar.bz2 rneovim-30ae60e7cac7e77005aa429bc13f8ffa3ce64eb1.zip |
Fix/revisit git-describe enhancement (#11124)
* Fix/keep massaging git-describe result
Ref: https://github.com/neovim/neovim/pull/11117#issuecomment-536416223
* build: revisit generation of version from Git
Fixes "make clean && make", where "auto/versiondef.h" would be missing
since b18b84d - because BYPRODUCTS are apparently removed when cleaning.
This includes the following improvements/changes:
- do not run git-describe during CMake's configure phase just for
reporting
- do not print with changed Git version (too noisy, simplifies code)
* Move to src/nvim (included before config) for easier flow
* fallback to describe always, write empty include file
* update_version_stamp.lua: use prefix always
Diffstat (limited to 'src')
-rw-r--r-- | src/nvim/CMakeLists.txt | 36 |
1 files changed, 34 insertions, 2 deletions
diff --git a/src/nvim/CMakeLists.txt b/src/nvim/CMakeLists.txt index 27977e3a40..a64944ab0d 100644 --- a/src/nvim/CMakeLists.txt +++ b/src/nvim/CMakeLists.txt @@ -217,6 +217,34 @@ function(get_preproc_output varname iname) endif() endfunction() +# Handle generating version from Git. +set(use_git_version 0) +if(NVIM_VERSION_MEDIUM) + message(STATUS "NVIM_VERSION_MEDIUM: ${NVIM_VERSION_MEDIUM}") +elseif(${CMAKE_VERSION} VERSION_LESS "3.2.0") + message(STATUS "Skipping version-string generation (requires CMake 3.2.0+)") +elseif(EXISTS ${PROJECT_SOURCE_DIR}/.git) + find_program(GIT_EXECUTABLE git) + if(GIT_EXECUTABLE) + message(STATUS "Using NVIM_VERSION_MEDIUM from Git") + set(use_git_version 1) + else() + message(STATUS "Skipping version-string generation (cannot find git)") + endif() +endif() +if(use_git_version) + # Create a update_version_stamp target to update the version during build. + file(RELATIVE_PATH relbuild "${PROJECT_SOURCE_DIR}" "${CMAKE_BINARY_DIR}") + add_custom_target(update_version_stamp ALL + COMMAND ${LUA_PRG} scripts/update_version_stamp.lua + ${relbuild}/config/auto/versiondef_git.h + "v${NVIM_VERSION_MAJOR}.${NVIM_VERSION_MINOR}.${NVIM_VERSION_PATCH}" + WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} + BYPRODUCTS ${CMAKE_BINARY_DIR}/config/auto/versiondef_git.h) +else() + file(WRITE ${CMAKE_BINARY_DIR}/config/auto/versiondef_git.h "") +endif() + # NVIM_GENERATED_FOR_HEADERS: generated headers to be included in headers # NVIM_GENERATED_FOR_SOURCES: generated headers to be included in sources # NVIM_GENERATED_SOURCES: generated source files @@ -245,12 +273,16 @@ foreach(sfile ${NVIM_SOURCES} get_preproc_output(PREPROC_OUTPUT ${gf_i}) + set(depends "${HEADER_GENERATOR}" "${sfile}") + if(use_git_version AND "${f}" STREQUAL "version.c") + # Ensure auto/versiondef_git.h exists after "make clean". + list(APPEND depends update_version_stamp) + endif() add_custom_command( OUTPUT "${gf_c_h}" "${gf_h_h}" COMMAND ${CMAKE_C_COMPILER} ${sfile} ${PREPROC_OUTPUT} ${gen_cflags} ${C_FLAGS_ARRAY} COMMAND "${LUA_PRG}" "${HEADER_GENERATOR}" "${sfile}" "${gf_c_h}" "${gf_h_h}" "${gf_i}" - DEPENDS "${HEADER_GENERATOR}" "${sfile}" - ) + DEPENDS ${depends}) list(APPEND NVIM_GENERATED_FOR_SOURCES "${gf_c_h}") list(APPEND NVIM_GENERATED_FOR_HEADERS "${gf_h_h}") if(${d} MATCHES "^api$" AND NOT ${f} MATCHES "^api/helpers.c$") |