3 # Permission is hereby granted, free of charge, to any person obtaining
4 # a copy of this software and associated documentation files (the
5 # "Software"), to deal in the Software without restriction, including
6 # without limitation the rights to use, copy, modify, merge, publish,
7 # distribute, sublicense, and/or sell copies of the Software, and to
8 # permit persons to whom the Software is furnished to do so, subject to
9 # the following conditions:
11 # The above copyright notice and this permission notice shall be included
12 # in all copies or substantial portions of the Software.
14 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
15 # KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
16 # WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17 # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18 # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19 # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20 # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24 Verify that we can import and use the contents of Platform and Tool
31 # must do this here, since TestSCons will chdir
32 tooldir
= os
.path
.join(os
.getcwd(), 'SCons', 'Tool')
35 test
= TestSCons
.TestSCons()
37 # Before executing any of the platform or tool modules, add some
38 # null entries to the environment $PATH variable to make sure there's
39 # no code that tries to index elements from the list before making sure
41 # (This was a problem in checkpoint release 0.97.d020070809.)
42 os
.environ
['PATH'] = os
.pathsep
+ os
.environ
['PATH'] + \
43 os
.pathsep
+ os
.pathsep
+ '/no/such/dir' + os
.pathsep
45 SConstruct_path
= test
.workpath('SConstruct')
59 for platform
in platforms
:
60 test
.write('SConstruct', """
61 DefaultEnvironment(tools=[])
62 print("Platform %(platform)s")
63 env = Environment(platform = '%(platform)s', tools=[])
64 import SCons.Platform.%(platform)s
65 x = SCons.Platform.%(platform)s.generate
69 ignore
= ('__init__.py',
70 # Can't import these everywhere due to Windows registry dependency.
71 '386asm.py', 'linkloc.py',
72 # Directory of common stuff for MSVC and MSVS
78 # Sun pkgchk and pkginfo common stuff
84 for name
in os
.listdir(tooldir
):
85 if name
in ignore
: continue
86 if name
[0] == '#': continue
87 if name
[0:1] == '.': continue
88 if name
[-1] == '~' : continue
89 if name
[-3:] == '.py':
90 if name
[-8:] not in ('Tests.py', 'ommon.py'):
91 tools
.append(name
[:-3])
92 elif os
.path
.exists(os
.path
.join(tooldir
,name
,'__init__.py')):
94 tools
.sort() # why not?
96 #if sys.platform == 'win32':
97 # Just comment out (for now?) due to registry dependency.
103 # Intel no compiler warning..
104 intel_no_compiler_warning
= """
105 scons: warning: Failed to find Intel compiler for version='None', abi='[^']*'
106 """ + TestSCons
.file_expr
108 # Intel no top dir warning.
109 intel_no_top_dir_warning
= """
110 scons: warning: Can't find Intel compiler top dir for version='None', abi='[^']*'
111 """ + TestSCons
.file_expr
113 # Intel no license directory warning
114 intel_license_warning
= re
.escape(
115 r
"""scons: warning: Intel license dir was not found. Tried using the INTEL_LICENSE_FILE environment variable (), the registry () and the default path (C:\Program Files\Common Files\Intel\Licenses). Using the default path as a last resort.
116 """) + TestSCons
.file_expr
119 re
.compile(intel_license_warning
),
120 re
.compile(intel_no_compiler_warning
),
121 re
.compile(intel_no_compiler_warning
+ intel_license_warning
),
122 re
.compile(intel_no_top_dir_warning
),
123 re
.compile(intel_no_top_dir_warning
+ intel_license_warning
),
126 moc
= test
.where_is('moc')
130 qtdir
= os
.path
.dirname(os
.path
.dirname(moc
))
132 scons: warning: Could not detect qt3, using moc executable as a hint \(QT3DIR={qtdir}\)
136 scons: warning: Could not detect qt3, using empty QT3DIR
140 scons: \*\*\* Deprecated tool 'qt' renamed to 'qt3'. Please update your build accordingly. 'qt3' will be removed entirely in a future release.
143 qt3_warnings
= [re
.compile(qt3_err
+ TestSCons
.file_expr
)]
144 qt_error
= [re
.compile(qt_moved
+ TestSCons
.file_expr
)]
147 'icl': intel_warnings
,
148 'intelc': intel_warnings
,
153 # An SConstruct for importing Tool names that have illegal characters
154 # for Python variable names.
155 indirect_import
= """\
156 DefaultEnvironment(tools=[])
157 print("Tool %(tool)s (indirect)")
158 env = Environment(tools = ['%(tool)s'])
160 SCons = __import__('SCons.Tool.%(tool)s', globals(), locals(), [])
161 m = getattr(SCons.Tool, '%(tool)s')
162 env = Environment(tools=[])
166 # An SConstruct for importing Tool names "normally."
168 DefaultEnvironment(tools=[])
169 print("Tool %(tool)s (direct)")
170 env = Environment(tools = ['%(tool)s'])
172 import SCons.Tool.%(tool)s
173 env = Environment(tools=[])
174 SCons.Tool.%(tool)s.exists(env)
175 SCons.Tool.%(tool)s.generate(env)
180 if tool
[0] in '0123456789' or '+' in tool
or tool
in ('as',):
181 test
.write('SConstruct', indirect_import
% locals())
183 test
.write('SConstruct', direct_import
% locals())
184 test
.run(stderr
=None, status
=None)
185 stderr
= test
.stderr()
186 if stderr
or test
.status
:
188 for expression
in error_output
.get(tool
, []):
189 if expression
.match(stderr
):
193 print(f
"Failed importing '{tool}', stderr:")
195 failures
.append(tool
)
197 test
.fail_test(len(failures
))
203 # indent-tabs-mode:nil
205 # vim: set expandtab tabstop=4 shiftwidth=4: