[cairo-commit] Makefile.am meson.build version.py

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Wed Oct 21 12:51:24 UTC 2020


 Makefile.am |    1 +
 meson.build |    2 +-
 version.py  |   31 +++++++++++++++++++++++++++++++
 3 files changed, 33 insertions(+), 1 deletion(-)

New commits:
commit c3e48e63a2d2deeae6205ee746cc00c960c8c5c5
Author: Tim-Philipp Müller <tim at centricular.com>
Date:   Wed Sep 23 19:27:34 2020 +0100

    meson: extract meson version from cairo-version.h
    
    Same as autotools does. Arguably it would be better to do
    it the other way round and generate cairo-version.h from
    the version in meson.build or configure.ac but for now
    let's do this so it's at least in sync with the autotools
    build and only one file has to be edited for releases.

diff --git a/Makefile.am b/Makefile.am
index 7354c3e2e..3ad73fed7 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -56,6 +56,7 @@ EXTRA_DIST += \
 EXTRA_DIST += \
 	meson.build \
 	meson_options.txt \
+	version.py \
 	boilerplate/make-cairo-boilerplate-constructors.py \
 	boilerplate/meson.build \
 	src/meson.build \
diff --git a/meson.build b/meson.build
index 8ea73bee4..111edd099 100644
--- a/meson.build
+++ b/meson.build
@@ -1,6 +1,6 @@
 project('cairo', 'c', 'cpp',
   meson_version: '>= 0.54.0',
-  version: '1.17.3',
+  version: run_command(find_program('version.py'), check: true).stdout().strip(),
 )
 
 cc = meson.get_compiler('c')
diff --git a/version.py b/version.py
new file mode 100755
index 000000000..3b663abed
--- /dev/null
+++ b/version.py
@@ -0,0 +1,31 @@
+#!/usr/bin/env python3
+#
+# cairo version.py
+#
+# Extracts the version from cairo-version.h for the meson build files.
+#
+import os
+import sys
+
+if __name__ == '__main__':
+    srcroot = os.path.dirname(__file__)
+
+    version_major = None
+    version_minor = None
+    version_micro = None
+
+    f = open(os.path.join(srcroot, 'src', 'cairo-version.h'), 'r')
+    for line in f:
+        if line.startswith('#define CAIRO_VERSION_MAJOR '):
+            version_major = line[28:].strip()
+        if line.startswith('#define CAIRO_VERSION_MINOR '):
+            version_minor = line[28:].strip()
+        if line.startswith('#define CAIRO_VERSION_MICRO '):
+            version_micro = line[28:].strip()
+    f.close()
+
+    if not (version_major and version_minor and version_micro):
+       print('ERROR: Could not extract cairo version from cairo-version.h in', srcroot, file=sys.stderr)
+       sys.exit(-1)
+
+    print('{0}.{1}.{2}'.format(version_major, version_minor, version_micro))


More information about the cairo-commit mailing list