From f7784fd6a7dc86bd371dba92d92f2a849a570f08 Mon Sep 17 00:00:00 2001 From: Dane Springmeyer Date: Wed, 17 Nov 2010 20:23:28 +0000 Subject: [PATCH] scons: move to regex for more robust libtool version detection --- SConstruct | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/SConstruct b/SConstruct index d8cc9e6bb..1d5649011 100644 --- a/SConstruct +++ b/SConstruct @@ -63,14 +63,22 @@ def call(cmd, silent=False): def get_libtool_version(): cmd = 'libtool' - version = 2 if platform.uname()[0] == "Darwin": cmd = 'glibtool' - ret = os.popen('%s --version' % cmd).readlines() - if len(ret): - version_string = ret[0].strip().split(' ')[-1] - if version_string: - version = version_string.split('.')[0] + version = 2 + pattern = r'(.*)(\d/.\d/.\d)(.*)' + ret = os.popen('%s --version' % cmd).read() + match = re.match(pattern,ret) + if match: + groups = match.groups() + if len(groups): + version_string = groups[1] + if version_string: + version = version_string.split('.')[0] + try: + version = int(version) + except ValueError: + pass return version # http://www.scons.org/wiki/InstallTargets