3 Tool-specific initialization for C++ on SunOS / Solaris.
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()
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:
22 # The above copyright notice and this permission notice shall be included
23 # in all copies or substantial portions of the Software.
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.
34 __revision__
= "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
43 cplusplus
= SCons
.Tool
.cxx
44 # cplusplus = __import__('c++', globals(), locals(), [])
49 def get_package_info(package_name
, pkginfo
, pkgchk
):
51 return package_info
[package_name
]
55 from subprocess
import DEVNULL
58 with
open('/var/sadm/install/contents', encoding
='UTF-8') as f
:
59 sadm_contents
= f
.read()
63 sadm_re
= re
.compile(r
'^(\S*/bin/CC)(=\S*)? %s$' % package_name
, re
.M
)
64 sadm_match
= sadm_re
.search(sadm_contents
)
66 pathname
= os
.path
.dirname(sadm_match
.group(1))
69 p
= subprocess
.Popen([pkginfo
, '-l', package_name
],
70 universal_newlines
=True,
71 stdout
=subprocess
.PIPE
,
76 pkginfo_contents
= p
.communicate()[0]
77 version_re
= re
.compile(r
'^ *VERSION:\s*(.*)$', re
.M
)
78 version_match
= version_re
.search(pkginfo_contents
)
80 version
= version_match
.group(1)
84 p
= subprocess
.Popen([pkgchk
, '-l', package_name
],
85 universal_newlines
=True,
86 stdout
=subprocess
.PIPE
,
91 pkgchk_contents
= p
.communicate()[0]
92 pathname_re
= re
.compile(r
'^Pathname:\s*(.*/bin/CC)$', re
.M
)
93 pathname_match
= pathname_re
.search(pkgchk_contents
)
95 pathname
= os
.path
.dirname(pathname_match
.group(1))
97 package_info
[package_name
] = (pathname
, version
)
98 return package_info
[package_name
]
101 # use the package installer tool "pkg" to figure out where cppc and what
102 # version of it is installed
104 cxx
= env
.subst('$CXX')
106 cppcPath
= os
.path
.dirname(cxx
)
112 pkginfo
= env
.subst('$PKGINFO')
113 pkgchk
= env
.subst('$PKGCHK')
115 for package
in ['SPROcpl']:
116 path
, version
= get_package_info(package
, pkginfo
, pkgchk
)
118 cppcPath
, cppcVersion
= path
, version
121 return (cppcPath
, 'CC', 'CC', cppcVersion
)
124 def generate(env
) -> None:
125 """Add Builders and construction variables for SunPRO C++."""
126 path
, cxx
, shcxx
, version
= get_cppc(env
)
128 cxx
= os
.path
.join(path
, cxx
)
129 shcxx
= os
.path
.join(path
, shcxx
)
131 cplusplus
.generate(env
)
135 env
['CXXVERSION'] = version
136 env
['SHCXXFLAGS'] = SCons
.Util
.CLVar('$CXXFLAGS -KPIC')
137 env
['SHOBJPREFIX'] = 'so_'
138 env
['SHOBJSUFFIX'] = '.o'
142 path
, cxx
, shcxx
, version
= get_cppc(env
)
144 cppc
= os
.path
.join(path
, cxx
)
145 if os
.path
.exists(cppc
):
151 # indent-tabs-mode:nil
153 # vim: set expandtab tabstop=4 shiftwidth=4: