diff options
author | Tim-Philipp Müller <tim@centricular.com> | 2020-09-23 19:27:34 +0100 |
---|---|---|
committer | Tim-Philipp Müller <tim@centricular.com> | 2020-10-21 11:45:54 +0000 |
commit | c3e48e63a2d2deeae6205ee746cc00c960c8c5c5 (patch) | |
tree | fe4958f05369efdb3afffb4cd7bf83b961deef2d /version.py | |
parent | a67735010dd7576fac7d5e30e0933a3be313b75e (diff) | |
download | cairo-c3e48e63a2d2deeae6205ee746cc00c960c8c5c5.tar.gz |
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.
Diffstat (limited to 'version.py')
-rwxr-xr-x | version.py | 31 |
1 files changed, 31 insertions, 0 deletions
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)) |