diff options
author | Daniel Hahler <git@thequod.de> | 2019-09-30 00:10:29 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-09-30 00:10:29 +0200 |
commit | b18b84df5eab9829ecbef644ef0af226becf881d (patch) | |
tree | 64ee0eb30c2522cd34e7c2dadc6e8c765235f60c /scripts | |
parent | ce637d0ef1d6f76edfa667dd1ea6662992195b1c (diff) | |
download | rneovim-b18b84df5eab9829ecbef644ef0af226becf881d.tar.gz rneovim-b18b84df5eab9829ecbef644ef0af226becf881d.tar.bz2 rneovim-b18b84df5eab9829ecbef644ef0af226becf881d.zip |
build: run git-describe for dev version during build (#11117)
This avoids invoking CMake after a new commit, which might take 15s on
some systems.
Skipped on CMake < 3.2.0 (missing BYPRODUCTS support).
Co-Authored-By: Justin M. Keyes <justinkz@gmail.com>
Diffstat (limited to 'scripts')
-rw-r--r-- | scripts/update_version_stamp.lua | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/scripts/update_version_stamp.lua b/scripts/update_version_stamp.lua new file mode 100644 index 0000000000..f01642043a --- /dev/null +++ b/scripts/update_version_stamp.lua @@ -0,0 +1,45 @@ +#!/usr/bin/env lua +-- +-- Script to update the Git version stamp during build. +-- This is called via the custom update_version_stamp target in +-- src/nvim/CMakeLists.txt. +-- +-- arg[1]: file containing the last git-describe output +-- arg[2]: file in which to update the version string + +local function die(msg) + print(string.format('%s: %s', arg[0], msg)) + -- No error, fall back to using generated "-dev" version. + os.exit(0) +end + +if #arg ~= 2 then + die(string.format("Expected two args, got %d", #arg)) +end + +local stampfile = arg[1] +local stamp = io.open(stampfile, 'r') +if stamp then + stamp = stamp:read('*l') +end + +local current = io.popen('git describe --dirty'):read('*l') +if not current then + die('git-describe failed') +end + +if stamp ~= current then + if stamp then + print(string.format('git version changed: %s -> %s', stamp, current)) + end + local new_lines = {} + local versiondeffile = arg[2] + for line in io.lines(versiondeffile) do + if line:match("NVIM_VERSION_MEDIUM") then + line = '#define NVIM_VERSION_MEDIUM "'..current..'"' + end + new_lines[#new_lines + 1] = line + end + io.open(versiondeffile, 'w'):write(table.concat(new_lines, '\n') .. '\n') + io.open(stampfile, 'w'):write(current) +end |