Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032 """A script to prepare version informtion for use the gtest Info.plist file.
00033
00034 This script extracts the version information from the configure.ac file and
00035 uses it to generate a header file containing the same information. The
00036 #defines in this header file will be included in during the generation of
00037 the Info.plist of the framework, giving the correct value to the version
00038 shown in the Finder.
00039
00040 This script makes the following assumptions (these are faults of the script,
00041 not problems with the Autoconf):
00042 1. The AC_INIT macro will be contained within the first 1024 characters
00043 of configure.ac
00044 2. The version string will be 3 integers separated by periods and will be
00045 surrounded by squre brackets, "[" and "]" (e.g. [1.0.1]). The first
00046 segment represents the major version, the second represents the minor
00047 version and the third represents the fix version.
00048 3. No ")" character exists between the opening "(" and closing ")" of
00049 AC_INIT, including in comments and character strings.
00050 """
00051
00052 import sys
00053 import re
00054
00055
00056 if (len(sys.argv) < 3):
00057 print "Usage: versiongenerate.py input_dir output_dir"
00058 sys.exit(1)
00059 else:
00060 input_dir = sys.argv[1]
00061 output_dir = sys.argv[2]
00062
00063
00064 config_file = open("%s/configure.ac" % input_dir, 'r')
00065 buffer_size = 1024
00066 opening_string = config_file.read(buffer_size)
00067 config_file.close()
00068
00069
00070
00071
00072
00073
00074
00075 version_expression = re.compile(r"AC_INIT\(.*?\[(\d+)\.(\d+)\.(\d+)\].*?\)",
00076 re.DOTALL)
00077 version_values = version_expression.search(opening_string)
00078 major_version = version_values.group(1)
00079 minor_version = version_values.group(2)
00080 fix_version = version_values.group(3)
00081
00082
00083
00084 file_data = """//
00085 // DO NOT MODIFY THIS FILE (but you can delete it)
00086 //
00087 // This file is autogenerated by the versiongenerate.py script. This script
00088 // is executed in a "Run Script" build phase when creating gtest.framework. This
00089 // header file is not used during compilation of C-source. Rather, it simply
00090 // defines some version strings for substitution in the Info.plist. Because of
00091 // this, we are not not restricted to C-syntax nor are we using include guards.
00092 //
00093
00094 #define GTEST_VERSIONINFO_SHORT %s.%s
00095 #define GTEST_VERSIONINFO_LONG %s.%s.%s
00096
00097 """ % (major_version, minor_version, major_version, minor_version, fix_version)
00098 version_file = open("%s/Version.h" % output_dir, 'w')
00099 version_file.write(file_data)
00100 version_file.close()