scons: move to regex for more robust libtool version detection

This commit is contained in:
Dane Springmeyer 2010-11-17 20:23:28 +00:00
parent 1114172e3e
commit f7784fd6a7

View file

@ -63,14 +63,22 @@ def call(cmd, silent=False):
def get_libtool_version(): def get_libtool_version():
cmd = 'libtool' cmd = 'libtool'
version = 2
if platform.uname()[0] == "Darwin": if platform.uname()[0] == "Darwin":
cmd = 'glibtool' cmd = 'glibtool'
ret = os.popen('%s --version' % cmd).readlines() version = 2
if len(ret): pattern = r'(.*)(\d/.\d/.\d)(.*)'
version_string = ret[0].strip().split(' ')[-1] ret = os.popen('%s --version' % cmd).read()
if version_string: match = re.match(pattern,ret)
version = version_string.split('.')[0] 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 return version
# http://www.scons.org/wiki/InstallTargets # http://www.scons.org/wiki/InstallTargets