|
37 | 37 | # Internal logger
|
38 | 38 | _logger = logging.getLogger(__name__)
|
39 | 39 |
|
| 40 | +# Flag for debugging |
| 41 | +DEBUG = False |
| 42 | + |
| 43 | + |
40 | 44 | # This class applies filters to GCC argument lists. It has a few
|
41 | 45 | # default arguments that it records, but does not modify the argument
|
42 | 46 | # list at all. It can be subclassed to change this behavior.
|
@@ -143,6 +147,9 @@ def __init__(self, inputList, exactMatches={}, patternMatches={}):
|
143 | 147 | if not matched:
|
144 | 148 | self.keepArgument(currentItem)
|
145 | 149 |
|
| 150 | + if DEBUG: |
| 151 | + self.dump() |
| 152 | + |
146 | 153 | def _shiftArgs(self, nargs):
|
147 | 154 | ret = []
|
148 | 155 | while nargs > 0:
|
@@ -198,6 +205,37 @@ def getOutputFilename(self):
|
198 | 205 | else:
|
199 | 206 | return 'a.out'
|
200 | 207 |
|
| 208 | + # iam: returns a pair [objectFilename, bitcodeFilename] i.e .o and .bc. |
| 209 | + # the hidden flag determines whether the objectFile is hidden like the |
| 210 | + # bitcodeFile is (starts with a '.'), use the DEBUG flag to get a sense |
| 211 | + # of what is being written out. |
| 212 | + def getArtifactNames(self, srcFile, hidden=False): |
| 213 | + (srcpath, srcbase) = os.path.split(srcFile) |
| 214 | + (srcroot, srcext) = os.path.splitext(srcbase) |
| 215 | + if hidden: |
| 216 | + objbase = '.{0}.o'.format(srcroot) |
| 217 | + else: |
| 218 | + objbase = '{0}.o'.format(srcroot) |
| 219 | + bcbase = '.{0}.o.bc'.format(srcroot) |
| 220 | + path = '' |
| 221 | + if self.outputFilename is not None: |
| 222 | + path = os.path.dirname(self.outputFilename) |
| 223 | + return [os.path.join(path, objbase), os.path.join(path, bcbase)] |
| 224 | + |
| 225 | + #iam: for printing our partitioning of the args |
| 226 | + def dump(self): |
| 227 | + print "compileArgs: ", self.compileArgs |
| 228 | + print "inputFiles: ", self.inputFiles |
| 229 | + print "linkArgs: ", self.linkArgs |
| 230 | + print "objectFiles: ", self.objectFiles |
| 231 | + print "outputFilename: ", self.outputFilename |
| 232 | + for srcFile in self.inputFiles: |
| 233 | + print "srcFile: ", srcFile |
| 234 | + (objFile, bcFile) = self.getArtifactNames(srcFile) |
| 235 | + print "{0} ===> ({1}, {2})".format(srcFile, objFile, bcFile) |
| 236 | + |
| 237 | + |
| 238 | + |
201 | 239 | # Same as above, but change the name of the output filename when
|
202 | 240 | # building the bitcode file so that we don't clobber the object file.
|
203 | 241 | class ClangBitcodeArgumentListFilter(ArgumentListFilter):
|
|
0 commit comments