diff options
author | kylo252 <59826753+kylo252@users.noreply.github.com> | 2022-07-14 09:12:27 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-07-14 00:12:27 -0700 |
commit | 912dbbdd77f382d90e4d8ef8ffa483037248b83a (patch) | |
tree | 80b529161cd80bd84c65ce4a1bf62a87c835fa32 /src | |
parent | b93cb481a20972c6af330de3e8974f641bccb355 (diff) | |
download | rneovim-912dbbdd77f382d90e4d8ef8ffa483037248b83a.tar.gz rneovim-912dbbdd77f382d90e4d8ef8ffa483037248b83a.tar.bz2 rneovim-912dbbdd77f382d90e4d8ef8ffa483037248b83a.zip |
build: gracefully handle error in git-version #19289
- only update git-version if both of these conditions are met:
- `git` command succeeds
- `versiondef_git.h` would change (SHA1-diff)
- else print a status/warning message
also move version generation out of Lua into cmake.
Diffstat (limited to 'src')
-rwxr-xr-x | src/nvim/CMakeLists.txt | 40 |
1 files changed, 13 insertions, 27 deletions
diff --git a/src/nvim/CMakeLists.txt b/src/nvim/CMakeLists.txt index de4af8e77b..360993de68 100755 --- a/src/nvim/CMakeLists.txt +++ b/src/nvim/CMakeLists.txt @@ -222,31 +222,17 @@ 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(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}/cmake.config/auto/versiondef_git.h - "v${NVIM_VERSION_MAJOR}.${NVIM_VERSION_MINOR}.${NVIM_VERSION_PATCH}${NVIM_VERSION_PRERELEASE}" - WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} - BYPRODUCTS ${CMAKE_BINARY_DIR}/cmake.config/auto/versiondef_git.h) -else() - file(WRITE ${CMAKE_BINARY_DIR}/cmake.config/auto/versiondef_git.h "") -endif() +set(NVIM_VERSION_GIT_H ${PROJECT_BINARY_DIR}/cmake.config/auto/versiondef_git.h) +add_custom_target(update_version_stamp + COMMAND ${CMAKE_COMMAND} + -DNVIM_VERSION_MAJOR=${NVIM_VERSION_MAJOR} + -DNVIM_VERSION_MINOR=${NVIM_VERSION_MINOR} + -DNVIM_VERSION_PATCH=${NVIM_VERSION_PATCH} + -DNVIM_VERSION_PRERELEASE=${NVIM_VERSION_PRERELEASE} + -DOUTPUT=${NVIM_VERSION_GIT_H} + -P ${PROJECT_SOURCE_DIR}/cmake/GenerateVersion.cmake + WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} + BYPRODUCTS ${NVIM_VERSION_GIT_H}) # NVIM_GENERATED_FOR_HEADERS: generated headers to be included in headers # NVIM_GENERATED_FOR_SOURCES: generated headers to be included in sources @@ -280,9 +266,9 @@ 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") + if("${f}" STREQUAL "version.c") # Ensure auto/versiondef_git.h exists after "make clean". - list(APPEND depends update_version_stamp) + list(APPEND depends "${NVIM_VERSION_GIT_H}") endif() add_custom_command( OUTPUT "${gf_c_h}" "${gf_h_h}" |