diff options
author | Emmanuele Bassi <ebassi@gnome.org> | 2020-04-19 18:37:46 +0100 |
---|---|---|
committer | Emmanuele Bassi <ebassi@gnome.org> | 2020-04-19 18:47:57 +0100 |
commit | 93faac9d8eb3af45c15eff738f2ff29dae5f1008 (patch) | |
tree | 33f114b96013a1885747f6384f3a70a967c08d29 | |
parent | bcf08abef0981456fd8400707431826e6473a63a (diff) | |
download | gtk+-93faac9d8eb3af45c15eff738f2ff29dae5f1008.tar.gz |
Add check on build system version
Since we're shipping both Meson and Autotools build systems for GTK3,
and both of them have a version field, it's bound to happen that the
GTK version defined in either build systems will go out of sync.
Let's add a check in both builds so that something will fail before
doing a release in case the versions do not match.
-rw-r--r-- | Makefile.am | 1 | ||||
-rwxr-xr-x | check-version.py | 159 | ||||
-rw-r--r-- | meson.build | 10 |
3 files changed, 170 insertions, 0 deletions
diff --git a/Makefile.am b/Makefile.am index a044e090dc..9a63602658 100644 --- a/Makefile.am +++ b/Makefile.am @@ -84,6 +84,7 @@ DISTCLEANFILES = \ dist-hook: mkdir $(distdir)/subprojects cp -p $(srcdir)/subprojects/*.wrap $(distdir)/subprojects + $(top_srcdir)/check-version.py $(top_srcdir)/configure.ac $(top_srcdir)/meson.build distclean-local: if test "$(srcdir)" = "."; then :; else \ diff --git a/check-version.py b/check-version.py new file mode 100755 index 0000000000..204a4f6049 --- /dev/null +++ b/check-version.py @@ -0,0 +1,159 @@ +#!/usr/bin/env python3 + +import re +import sys + +try: + configure_ac = sys.argv[1] +except Exception: + configure_ac = 'configure.ac' + +try: + meson_build = sys.argv[2] +except Exception: + meson_build = 'meson.build' + +CONFIGURE_MAJOR_VERSION_RE = re.compile( + r''' + ^ + \s* + m4_define\( + \s* + \[gtk_major_version\] + \s* + , + \s* + \[ + (?P<version>[0-9]+) + \] + \s* + \) + $ + ''', + re.UNICODE | re.VERBOSE +) + +CONFIGURE_MINOR_VERSION_RE = re.compile( + r''' + ^ + \s* + m4_define\( + \s* + \[gtk_minor_version\] + \s* + , + \s* + \[ + (?P<version>[0-9]+) + \] + \s* + \) + $ + ''', + re.UNICODE | re.VERBOSE +) + +CONFIGURE_MICRO_VERSION_RE = re.compile( + r''' + ^ + \s* + m4_define\( + \s* + \[gtk_micro_version\] + \s* + , + \s* + \[ + (?P<version>[0-9]+) + \] + \s* + \) + $ + ''', + re.UNICODE | re.VERBOSE +) + +MESON_VERSION_RE = re.compile( + r''' + ^ + \s* + version + \s* + :{1} + \s* + \'{1} + (?P<major>[0-9]+) + \.{1} + (?P<minor>[0-9]+) + \.{1} + (?P<micro>[0-9]+) + \'{1} + \s* + ,? + $ + ''', + re.UNICODE | re.VERBOSE +) + +version = {} + +with open(configure_ac, 'r') as f: + line = f.readline() + while line: + res = CONFIGURE_MAJOR_VERSION_RE.match(line) + if res: + if 'major' in version: + print(f'Redefinition of major version; version is already set to {version["major"]}') + sys.exit(1) + version['major'] = res.group('version') + line = f.readline() + continue + res = CONFIGURE_MINOR_VERSION_RE.match(line) + if res: + if 'minor' in version: + print(f'Redefinition of minor version; version is already set to {version["minor"]}') + sys.exit(1) + version['minor'] = res.group('version') + line = f.readline() + continue + res = CONFIGURE_MICRO_VERSION_RE.match(line) + if res: + if 'micro' in version: + print(f'Redefinition of micro version; version is already set to {version["micro"]}') + sys.exit(1) + version['micro'] = res.group('version') + line = f.readline() + continue + if ('major', 'minor', 'micro') in version: + break + line = f.readline() + +print(f'GTK version defined in {configure_ac}: {version["major"]}.{version["minor"]}.{version["micro"]}') + +configure_version = version +version = {} + +with open(meson_build, 'r') as f: + line = f.readline() + inside_project = False + while line: + if line.startswith('project('): + inside_project = True + elif inside_project: + res = MESON_VERSION_RE.match(line) + if res: + version['major'] = res.group('major') + version['minor'] = res.group('minor') + version['micro'] = res.group('micro') + break + line = f.readline() + +print(f'GTK version defined in {meson_build}: {version["major"]}.{version["minor"]}.{version["micro"]}') + +meson_version = version + +if configure_version != meson_version: + print('Version mismatch between Autotools and Meson builds') + sys.exit(1) + +sys.exit(0) diff --git a/meson.build b/meson.build index 7ec6a9e409..dc3f93c5d4 100644 --- a/meson.build +++ b/meson.build @@ -987,6 +987,16 @@ if host_machine.system() != 'windows' install_dir : join_paths(gtk_datadir, 'gtk-3.0', 'valgrind')) endif +test( + 'version-check', + find_program('check-version.py'), + args: [ + join_paths(meson.current_source_dir(), 'configure.ac'), + join_paths(meson.current_source_dir(), 'meson.build'), + ], + suite: 'gtk', +) + summary = [ '', '------', |