Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(8)

Side by Side Diff: scons-2.0.1/engine/SCons/Tool/sunc++.py

Issue 6711079: Added an unmodified copy of SCons to third_party. (Closed) Base URL: svn://svn.chromium.org/native_client/trunk/src/third_party/
Patch Set: '' Created 9 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « scons-2.0.1/engine/SCons/Tool/sunar.py ('k') | scons-2.0.1/engine/SCons/Tool/suncc.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Property Changes:
Added: svn:eol-style
+ LF
OLDNEW
(Empty)
1 """SCons.Tool.sunc++
2
3 Tool-specific initialization for C++ on SunOS / Solaris.
4
5 There normally shouldn't be any need to import this module directly.
6 It will usually be imported through the generic SCons.Tool.Tool()
7 selection method.
8
9 """
10
11 #
12 # Copyright (c) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 The S Cons Foundation
13 #
14 # Permission is hereby granted, free of charge, to any person obtaining
15 # a copy of this software and associated documentation files (the
16 # "Software"), to deal in the Software without restriction, including
17 # without limitation the rights to use, copy, modify, merge, publish,
18 # distribute, sublicense, and/or sell copies of the Software, and to
19 # permit persons to whom the Software is furnished to do so, subject to
20 # the following conditions:
21 #
22 # The above copyright notice and this permission notice shall be included
23 # in all copies or substantial portions of the Software.
24 #
25 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
26 # KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
27 # WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
28 # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
29 # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
30 # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
31 # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
32 #
33
34 __revision__ = "src/engine/SCons/Tool/sunc++.py 5134 2010/08/16 23:02:40 bdeegan "
35
36 import SCons
37
38 import os
39 import re
40 import subprocess
41
42 cplusplus = __import__('c++', globals(), locals(), [])
43
44 package_info = {}
45
46 def get_package_info(package_name, pkginfo, pkgchk):
47 try:
48 return package_info[package_name]
49 except KeyError:
50 version = None
51 pathname = None
52 try:
53 sadm_contents = open('/var/sadm/install/contents', 'r').read()
54 except EnvironmentError:
55 pass
56 else:
57 sadm_re = re.compile('^(\S*/bin/CC)(=\S*)? %s$' % package_name, re.M )
58 sadm_match = sadm_re.search(sadm_contents)
59 if sadm_match:
60 pathname = os.path.dirname(sadm_match.group(1))
61
62 try:
63 p = subprocess.Popen([pkginfo, '-l', package_name],
64 stdout=subprocess.PIPE,
65 stderr=open('/dev/null', 'w'))
66 except EnvironmentError:
67 pass
68 else:
69 pkginfo_contents = p.communicate()[0]
70 version_re = re.compile('^ *VERSION:\s*(.*)$', re.M)
71 version_match = version_re.search(pkginfo_contents)
72 if version_match:
73 version = version_match.group(1)
74
75 if pathname is None:
76 try:
77 p = subprocess.Popen([pkgchk, '-l', package_name],
78 stdout=subprocess.PIPE,
79 stderr=open('/dev/null', 'w'))
80 except EnvironmentError:
81 pass
82 else:
83 pkgchk_contents = p.communicate()[0]
84 pathname_re = re.compile(r'^Pathname:\s*(.*/bin/CC)$', re.M)
85 pathname_match = pathname_re.search(pkgchk_contents)
86 if pathname_match:
87 pathname = os.path.dirname(pathname_match.group(1))
88
89 package_info[package_name] = (pathname, version)
90 return package_info[package_name]
91
92 # use the package installer tool lslpp to figure out where cppc and what
93 # version of it is installed
94 def get_cppc(env):
95 cxx = env.subst('$CXX')
96 if cxx:
97 cppcPath = os.path.dirname(cxx)
98 else:
99 cppcPath = None
100
101 cppcVersion = None
102
103 pkginfo = env.subst('$PKGINFO')
104 pkgchk = env.subst('$PKGCHK')
105
106 for package in ['SPROcpl']:
107 path, version = get_package_info(package, pkginfo, pkgchk)
108 if path and version:
109 cppcPath, cppcVersion = path, version
110 break
111
112 return (cppcPath, 'CC', 'CC', cppcVersion)
113
114 def generate(env):
115 """Add Builders and construction variables for SunPRO C++."""
116 path, cxx, shcxx, version = get_cppc(env)
117 if path:
118 cxx = os.path.join(path, cxx)
119 shcxx = os.path.join(path, shcxx)
120
121 cplusplus.generate(env)
122
123 env['CXX'] = cxx
124 env['SHCXX'] = shcxx
125 env['CXXVERSION'] = version
126 env['SHCXXFLAGS'] = SCons.Util.CLVar('$CXXFLAGS -KPIC')
127 env['SHOBJPREFIX'] = 'so_'
128 env['SHOBJSUFFIX'] = '.o'
129
130 def exists(env):
131 path, cxx, shcxx, version = get_cppc(env)
132 if path and cxx:
133 cppc = os.path.join(path, cxx)
134 if os.path.exists(cppc):
135 return cppc
136 return None
137
138 # Local Variables:
139 # tab-width:4
140 # indent-tabs-mode:nil
141 # End:
142 # vim: set expandtab tabstop=4 shiftwidth=4:
OLDNEW
« no previous file with comments | « scons-2.0.1/engine/SCons/Tool/sunar.py ('k') | scons-2.0.1/engine/SCons/Tool/suncc.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698