32 """A script to prepare version informtion for use the gtest Info.plist file. 34 This script extracts the version information from the configure.ac file and 35 uses it to generate a header file containing the same information. The 36 #defines in this header file will be included in during the generation of 37 the Info.plist of the framework, giving the correct value to the version 40 This script makes the following assumptions (these are faults of the script, 41 not problems with the Autoconf): 42 1. The AC_INIT macro will be contained within the first 1024 characters 44 2. The version string will be 3 integers separated by periods and will be 45 surrounded by squre brackets, "[" and "]" (e.g. [1.0.1]). The first 46 segment represents the major version, the second represents the minor 47 version and the third represents the fix version. 48 3. No ")" character exists between the opening "(" and closing ")" of 49 AC_INIT, including in comments and character strings. 56 if (len(sys.argv) < 3):
57 print "Usage: versiongenerate.py input_dir output_dir" 60 input_dir = sys.argv[1]
61 output_dir = sys.argv[2]
64 config_file = open(
"%s/configure.ac" % input_dir,
'r') 66 opening_string = config_file.read(buffer_size) 75 version_expression = re.compile(
r"AC_INIT\(.*?\[(\d+)\.(\d+)\.(\d+)\].*?\)",
77 version_values = version_expression.search(opening_string)
78 major_version = version_values.group(1)
79 minor_version = version_values.group(2)
80 fix_version = version_values.group(3)
85 // DO NOT MODIFY THIS FILE (but you can delete it) 87 // This file is autogenerated by the versiongenerate.py script. This script 88 // is executed in a "Run Script" build phase when creating gtest.framework. This 89 // header file is not used during compilation of C-source. Rather, it simply 90 // defines some version strings for substitution in the Info.plist. Because of 91 // this, we are not not restricted to C-syntax nor are we using include guards. 94 #define GTEST_VERSIONINFO_SHORT %s.%s 95 #define GTEST_VERSIONINFO_LONG %s.%s.%s 97 """ % (major_version, minor_version, major_version, minor_version, fix_version)
98 version_file = open(
"%s/Version.h" % output_dir,
'w')
99 version_file.write(file_data)