Skip to content

Commit 082dce3

Browse files
committed
Enough of the nannying.
1 parent 6267734 commit 082dce3

File tree

1 file changed

+51
-9
lines changed

1 file changed

+51
-9
lines changed

sanity/checker.py

Lines changed: 51 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,44 @@
33
import subprocess as sp
44

55
explain_LLVM_COMPILER = """
6+
67
The environment variable 'LLVM_COMPILER' is a switch. It should either
78
be set to 'clang' or 'dragonegg'. Anything else will cause an error.
9+
810
"""
911

1012
explain_LLVM_DRAGONEGG_PLUGIN = """
11-
You need to set the environment variable LLVM_DRAGONEGG_PLUGIN to the full path
12-
to your dragonegg plugin. Thanks.
13+
14+
You need to set the environment variable LLVM_DRAGONEGG_PLUGIN to the
15+
full path to your dragonegg plugin. Thanks.
16+
17+
"""
18+
19+
explain_LLVM_CC_NAME = """
20+
21+
If your clang compiler is not called clang, but something else, then
22+
you will need to set the environment variable LLVM_CC_NAME to the
23+
appropriate string. For example if your clang is called clang-3.5 then
24+
LLVM_CC_NAME should be set to clang-3.5.
25+
26+
"""
27+
28+
explain_LLVM_CXX_NAME = """
29+
30+
If your clang++ compiler is not called clang++, but something else,
31+
then you will need to set the environment variable LLVM_CXX_NAME to
32+
the appropriate string. For example if your clang++ is called ++clang
33+
then LLVM_CC_NAME should be set to ++clang.
34+
35+
"""
36+
37+
explain_LLVM_COMPILER_PATH = """
38+
39+
Your compiler should either be in your PATH, or else located where the
40+
environment variable LLVM_COMPILER_PATH indicates. It can also be used
41+
to indicatethe directory that contains the other LLVM tools such as
42+
llvm-link, and llvm-ar.
43+
1344
"""
1445

1546
class Checker(object):
@@ -74,9 +105,6 @@ def checkDragonegg(self):
74105
cc = '{0}{1}gcc'.format(self.path, pfx)
75106
cxx = '{0}{1}g++'.format(self.path, pfx)
76107

77-
(ccOk, ccVersion) = self.checkExecutable(cc)
78-
(cxxOk, cxxVersion) = self.checkExecutable(cxx)
79-
80108
return self.checkCompilers(cc, cxx)
81109

82110

@@ -130,7 +158,16 @@ def checkCompilers(self, cc, cxx):
130158
if not cxxOk:
131159
print 'The CXX compiler {0} was not found or not executable.\nBetter not try using wllvm++!\n'.format(cxx)
132160
else:
133-
print 'The C++ compiler {0} is:\n{1}\n'.format(cxx, cxxVersion)
161+
print 'The C++ compiler {0} is:\n\n{1}\n'.format(cxx, cxxVersion)
162+
163+
if not ccOk or not cxxOk:
164+
print explain_LLVM_COMPILER_PATH
165+
if not ccOk:
166+
print explain_LLVM_CC_NAME
167+
if not cxxOk:
168+
print explain_LLVM_CXX_NAME
169+
170+
134171

135172
return ccOk or cxxOk
136173

@@ -142,7 +179,12 @@ def checkExecutable(self, exe, version_switch='-v'):
142179
output = compiler.communicate()
143180
compilerOutput = '{0}{1}'.format(output[0], output[1])
144181
except OSError as e:
145-
return (False, '{0} not found or not executable'.format(exe))
182+
if e.errno == errno.EPERM:
183+
return (False, '{0} not executable'.format(exe))
184+
elif e.errno == errno.ENOENT:
185+
return (False, '{0} not found'.format(exe))
186+
else:
187+
return (False, '{0} not sure why, errno is {1}'.format(exe, e.errno))
146188
else:
147189
return (True, compilerOutput)
148190

@@ -159,11 +201,11 @@ def checkAuxiliaries(self):
159201
if not linkOk:
160202
print 'The bitcode linker {0} was not found or not executable.\nBetter not try using extract-bc!\n'.format(link)
161203
else:
162-
print 'The bitcode linker {0} is:\n{1}\n'.format(link, linkVersion)
204+
print 'The bitcode linker {0} is:\n\n{1}\n'.format(link, linkVersion)
163205

164206
if not arOk:
165207
print 'The bitcode archiver {0} was not found or not executable.\nBetter not try using extract-bc!\n'.format(ar)
166208
else:
167-
print 'The bitcode archiver {0} is:\n{1}\n'.format(ar, arVersion)
209+
print 'The bitcode archiver {0} is:\n\n{1}\n'.format(ar, arVersion)
168210

169211

0 commit comments

Comments
 (0)