[gtk/msvcproj-git: 9/10] win32/gen-version-items.py: Retrieve version info from configure.ac
- From: Chun-wei Fan <fanchunwei src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/msvcproj-git: 9/10] win32/gen-version-items.py: Retrieve version info from configure.ac
- Date: Fri, 5 Aug 2022 10:16:04 +0000 (UTC)
commit bad9744c3e914491f42bb4c4a17d99f1e2038489
Author: Chun-wei Fan <fanchunwei src gnome org>
Date: Fri Aug 5 12:56:49 2022 +0800
win32/gen-version-items.py: Retrieve version info from configure.ac
...and use that info if no version and/or interface age was specified. This
way, we can use this script to help bootstrap builds from Visual Studio
projects directly from a GIT checkout.
win32/gen-version-items.py | 55 ++++++++++++++++++++++++++++++++++++----------
1 file changed, 44 insertions(+), 11 deletions(-)
---
diff --git a/win32/gen-version-items.py b/win32/gen-version-items.py
index a2f450cfe1..2a5ba35933 100644
--- a/win32/gen-version-items.py
+++ b/win32/gen-version-items.py
@@ -5,39 +5,72 @@
# Author: Fan, Chun-wei
# Date: July 25, 2019
+import argparse
import os
+import re
import sys
-import argparse
from replace import replace_multi, replace
+def get_srcroot():
+ if not os.path.isabs(__file__):
+ path = os.path.abspath(__file__)
+ else:
+ path = __file__
+ dirname = os.path.dirname(path)
+ return os.path.abspath(os.path.join(dirname, '..'))
+
+def get_version(srcroot):
+ ver = {}
+ RE_VERSION = re.compile(r'^m4_define\(\[(gtk_\w+)\],\s*\[(\d+)\]\)')
+ with open(os.path.join(srcroot, 'configure.ac'), 'r') as ac:
+ for i in ac:
+ mo = RE_VERSION.search(i)
+ if mo:
+ ver[mo.group(1).upper()] = int(mo.group(2))
+ ver['GTK_VERSION'] = '%d.%d.%d' % (ver['GTK_MAJOR_VERSION'],
+ ver['GTK_MINOR_VERSION'],
+ ver['GTK_MICRO_VERSION'])
+ return ver
+
def main(argv):
srcdir = os.path.dirname(__file__)
top_srcdir = os.path.join(srcdir, os.pardir)
parser = argparse.ArgumentParser(description='Generate various items with version info')
- parser.add_argument('--version', help='Version of the package',
- required=True)
- parser.add_argument('--interface-age', help='Interface age of the package',
- required=True)
+ parser.add_argument('--version', help='Version of the package')
+ parser.add_argument('--interface-age', help='Interface age of the package')
parser.add_argument('--source', help='Source file template to process',
required=True)
parser.add_argument('--output', '-o', help='Output generated file location',
required=True)
args = parser.parse_args()
- gdk_sourcedir = os.path.join(top_srcdir, 'gdk')
- version_parts = args.version.split('.')
+ version_info = get_version(get_srcroot())
+
+ # If version and/or interface-age were specified, use them,
+ # otherwise use the info we have from configure.ac.
+ if args.version is not None:
+ gtk_version = args.version
+ else:
+ gtk_version = version_info['GTK_VERSION']
+ if args.interface_age is not None:
+ interface_age = args.interface_age
+ else:
+ interface_age = version_info['GTK_INTERFACE_AGE']
+
+ version_parts = gtk_version.split('.')
# (100 * gtk_minor_version + gtk_micro_version - gtk_interface_age)
binary_age = (int(version_parts[1]) * 100) + int(version_parts[2])
- lt_current = (int(version_parts[1]) * 100) + int(version_parts[2]) - int(args.interface_age)
- lt_age = binary_age - int(args.interface_age)
+ lt_current = (int(version_parts[1]) * 100) + int(version_parts[2]) - int(interface_age)
+ lt_age = binary_age - int(interface_age)
version_info_replace_items = {'@GTK_MAJOR_VERSION@': version_parts[0],
'@GTK_MINOR_VERSION@': version_parts[1],
'@GTK_MICRO_VERSION@': version_parts[2],
'@GTK_API_VERSION@': '3.0',
- '@GTK_VERSION@': args.version,
+ '@GTK_VERSION@': gtk_version,
'@GTK_BINARY_AGE@': str(binary_age),
- '@GTK_INTERFACE_AGE@': args.interface_age,
+ '@GTK_INTERFACE_AGE@': str(interface_age),
+ '@GETTEXT_PACKAGE@': 'gtk30',
'@LT_CURRENT_MINUS_AGE@': str(lt_current - lt_age)}
replace_multi(args.source, args.output, version_info_replace_items)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]