diff options
author | Jörg Frings-Fürst <jff@merkur> | 2014-07-26 11:45:48 +0200 |
---|---|---|
committer | Jörg Frings-Fürst <jff@merkur> | 2014-07-26 11:45:48 +0200 |
commit | 99469e37d07b9f326c5b2c8157566f2f512cdc56 (patch) | |
tree | 475c0ae1b3b3b8be085b54420894896688ea363c /engine/SCons/Platform/aix.py | |
parent | 2176ae74d2f856582dd1e498a63a31949a7e19e2 (diff) | |
parent | 7c6b954c00c2a2eed2e975ec797216c515cd249d (diff) |
Merge tag 'upstream/2.3.2'
Upstream version 2.3.2
Diffstat (limited to 'engine/SCons/Platform/aix.py')
-rw-r--r-- | engine/SCons/Platform/aix.py | 44 |
1 files changed, 30 insertions, 14 deletions
diff --git a/engine/SCons/Platform/aix.py b/engine/SCons/Platform/aix.py index 98d4d8f..4d9ea92 100644 --- a/engine/SCons/Platform/aix.py +++ b/engine/SCons/Platform/aix.py @@ -8,7 +8,7 @@ selection method. """ # -# Copyright (c) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014 The SCons Foundation +# Copyright (c) 2001 - 2014 The SCons Foundation # # Permission is hereby granted, free of charge, to any person obtaining # a copy of this software and associated documentation files (the @@ -30,13 +30,17 @@ selection method. # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # -__revision__ = "src/engine/SCons/Platform/aix.py 2014/03/02 14:18:15 garyo" +__revision__ = "src/engine/SCons/Platform/aix.py 2014/07/05 09:42:21 garyo" import os +import subprocess import posix -def get_xlc(env, xlc=None, xlc_r=None, packages=[]): +import SCons.Util +import SCons.Action + +def get_xlc(env, xlc=None, packages=[]): # Use the AIX package installer tool lslpp to figure out where a # given xl* compiler is installed and what version it is. xlcPath = None @@ -44,18 +48,30 @@ def get_xlc(env, xlc=None, xlc_r=None, packages=[]): if xlc is None: xlc = env.get('CC', 'xlc') - if xlc_r is None: - xlc_r = xlc + '_r' + if SCons.Util.is_List(xlc): + xlc = xlc[0] for package in packages: - cmd = "lslpp -fc " + package + " 2>/dev/null | egrep '" + xlc + "([^-_a-zA-Z0-9].*)?$'" - line = os.popen(cmd).readline() - if line: - v, p = line.split(':')[1:3] - xlcVersion = v.split()[1] - xlcPath = p.split()[0] - xlcPath = xlcPath[:xlcPath.rindex('/')] - break - return (xlcPath, xlc, xlc_r, xlcVersion) + # find the installed filename, which may be a symlink as well + pipe = SCons.Action._subproc(env, ['lslpp', '-fc', package], + stdin = 'devnull', + stderr = 'devnull', + stdout = subprocess.PIPE) + # output of lslpp is something like this: + # #Path:Fileset:File + # /usr/lib/objrepos:vac.C 6.0.0.0:/usr/vac/exe/xlCcpp + # /usr/lib/objrepos:vac.C 6.0.0.0:/usr/vac/bin/xlc_r -> /usr/vac/bin/xlc + for line in pipe.stdout: + if xlcPath: + continue # read everything to let lslpp terminate + fileset, filename = line.split(':')[1:3] + filename = filename.split()[0] + if ('/' in xlc and filename == xlc) \ + or ('/' not in xlc and filename.endswith('/' + xlc)): + xlcVersion = fileset.split()[1] + xlcPath, sep, xlc = filename.rpartition('/') + pass + pass + return (xlcPath, xlc, xlcVersion) def generate(env): posix.generate(env) |