[Spice-commits] server/meson.build

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Tue May 18 09:10:29 UTC 2021


 server/meson.build |   27 ++++++++++++++++++++-------
 1 file changed, 20 insertions(+), 7 deletions(-)

New commits:
commit 1201113acddcec947002e617f953f7a8f8b45c10
Author: Frediano Ziglio <freddy77 at gmail.com>
Date:   Wed Apr 21 08:55:50 2021 +0100

    build: Better version checks and handling for Meson
    
    Strip dirty and git hash.
    Check that there are at least 3 numbers at the beginning.
    
    Signed-off-by: Frediano Ziglio <freddy77 at gmail.com>

diff --git a/server/meson.build b/server/meson.build
index f9cdf9de..fe8d5d63 100644
--- a/server/meson.build
+++ b/server/meson.build
@@ -8,14 +8,27 @@ if meson.project_version().startswith('UNKNOWN')
   minor = '0'
   micro = '1'
 else
-  version_info = meson.project_version().split('.')
-  major = '@0@'.format(version_info[0])
-  minor = '@0@'.format(version_info[1])
-  micro = version_info[2].to_int()
-  if version_info.length() >= 4
-    micro += 1
+  additional_commits = false
+  increment_micro = 0
+  # remove the "-dirty" from version, increment micro later if found
+  version_info = meson.project_version().split('-dirty')
+  if version_info.length() > 1
+    increment_micro = 1
   endif
-  micro = '@0@'.format(micro)
+  # remove the "-" from version, increment micro later if found
+  version_info = version_info[0].split('-')
+  if version_info.length() > 1
+    additional_commits = true
+    increment_micro = 1
+  endif
+  version_info = version_info[0].split('.')
+  if ((not additional_commits and version_info.length() != 3)
+    or (additional_commits and version_info.length() != 4))
+    error('Invalid version @0@'.format(meson.project_version()))
+  endif
+  major = '@0@'.format(version_info[0].to_int())
+  minor = '@0@'.format(version_info[1].to_int())
+  micro = '@0@'.format(version_info[2].to_int() + increment_micro)
 endif
 
 cmd = run_command('printf', ['0x%02x%02x%02x', major, minor, micro], check : true)


More information about the Spice-commits mailing list