versiongenerate.py
Go to the documentation of this file.
00001 #!/usr/bin/env python
00002 #
00003 # Copyright 2008, Google Inc.
00004 # All rights reserved.
00005 #
00006 # Redistribution and use in source and binary forms, with or without
00007 # modification, are permitted provided that the following conditions are
00008 # met:
00009 #
00010 #     * Redistributions of source code must retain the above copyright
00011 # notice, this list of conditions and the following disclaimer.
00012 #     * Redistributions in binary form must reproduce the above
00013 # copyright notice, this list of conditions and the following disclaimer
00014 # in the documentation and/or other materials provided with the
00015 # distribution.
00016 #     * Neither the name of Google Inc. nor the names of its
00017 # contributors may be used to endorse or promote products derived from
00018 # this software without specific prior written permission.
00019 #
00020 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
00021 # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
00022 # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
00023 # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
00024 # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
00025 # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
00026 # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
00027 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
00028 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
00029 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
00030 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
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 # Read the command line argument (the output directory for Version.h)
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 # Read the first 1024 characters of the configure.ac file
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 # Extract the version string from the AC_INIT macro
00070 #   The following init_expression means:
00071 #     Extract three integers separated by periods and surrounded by squre
00072 #     brackets(e.g. "[1.0.1]") between "AC_INIT(" and ")". Do not be greedy
00073 #     (*? is the non-greedy flag) since that would pull in everything between
00074 #     the first "(" and the last ")" in the file.
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 # Write the version information to a header file to be included in the
00083 # Info.plist file.
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()


rc_visard_driver
Author(s): Heiko Hirschmueller , Christian Emmerich , Felix Ruess
autogenerated on Thu Jun 6 2019 20:43:07