diff options
Diffstat (limited to 'configure.py')
-rwxr-xr-x | configure.py | 57 |
1 files changed, 35 insertions, 22 deletions
diff --git a/configure.py b/configure.py index 2920becb6..bb0dbc192 100755 --- a/configure.py +++ b/configure.py @@ -5,15 +5,16 @@ Configuration program for botan (http://botan.randombit.net/) (C) 2009-2011 Jack Lloyd Distributed under the terms of the Botan license -Tested with - CPython 2.5, 2.6, 2.7 - OK - Jython 2.5 - Target detection does not work (use --os and --cpu) +Tested with CPython 2.6, 2.7, 3.1 and PyPy 1.5 - CPython 2.4 and earlier are not supported +Python 2.5 works if you change the exception catching syntax: + perl -pi -e 's/except (.*) as (.*):/except $1, $2:/g' configure.py - Use the 2to3 script to use with Python 3 +Jython - Target detection does not work (use --os and --cpu) - Has not been tested with IronPython or PyPy +CPython 2.4 and earlier are not supported + +Has not been tested with IronPython """ import sys @@ -41,17 +42,23 @@ def flatten(l): return sum(l, []) def get_vc_revision(): - mtn = subprocess.Popen(['mtn', 'automate', 'heads'], - stdout=subprocess.PIPE, - stderr=subprocess.PIPE) + try: + mtn = subprocess.Popen(['mtn', 'automate', 'heads'], + stdout=subprocess.PIPE, + stderr=subprocess.PIPE) - (stdout, stderr) = mtn.communicate() + (stdout, stderr) = mtn.communicate() - if(stderr != ''): - #logging.debug('Error getting rev from monotone - %s' % (stderr)) - return 'unknown' + if(stderr != ''): + logging.debug('Error getting rev from monotone - %s' % (stderr)) + return 'unknown' + + logging.debug('Monotone reported revision ' + stdout.strip()) - return 'mtn:' + stdout.strip() + return 'mtn:' + stdout.strip() + except OSError as e: + logging.debug('Error getting rev from monotone - %s' % (e[1])) + return 'unknown' class BuildConfigurationInformation(object): @@ -65,7 +72,7 @@ class BuildConfigurationInformation(object): version_datestamp = botan_version.release_datestamp - version_vc_rev = botan_version.release_vc_rev or get_vc_revision() + version_vc_rev = botan_version.release_vc_rev version_string = '%d.%d.%d' % (version_major, version_minor, version_patch) """ @@ -73,6 +80,9 @@ class BuildConfigurationInformation(object): """ def __init__(self, options, modules): + if self.version_vc_rev is None: + self.version_vc_rev = get_vc_revision() + self.build_dir = os.path.join(options.with_build_dir, 'build') self.checkobj_dir = os.path.join(self.build_dir, 'checks') @@ -945,7 +955,7 @@ def process_template(template_file, variables): try: template = PercentSignTemplate(slurp_file(template_file)) return template.substitute(variables) - except KeyError, e: + except KeyError as e: raise Exception('Unbound var %s in template %s' % (e, template_file)) """ @@ -1383,14 +1393,14 @@ def setup_build(build_config, options, template_vars): try: if options.clean_build_tree: shutil.rmtree(build_config.build_dir) - except OSError, e: + except OSError as e: if e.errno != errno.ENOENT: logging.error('Problem while removing build dir: %s' % (e)) for dir in build_config.build_dirs: try: os.makedirs(dir) - except OSError, e: + except OSError as e: if e.errno != errno.EEXIST: logging.error('Error while creating "%s": %s' % (dir, e)) @@ -1441,7 +1451,7 @@ def setup_build(build_config, options, template_vars): for header_file in header_list: try: portable_symlink(header_file, dir, link_method) - except OSError, e: + except OSError as e: if e.errno != errno.EEXIST: logging.error('Error linking %s into %s: %s' % ( header_file, dir, e)) @@ -1702,10 +1712,13 @@ def main(argv = None): def get_gcc_version(gcc_bin): try: - gcc_version = ''.join(subprocess.Popen( + subproc_result = subprocess.Popen( gcc_bin.split(' ') + ['-dumpversion'], stdout=subprocess.PIPE, - stderr=subprocess.PIPE).communicate()).strip() + stderr=subprocess.PIPE).communicate() + + gcc_version = ''.join(map(str, subproc_result)).strip() + logging.info('Detected gcc version %s' % (gcc_version)) return gcc_version except OSError: @@ -1768,7 +1781,7 @@ def main(argv = None): if __name__ == '__main__': try: main() - except Exception, e: + except Exception as e: logging.error(str(e)) #import traceback #traceback.print_exc(file=sys.stderr) |