Lines 33-42
Link Here
|
33 |
__revision__ = "src/engine/SCons/Platform/aix.py 2014/03/02 14:18:15 garyo" |
33 |
__revision__ = "src/engine/SCons/Platform/aix.py 2014/03/02 14:18:15 garyo" |
34 |
|
34 |
|
35 |
import os |
35 |
import os |
|
|
36 |
import subprocess |
36 |
|
37 |
|
37 |
import posix |
38 |
import posix |
38 |
|
39 |
|
39 |
def get_xlc(env, xlc=None, xlc_r=None, packages=[]): |
40 |
import SCons.Util |
|
|
41 |
import SCons.Action |
42 |
|
43 |
def get_xlc(env, xlc=None, packages=[]): |
40 |
# Use the AIX package installer tool lslpp to figure out where a |
44 |
# Use the AIX package installer tool lslpp to figure out where a |
41 |
# given xl* compiler is installed and what version it is. |
45 |
# given xl* compiler is installed and what version it is. |
42 |
xlcPath = None |
46 |
xlcPath = None |
Lines 44-61
Link Here
|
44 |
|
48 |
|
45 |
if xlc is None: |
49 |
if xlc is None: |
46 |
xlc = env.get('CC', 'xlc') |
50 |
xlc = env.get('CC', 'xlc') |
47 |
if xlc_r is None: |
51 |
if SCons.Util.is_List(xlc): |
48 |
xlc_r = xlc + '_r' |
52 |
xlc = xlc[0] |
49 |
for package in packages: |
53 |
for package in packages: |
50 |
cmd = "lslpp -fc " + package + " 2>/dev/null | egrep '" + xlc + "([^-_a-zA-Z0-9].*)?$'" |
54 |
# find the installed filename, which may be a symlink as well |
51 |
line = os.popen(cmd).readline() |
55 |
pipe = SCons.Action._subproc(env, ['lslpp', '-fc', package], |
52 |
if line: |
56 |
stdin = 'devnull', |
53 |
v, p = line.split(':')[1:3] |
57 |
stderr = 'devnull', |
54 |
xlcVersion = v.split()[1] |
58 |
stdout = subprocess.PIPE) |
55 |
xlcPath = p.split()[0] |
59 |
# output of lslpp is something like this: |
56 |
xlcPath = xlcPath[:xlcPath.rindex('/')] |
60 |
# #Path:Fileset:File |
57 |
break |
61 |
# /usr/lib/objrepos:vac.C 6.0.0.0:/usr/vac/exe/xlCcpp |
58 |
return (xlcPath, xlc, xlc_r, xlcVersion) |
62 |
# /usr/lib/objrepos:vac.C 6.0.0.0:/usr/vac/bin/xlc_r -> /usr/vac/bin/xlc |
|
|
63 |
for line in pipe.stdout: |
64 |
if xlcPath: |
65 |
continue # read everything to let lslpp terminate |
66 |
fileset, filename = line.split(':')[1:3] |
67 |
filename = filename.split()[0] |
68 |
if ('/' in xlc and filename == xlc) \ |
69 |
or ('/' not in xlc and filename.endswith('/' + xlc)): |
70 |
xlcVersion = fileset.split()[1] |
71 |
xlcPath, sep, xlc = filename.rpartition('/') |
72 |
pass |
73 |
pass |
74 |
return (xlcPath, xlc, xlcVersion) |
59 |
|
75 |
|
60 |
def generate(env): |
76 |
def generate(env): |
61 |
posix.generate(env) |
77 |
posix.generate(env) |